Ejemplo n.º 1
0
        // states management

        /*
         *      Func: ItemStateChanged (itemName)
         *      Internal function. Called automatically from <UIStateItem> for each state change
         *
         *      This function used as an internal callback between components <UIStateItem> and <UIStateGroup>
         *
         *      Parameters:
         *              itemName - item name
         */
        public virtual void ItemStateChanged(string itemName)
        {
            UIStateItem StateItem = GetStateItem(itemName);

            if (StateItem == null)
            {
                return;
            }
        }
Ejemplo n.º 2
0
        /*
         *      Func: SetItemInactive(itemName)
         *      Change item with given name to state UIStateItem.STATE_INACTIVE
         *
         *      (start code)
         *      GetComponent<UIStateGroupControl>().SetItemInactive("item (2)");
         *      (end code)
         *
         *      Parameters:
         *              itemName - <UIStateItem> item name
         */
        public void SetItemInactive(string itemName)
        {
            UIStateItem StateItem = GetStateItem(itemName);

            if (StateItem == null)
            {
                return;
            }
            StateItem.SetStateInactive();
        }
Ejemplo n.º 3
0
 /*
  *      Func: SetStateForAllItems (state)
  *      Set state for all items
  *
  *      (start code)
  *      GetComponent<UIStateGroup>().SetStateForAllItems(UIStateItem.STATE_INACTIVE);
  *      (end code)
  *
  *      Parameters:
  *              state - state name
  */
 public void SetStateForAllItems(string state)
 {
     if (OnStateChange != null)
     {
         OnStateChange.Invoke();                            // call OnStateChange event
     }
     for (int i = 0; i < items.Length; i++)
     {
         UIStateItem StateItem = items[i] as UIStateItem;
         if (StateItem != null)
         {
             StateItem.SetState(state);
         }
     }
 }
Ejemplo n.º 4
0
 /*
  *      Func: SetStateForItems (state, itemsNames)
  *      Set state for several items
  *
  *      (start code)
  *      GetComponent<UIStateGroup>().SetStateForItems(UIStateItem.STATE_ACTIVE, new string [] {"item (1)", "item (3)"});
  *      (end code)
  *
  *      Parameters:
  *              state - state name
  *              itemsNames - string array of <UIStateItem> items names
  */
 public void SetStateForItems(string state, string [] itemsNames)
 {
     if (OnStateChange != null)
     {
         OnStateChange.Invoke();                            // call OnStateChange event
     }
     for (int i = 0; i < itemsNames.Length; i++)
     {
         UIStateItem StateItem = GetItem(itemsNames[i]) as UIStateItem;
         if (StateItem != null)
         {
             StateItem.SetState(state);
         }
     }
 }
Ejemplo n.º 5
0
        /*
         *      Func: Flush()
         *      Flush all items for default state according to current <Mode>
         *
         *      (start code)
         *      GetComponent<UIStateGroupControl>().Flush();
         *      (end code)
         */
        public void Flush()
        {
            switch (Mode)
            {
            case STATE_GROUP_CONTROL_MODE.OneActive:
                selectedItem = null;
                for (int i = 0; i < StateItems.Length; i++)
                {
                    StateItems[i].SetStateInactive();
                }
                break;

            case STATE_GROUP_CONTROL_MODE.OneInActive:
                selectedItem = null;
                for (int i = 0; i < StateItems.Length; i++)
                {
                    StateItems[i].SetStateActive();
                }
                break;
            }
        }
Ejemplo n.º 6
0
        protected override void InitInspector()
        {
            base.InitInspector();

            // do initialization here
            scriptStateItem = (UIStateItem)target;
            if (!Application.isPlaying)
            {
                scriptStateItem.Init(true);
            }

            statesUi                   = serializedObject.FindProperty("statesUi");
            isStateItemExpanded        = serializedObject.FindProperty("isStateItemExpanded");
            isStateItemStatesExpanded  = serializedObject.FindProperty("isStateItemStatesExpanded");
            isStateItemUiExpanded      = serializedObject.FindProperty("isStateItemUiExpanded");
            isStateItemTestingExpanded = serializedObject.FindProperty("isStateItemTestingExpanded");

            OnStateChange = serializedObject.FindProperty("OnStateChange");

            statesUiMode = serializedObject.FindProperty("statesUiMode");

            defaultStateId = serializedObject.FindProperty("defaultStateId");
        }
Ejemplo n.º 7
0
        /*
         *      Func: ItemStateChanged (itemName)
         *      Internal function. Called automatically from <UIStateItem> for each state change
         *
         *      See <UIStateGroup.ItemStateChanged (itemName)> for details.
         *
         *      Parameters:
         *              itemName - item name
         */
        public override void ItemStateChanged(string itemName)
        {
            UIStateItem StateItem = GetStateItem(itemName);

            if (StateItem == null)
            {
                return;
            }

            //		if Mode - one active
            //			if item active
            //				set others to inactive
            if (Mode == STATE_GROUP_CONTROL_MODE.OneActive)
            {
                if (StateItem.CurrentState == UIStateItem.STATE_ACTIVE)
                {
                    selectedItem = StateItem;

                    for (int i = 0; i < StateItems.Length; i++)
                    {
                        if (StateItems[i].itemName != itemName)
                        {
                            StateItems[i].SetState(UIStateItem.STATE_INACTIVE);
                        }
                    }
                }
                else
                {
                    if (SelectedItemName == itemName)
                    {
                        selectedItem = null;
                    }
                }
            }

            //		if Mode - one inactive
            //			if item inactive
            //				set others to active
            if (Mode == STATE_GROUP_CONTROL_MODE.OneInActive)
            {
                if (StateItem.CurrentState == UIStateItem.STATE_INACTIVE)
                {
                    selectedItem = StateItem;

                    for (int i = 0; i < StateItems.Length; i++)
                    {
                        if (StateItems[i].itemName != itemName)
                        {
                            StateItems[i].SetState(UIStateItem.STATE_ACTIVE);
                        }
                    }
                }
                else
                {
                    if (SelectedItemName == itemName)
                    {
                        selectedItem = null;
                    }
                }
            }
        }