本文整理汇总了C#中CONTROL_STATE类的典型用法代码示例。如果您正苦于以下问题:C# CONTROL_STATE类的具体用法?C# CONTROL_STATE怎么用?C# CONTROL_STATE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CONTROL_STATE类属于命名空间,在下文中一共展示了CONTROL_STATE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public override void Start()
{
base.Start();
state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled;
/*
if (btnValue)
PopOtherButtonsInGroup();
*/
// Runtime init stuff:
if (Application.isPlaying)
{
// Setup our transitions:
for (int i = 0; i < transitions.Length; ++i)
for (int j = 0; j < transitions[i].list.Length; ++j)
{
transitions[i].list[j].MainSubject = this.gameObject;
// Add our text as a sub-subject of our transitions:
if (spriteText != null)
transitions[i].list[j].AddSubSubject(spriteText.gameObject);
}
// We'll use this to setup our state:
int stateIdx = btnValue ? 0 : 1;
stateIdx = m_controlIsEnabled ? stateIdx : 2;
// Create a default collider if none exists:
if (collider == null)
{
AddCollider();
}
//SetState(stateIdx);
}
Value = btnValue;
if (useParentForGrouping && transform.parent != null)
SetGroup(transform.parent.GetHashCode());
else
SetGroup(radioGroup);
}
示例2: SetButtonState
// Sets the button's visual state to match its value.
protected virtual void SetButtonState()
{
int prevState = (int)state;
state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled;
int index = (int)state;
// First see if we need to postpone this state
// change for when we are active:
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
if (!gameObject.activeInHierarchy)
#else
if (!gameObject.active)
#endif
{
stateChangeWhileDeactivated = true;
return;
}
this.UseStateLabel(index);
// End any current transition:
if (prevTransition != null)
prevTransition.StopSafe();
StartTransition(index, prevState);
}
示例3: SetState
public void SetState(CONTROL_STATE s)
{
switch (s)
{
case CONTROL_STATE.NORMAL:
if (m_ButtonImage != null && m_ButtonImage.Length > 0)
{
for (int i = 0, iMax = m_ButtonImage.Length; i < iMax; ++i)
m_ButtonImage[i].target.spriteName = m_ButtonImage[i].normalSprite;
}
break;
case CONTROL_STATE.OVER:
if (m_ButtonImage != null && m_ButtonImage.Length > 0)
{
for (int i = 0, iMax = m_ButtonImage.Length; i < iMax; ++i)
m_ButtonImage[i].target.spriteName = m_ButtonImage[i].hoverSprite;
}
break;
case CONTROL_STATE.ACTIVE:
if (m_ButtonImage != null && m_ButtonImage.Length > 0)
{
for (int i = 0, iMax = m_ButtonImage.Length; i < iMax; ++i)
m_ButtonImage[i].target.spriteName = m_ButtonImage[i].pressedSprite;
}
break;
case CONTROL_STATE.DISABLED:
if (m_ButtonImage != null && m_ButtonImage.Length > 0)
{
for (int i = 0, iMax = m_ButtonImage.Length; i < iMax; ++i)
m_ButtonImage[i].target.spriteName = m_ButtonImage[i].disabledSprite;
}
break;
default:
break;
}
}
示例4: DisableMe
// Sets the control to its disabled appearance:
protected void DisableMe()
{
// End any current transition:
if (prevTransition != null)
prevTransition.StopSafe();
StartTransition((int)CONTROL_STATE.Disabled, (int)state);
state = CONTROL_STATE.Disabled;
}
示例5: Start
public override void Start()
{
if (m_started)
return;
base.Start();
// Assign our aggregate layers:
aggregateLayers = new SpriteRoot[1][];
aggregateLayers[0] = layers;
state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled;
/*
if (btnValue)
PopOtherButtonsInGroup();
*/
// Runtime init stuff:
if (Application.isPlaying)
{
// Setup our transitions:
for (int i = 0; i < transitions.Length; ++i)
for (int j = 0; j < transitions[i].list.Length; ++j)
{
transitions[i].list[j].MainSubject = this.gameObject;
// Add our text as a sub-subject of our transitions:
if (spriteText != null)
transitions[i].list[j].AddSubSubject(spriteText.gameObject);
}
// Add our text as a sub-subject of our transitions:
stateIndices = new int[layers.Length, 5];
// We'll use this to setup our state:
int stateIdx = btnValue ? 0 : 1;
stateIdx = m_controlIsEnabled ? stateIdx : 2;
// Populate our state indices based on if we
// find any valid states/animations in each
// sprite layer:
for (int i = 0; i < layers.Length; ++i)
{
if (layers[i] == null)
{
Debug.LogError("A null layer sprite was encountered on control \"" + name + "\". Please fill in the layer reference, or remove the empty element.");
continue;
}
stateIndices[i, 0] = layers[i].GetStateIndex("true");
stateIndices[i, 1] = layers[i].GetStateIndex("false");
stateIndices[i, 2] = layers[i].GetStateIndex("disabled");
stateIndices[i, 3] = layers[i].GetStateIndex("over");
stateIndices[i, 4] = layers[i].GetStateIndex("active");
// Add this as a subject of our transition for
// each state, as appropriate:
if (stateIndices[i, 0] != -1)
{
transitions[0].list[0].AddSubSubject(layers[i].gameObject);
transitions[0].list[1].AddSubSubject(layers[i].gameObject);
}
if (stateIndices[i, 1] != -1)
{
transitions[1].list[0].AddSubSubject(layers[i].gameObject);
transitions[1].list[1].AddSubSubject(layers[i].gameObject);
}
if (stateIndices[i, 2] != -1)
{
transitions[2].list[0].AddSubSubject(layers[i].gameObject);
transitions[2].list[1].AddSubSubject(layers[i].gameObject);
}
// Set the layer's state:
if (stateIndices[i, stateIdx] != -1)
layers[i].SetState(stateIndices[i, stateIdx]);
else
layers[i].Hide(true);
}
// Create a default collider if none exists:
if (collider == null)
AddCollider();
SetValue(btnValue, true);
if (useParentForGrouping && transform.parent != null)
SetGroup(transform.parent.GetHashCode());
else
SetGroup(radioGroup);
}
// Since hiding while managed depends on
// setting our mesh extents to 0, and the
// foregoing code causes us to not be set
// to 0, re-hide ourselves:
if (managed && m_hidden)
Hide(true);
}
示例6: SetLayerState
// Sets the layers to represent the current control state
// (includes states not directly supported by the control
// itself, such as Over and Active)
protected void SetLayerState(CONTROL_STATE s)
{
// Skip if redundant:
if (s == layerState)
return;
layerState = s;
// This index is valid for our layers as
// they can also support "Over" and "Active":
int layerIndex = (int)layerState;
// Loop through each layer and set its state,
// provided we have a valid index for that state:
for (int i = 0; i < layers.Length; ++i)
{
if (-1 != stateIndices[i, layerIndex])
{
layers[i].Hide(IsHidden());
layers[i].SetState(stateIndices[i, layerIndex]);
}
else
layers[i].Hide(true);
}
}
示例7: SetControlState
public virtual void SetControlState(CONTROL_STATE s)
{
SetControlState(s, false);
}
示例8: SetButtonState
// Sets the button's visual state to match its value.
protected void SetButtonState()
{
// Make sure we have a mesh:
if (spriteMesh == null)
return;
// Make sure we're initialized since
// we might have been called as a result of
// another button in our group settings its
// value on Start() before we've had a cance
// to Start() ourselves, meaning we may lack
// important info like a valid screensize,
// etc. which is necessary for sizing or else
// we'll get vertices of "infinite" value
// resulting in a !local.IsValid() error:
if (!m_started)
return;
int prevState = (int)state;
state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled;
int index = (int)state;
this.SetState(index);
this.UseStateLabel(index);
// Recalculate our collider
UpdateCollider();
// Loop through each layer and set its state,
// provided we have a valid index for that state:
for (int i = 0; i < layers.Length; ++i)
{
if (-1 != stateIndices[i, index])
{
layers[i].Hide(false);
layers[i].SetState(stateIndices[i, index]);
}
else
layers[i].Hide(true);
}
// End any current transition:
if (prevTransition != null)
prevTransition.StopSafe();
StartTransition(index, prevState);
// Notify our change delegate:
if (changeDelegate != null)
changeDelegate(this);
}
示例9: SetControlState
// Switches the displayed sprite(s) to match the current state:
protected void SetControlState(CONTROL_STATE s)
{
// If this is the same as the current state, ignore:
if (m_ctrlState == s)
return;
int prevState = (int)m_ctrlState;
m_ctrlState = s;
// End any current transition:
if (prevTransition != null)
prevTransition.StopSafe();
// Start a new transition:
StartTransition((int)s, prevState);
}
示例10: OnEnable
protected override void OnEnable()
{
base.OnEnable();
if (Application.isPlaying && m_started)
{
// Set it to some bogus value so we can force
// it to be reset:
m_ctrlState = (CONTROL_STATE)(-1);
if (controlIsEnabled)
SetControlState(CONTROL_STATE.NORMAL, true);
else
SetControlState(CONTROL_STATE.DISABLED, true);
}
}
示例11: QueueTransition
// Queues a transition to play following the previous (currently-running) transition
protected void QueueTransition(int newState, int prevState)
{
if (deleted)
return;
nextTransition = transitions[newState].list[DetermineNextTransition(newState, prevState)];
nextState = (CONTROL_STATE)newState;
// See if we've already queued to run a follow-up transition:
if (!transitionQueued)
prevTransition.AddTransitionEndDelegate(RunFollowupTrans);
transitionQueued = true;
}
示例12: SetControlState
public virtual void SetControlState(CONTROL_STATE s, bool suppressTransitions)
{
// If this is the same as the current state, ignore:
if (m_ctrlState == s)
return;
// Only stop our transition if it isn't an active state
// transition and we don't want it to run to completion:
if (!(alwaysFinishActiveTransition &&
(prevTransition == transitions[(int)UIButton.CONTROL_STATE.ACTIVE].list[0] ||
prevTransition == transitions[(int)UIButton.CONTROL_STATE.ACTIVE].list[1])
))
{
int prevState = (int)m_ctrlState;
m_ctrlState = s;
this.UseStateLabel((int)s);
if (s == CONTROL_STATE.DISABLED)
m_controlIsEnabled = false;
else
m_controlIsEnabled = true;
// Go no further if we're suppressing transitions:
if (suppressTransitions)
return;
// End any current transition:
if (prevTransition != null)
prevTransition.StopSafe();
// Start a new transition:
StartTransition((int)s, prevState);
}
else // Else, have our desired transition run when the active transition is complete:
{
// Go no further if we're suppressing transitions:
if (suppressTransitions)
return;
QueueTransition((int)s, (int)UIButton.CONTROL_STATE.ACTIVE);
}
}
示例13: SetControlState
// Switches the displayed sprite(s) to match the current state:
public void SetControlState(CONTROL_STATE s)
{
// If this is the same as the current state, ignore:
if (m_ctrlState == s)
return;
int prevState = (int)m_ctrlState;
m_ctrlState = s;
// Validate that we can go to this appearance:
if(animations[(int)s].GetFrameCount() > 0)
this.SetState((int)s);
this.UseStateLabel((int)s);
if (s == CONTROL_STATE.DISABLED)
m_controlIsEnabled = false;
else
m_controlIsEnabled = true;
// Recalculate our collider
UpdateCollider();
// Loop through each layer and set its state,
// provided we have a valid index for that state:
for (int i = 0; i < layers.Length; ++i)
{
if (-1 != stateIndices[i, (int)s])
{
layers[i].Hide(false);
layers[i].SetState(stateIndices[i, (int)s]);
}
else
layers[i].Hide(true);
}
// End any current transition:
if (prevTransition != null)
prevTransition.StopSafe();
// Start a new transition:
StartTransition((int)s, prevState);
}
示例14: DisableMe
// Sets the control to its disabled appearance:
protected void DisableMe()
{
this.UseStateLabel(states.Length - 1);
// End any current transition:
if (prevTransition != null)
prevTransition.StopSafe();
StartTransition((int)CONTROL_STATE.Disabled, (int)state);
state = CONTROL_STATE.Disabled;
}
示例15: Start
protected override void Start()
{
base.Start();
// Assign our aggregate layers:
aggregateLayers = new SpriteRoot[1][];
aggregateLayers[0] = layers;
state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled;
/*
if (btnValue)
PopOtherButtonsInGroup();
*/
// Runtime init stuff:
if (Application.isPlaying)
{
// Setup our transitions:
transitions[0].list[0].MainSubject = this.gameObject;
transitions[1].list[0].MainSubject = this.gameObject;
transitions[2].list[0].MainSubject = this.gameObject;
transitions[2].list[1].MainSubject = this.gameObject;
stateIndices = new int[layers.Length, 3];
// We'll use this to setup our state:
int stateIdx = btnValue ? 0 : 1;
stateIdx = m_controlIsEnabled ? stateIdx : 2;
// Populate our state indices based on if we
// find any valid states/animations in each
// sprite layer:
for (int i = 0; i < layers.Length; ++i)
{
if (layers[i] == null)
{
Debug.LogError("A null layer sprite was encountered on control \"" + name + "\". Please fill in the layer reference, or remove the empty element.");
continue;
}
stateIndices[i, 0] = layers[i].GetStateIndex("true");
stateIndices[i, 1] = layers[i].GetStateIndex("false");
stateIndices[i, 2] = layers[i].GetStateIndex("disabled");
// Add this as a subject of our transition for
// each state, as appropriate:
if (stateIndices[i, 0] != -1)
transitions[0].list[0].AddSubSubject(layers[i].gameObject);
if (stateIndices[i, 1] != -1)
transitions[1].list[0].AddSubSubject(layers[i].gameObject);
if (stateIndices[i, 2] != -1)
{
transitions[2].list[0].AddSubSubject(layers[i].gameObject);
transitions[2].list[1].AddSubSubject(layers[i].gameObject);
}
// Set the layer's state:
if (stateIndices[i, stateIdx] != -1)
layers[i].SetState(stateIndices[i, stateIdx]);
else
layers[i].Hide(true);
}
// Create a default collider if none exists:
if (collider == null)
AddCollider();
Value = btnValue;
}
}