示例#1
0
 private void OnValueChanged(bool isOn)
 {
     if (!m_toggle.enabled)
     {
         m_uiStateSwitcher.SwitchState("disable");
     }
     else if (isOn)
     {
         m_uiStateSwitcher.SwitchState("isOn");
     }
     else
     {
         m_uiStateSwitcher.SwitchState("isOff");
     }
 }
 static int QPYX_SwitchState_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 2);
         UIStateSwitcher QPYX_obj_YXQP  = (UIStateSwitcher)ToLua.CheckObject <UIStateSwitcher>(L_YXQP, 1);
         string          QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 2);
         QPYX_obj_YXQP.SwitchState(QPYX_arg0_YXQP);
         return(0);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
 static int SwitchState(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UIStateSwitcher obj  = (UIStateSwitcher)ToLua.CheckObject <UIStateSwitcher>(L, 1);
         string          arg0 = ToLua.CheckString(L, 2);
         obj.SwitchState(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#4
0
    public override void OnInspectorGUI()
    {
        ValidateStateSwitcher();

        EditorGUILayout.LabelField("States:", EditorStyles.boldLabel);

        EditorGUI.indentLevel++;

        UIStateSwitcher.State deleteState = null;

        if (stateSwitcher.states.Count > 0)
        {
            foreach (UIStateSwitcher.State state in stateSwitcher.states)
            {
                EditorGUILayout.BeginHorizontal();

                if (stateSwitcher.CurrentStateID == state.StateID)
                {
                    EditorGUILayout.Toggle(true, EditorStyles.radioButton, GUILayout.Width(15));
                }
                else
                {
                    if (EditorGUILayout.Toggle(false, EditorStyles.radioButton, GUILayout.Width(15)))
                    {
                        stateSwitcher.SwitchState(state);
                        PersistChanges();
                    }
                }

                state.stateName = EditorGUILayout.TextField(state.stateName);

                if (GUILayout.Button("Revert"))
                {
                    state.Revert();
                    PersistChanges();
                }

                if (GUILayout.Button("Save"))
                {
                    if (state.StateID == stateSwitcher.CurrentStateID || EditorUtility.DisplayDialog("Overwrite state?",
                                                                                                     "Are you sure you want to overwrite state '" + state.stateName + "' with the current layout?", "Yes", "No"))
                    {
                        state.Save();
                        EditorUtility.SetDirty(target);
                    }
                }

                if (GUILayout.Button("Delete") && EditorUtility.DisplayDialog("Delete state?", "Are you sure you want to delete state '" + state.stateName + "'?", "Yes", "No"))
                {
                    deleteState = state;
                }

                EditorGUILayout.EndHorizontal();
            }
        }
        else
        {
            EditorGUILayout.HelpBox("No states created yet!", MessageType.Info);
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.Space();
        if (GUILayout.Button("New"))
        {
            CreateNewState("New state");
        }
        EditorGUILayout.EndHorizontal();
        EditorGUI.indentLevel--;

        showTargetObjects = EditorGUILayout.Foldout(showTargetObjects, "Target objects");

        if (showTargetObjects)
        {
            EditorGUI.indentLevel++;

            foreach (GameObject go in stateSwitcher.Targets)
            {
                if (go == null)
                {
                    continue;
                }

                if (!RenderTargetObject(go))
                {
                    break;
                }
            }

            EditorGUILayout.Space();

            Object obj = EditorGUILayout.ObjectField("Drop to add", null, typeof(GameObject), true);
            if (obj != null)
            {
                AddTargetObject(obj as GameObject);
            }

            EditorGUI.indentLevel--;
        }

        if (deleteState != null)
        {
            DeleteState(deleteState);
        }
    }