private void SetOpen(ActionsSerialized action, bool isOpen)
 {
     action.isOpen.boolValue            = isOpen;
     action.isEventOpen.boolValue       = isOpen;
     action.isUIScreenOpen.boolValue    = isOpen;
     action.isSceneLoaderOpen.boolValue = isOpen;
 }
        private void DrawActionMiniIcon(ActionsSerialized thisAction)
        {
            if (thisAction.isEvent.boolValue)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            GUILayout.Toggle(thisAction.isEvent.boolValue, new GUIContent(" E ", "Unity Events"), UIStyle.Toggle);
            if (thisAction.isUIScreen.boolValue)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            GUILayout.Toggle(thisAction.isUIScreen.boolValue, new GUIContent(" U ", "UIScreen"), UIStyle.Toggle);
            if (thisAction.isSceneLoader.boolValue)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            GUILayout.Toggle(thisAction.isSceneLoader.boolValue, new GUIContent(" S ", "Scene"), UIStyle.Toggle);


            GUI.backgroundColor = Color.white;
        }
        private ActionsSerialized SetActionsSerializedProperty(string inScriptActionsName)
        {
            ActionsSerialized actions = new ActionsSerialized
            {
                isEvent           = serializedObject.FindProperty(inScriptActionsName + ".isEvent"),
                unityEvent        = serializedObject.FindProperty(inScriptActionsName + ".unityEvent"),
                isUIScreen        = serializedObject.FindProperty(inScriptActionsName + ".isUIScreen"),
                uiScreen          = serializedObject.FindProperty(inScriptActionsName + ".uiScreen"),
                uiScreenIndex     = serializedObject.FindProperty(inScriptActionsName + ".uiScreenIndex"),
                isSceneLoader     = serializedObject.FindProperty(inScriptActionsName + ".isSceneLoader"),
                buildIndex        = serializedObject.FindProperty(inScriptActionsName + ".buildIndex"),
                isOpen            = serializedObject.FindProperty(inScriptActionsName + ".isOpen"),
                isEventOpen       = serializedObject.FindProperty(inScriptActionsName + ".isEventOpen"),
                isUIScreenOpen    = serializedObject.FindProperty(inScriptActionsName + ".isUIScreenOpen"),
                isSceneLoaderOpen = serializedObject.FindProperty(inScriptActionsName + ".isSceneLoaderOpen"),
                isSound           = serializedObject.FindProperty(inScriptActionsName + ".isSound"),
                sound             = serializedObject.FindProperty(inScriptActionsName + ".sound"),
                isVibration       = serializedObject.FindProperty(inScriptActionsName + ".isVibration"),
                vibrate           = serializedObject.FindProperty(inScriptActionsName + ".vibrate")
            };

            return(actions);
        }
        protected override void OnEnable()
        {
            base.OnEnable();
            p_SelectablePropertiesFieldsOpen = serializedObject.FindProperty("editorMenuSelectableProperties");
            //m_sortingOrder = serializedObject.FindProperty("sortingOrder");
            p_OnClickActions_SerializedObject = SetActionsSerializedProperty("actionsOnClick");
            p_OnDoubleClick_SerializedObject  = SetActionsSerializedProperty("actionsOnDoubleClick");
            p_OnLongClick_SerializedObject    = SetActionsSerializedProperty("actionsOnLongClick");
            p_OnPointerEnter_SerializedObject = SetActionsSerializedProperty("actionsOnPointerEnter");
            p_OnPointerExit_SerializedObject  = SetActionsSerializedProperty("actionsOnPointerExit");
            p_OnPointerDown_SerializedObject  = SetActionsSerializedProperty("actionsOnPointerDown");
            p_OnPointerUp_SerializedObject    = SetActionsSerializedProperty("actionsOnPointerUp");


            // set data from script to custom editor
            m_SelectablePropertiesFieldsOpen = new AnimBool(p_SelectablePropertiesFieldsOpen.boolValue);

            m_OnClick_FieldsOpen       = new AnimBool(p_OnClickActions_SerializedObject.isOpen.boolValue);
            m_OnDoubleClick_FieldsOpen = new AnimBool(p_OnDoubleClick_SerializedObject.isOpen.boolValue);
            m_OnLongClick_FieldsOpen   = new AnimBool(p_OnLongClick_SerializedObject.isOpen.boolValue);
            m_OnPointEnter_FieldsOpen  = new AnimBool(p_OnPointerEnter_SerializedObject.isOpen.boolValue);
            m_OnPointExit_FieldsOpen   = new AnimBool(p_OnPointerExit_SerializedObject.isOpen.boolValue);
            m_OnPointDown_FieldsOpen   = new AnimBool(p_OnPointerDown_SerializedObject.isOpen.boolValue);
            m_OnPointUp_FieldsOpen     = new AnimBool(p_OnPointerUp_SerializedObject.isOpen.boolValue);

            // repaint elements
            m_SelectablePropertiesFieldsOpen.valueChanged.AddListener(new UnityAction(base.Repaint));

            m_OnClick_FieldsOpen.valueChanged.AddListener(new UnityAction(base.Repaint));
            m_OnDoubleClick_FieldsOpen.valueChanged.AddListener(new UnityAction(base.Repaint));
            m_OnLongClick_FieldsOpen.valueChanged.AddListener(new UnityAction(base.Repaint));
            m_OnPointEnter_FieldsOpen.valueChanged.AddListener(new UnityAction(base.Repaint));
            m_OnPointExit_FieldsOpen.valueChanged.AddListener(new UnityAction(base.Repaint));
            m_OnPointDown_FieldsOpen.valueChanged.AddListener(new UnityAction(base.Repaint));
            m_OnPointUp_FieldsOpen.valueChanged.AddListener(new UnityAction(base.Repaint));
        }
        private void DrawActionSetup(ActionsSerialized thisAction)
        {
            m_isEventOpen       = thisAction.isEventOpen.boolValue;
            m_isUIScreenOpen    = thisAction.isUIScreenOpen.boolValue;
            m_isSceneLoaderOpen = thisAction.isSceneLoaderOpen.boolValue;

            EditorGUI.indentLevel++;
            ///////////////////////////////////
            EditorGUILayout.BeginVertical("ObjectFieldThumb");
            EditorGUILayout.BeginHorizontal("ObjectPickerToolbar");
            m_isEventOpen = EditorGUILayout.Foldout(m_isEventOpen, new GUIContent("Invoke Event", "Call event after a specified action."), true, "Foldout");
            if (thisAction.isEvent.boolValue)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            thisAction.isEvent.boolValue = GUILayout.Toggle(thisAction.isEvent.boolValue, thisAction.isEvent.boolValue ? "  ENABLE  " : " DISABLE ", UIStyle.Toggle);
            if (thisAction.isEvent.boolValue)
            {
                GUI.backgroundColor = colorBacgroundEnable;
            }
            else
            {
                GUI.backgroundColor = colorBacgroundDisable;
            }
            EditorGUILayout.EndHorizontal();
            thisAction.isEventOpen.boolValue = m_isEventOpen;
            if (m_isEventOpen)
            {
                EditorGUILayout.BeginVertical("Box");
                EditorGUI.indentLevel++;
                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(thisAction.unityEvent, new GUIContent("On Action"));
                EditorGUILayout.Space();
                EditorGUI.indentLevel--;
                EditorGUILayout.EndVertical();
            }
            GUI.backgroundColor = Color.white;
            EditorGUILayout.EndVertical();
            ///////////////////////////////////


            EditorGUILayout.BeginVertical("ObjectFieldThumb");
            EditorGUILayout.BeginHorizontal("ObjectPickerToolbar");
            m_isUIScreenOpen = EditorGUILayout.Foldout(m_isUIScreenOpen, new GUIContent("Open UI Screen", "Open UIScreen after a specified action."), true, "Foldout");
            if (thisAction.isUIScreen.boolValue)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            thisAction.isUIScreen.boolValue = GUILayout.Toggle(thisAction.isUIScreen.boolValue, thisAction.isUIScreen.boolValue ? "  ENABLE  " : " DISABLE ", UIStyle.Toggle);
            if (thisAction.isUIScreen.boolValue)
            {
                GUI.backgroundColor = colorBacgroundEnable;
            }
            else
            {
                GUI.backgroundColor = colorBacgroundDisable;
            }
            EditorGUILayout.EndHorizontal();
            thisAction.isUIScreenOpen.boolValue = m_isUIScreenOpen;
            if (m_isUIScreenOpen)
            {
                EditorGUILayout.BeginVertical("Box");
                EditorGUI.indentLevel++;
                EditorGUILayout.Space();


                UIScreen[] uiScreen      = UIEditor.GetUIScreens();
                string[]   uiScreenNames = UIEditor.GetUIScreensNames(uiScreen);
                int        idScreen      = Array.FindIndex(uiScreen, obj => obj == thisAction.uiScreen.GetValue <UIScreen>());
                idScreen = (idScreen < 0) ? 0 : idScreen;
                idScreen = EditorGUILayout.Popup(new GUIContent("UIScreen", "Choose UIScreen to open."), idScreen, uiScreenNames);

                if (uiScreen.Length > 0)
                {
                    thisAction.uiScreen.SetValue(uiScreen[idScreen]);
                }

                if (GUILayout.Button(new GUIContent("Ping", "Show connected UIScreen to this UIButton.")) && thisAction.uiScreen.GetValue <UIScreen>() != null)
                {
                    EditorGUIUtility.PingObject(thisAction.uiScreen.GetValue <UIScreen>().GetInstanceID());
                    bezier = 1f;
                }
                EditorGUILayout.Space();
                EditorGUI.indentLevel--;
                EditorGUILayout.EndVertical();
            }
            GUI.backgroundColor = Color.white;
            EditorGUILayout.EndVertical();
            ///////////////////////////////////


            EditorGUILayout.BeginVertical("ObjectFieldThumb");
            EditorGUILayout.BeginHorizontal("ObjectPickerToolbar");
            m_isSceneLoaderOpen = EditorGUILayout.Foldout(m_isSceneLoaderOpen, new GUIContent("Load Scene", "Open Scene after a specified action."), true, "Foldout");
            if (thisAction.isSceneLoader.boolValue)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            thisAction.isSceneLoader.boolValue = GUILayout.Toggle(thisAction.isSceneLoader.boolValue, thisAction.isSceneLoader.boolValue ? "  ENABLE  " : " DISABLE ", UIStyle.Toggle);
            if (thisAction.isSceneLoader.boolValue)
            {
                GUI.backgroundColor = colorBacgroundEnable;
            }
            else
            {
                GUI.backgroundColor = colorBacgroundDisable;
            }
            EditorGUILayout.EndHorizontal();
            thisAction.isSceneLoaderOpen.boolValue = m_isSceneLoaderOpen;
            if (m_isSceneLoaderOpen)
            {
                EditorGUILayout.BeginVertical("Box");
                EditorGUI.indentLevel++;
                EditorGUILayout.Space();
                if (UISceneManager.Instance)
                {
                    // get scene list
                    List <SceneProperties> sceneProperties = GetAllScenes(UISceneManager.Instance.sceneProperties);
                    string[] scenesNames = ConvertScenesToString(sceneProperties);
                    int      idScene     = -1;
                    idScene = sceneProperties.FindIndex(obj => obj.buildIndex == thisAction.buildIndex.intValue);
                    idScene = (idScene < 0) ? 0 : idScene;
                    idScene = EditorGUILayout.Popup(new GUIContent("Scene", "Choose Scene to open."), idScene, scenesNames);
                    if (sceneProperties.Count > 0)
                    {
                        thisAction.buildIndex.intValue = sceneProperties[idScene].buildIndex;
                    }

                    EditorGUILayout.Space();
                    if (GUILayout.Button(new GUIContent("Open Scene Manager", "Show UI Scene Manager in inspector.")))
                    {
                        EditorGUIUtility.PingObject(UISceneManager.Instance.gameObject);
                        Selection.activeGameObject = UISceneManager.Instance.gameObject;
                    }
                }
                else
                {
                    GUILayout.Label("Create UI Scene Manager first");
                    GUILayout.Label("Find it in \"Create/KreliStudio/UI SceneManager\".");
                    EditorGUILayout.Space();
                }
                EditorGUI.indentLevel--;
                EditorGUILayout.EndVertical();
            }
            GUI.backgroundColor = Color.white;

            /*
             * EditorGUILayout.BeginVertical("HelpBox");
             * GUILayout.Label("Sound & Vibration",UIStyle.LabelBoldMini);
             * EditorGUILayout.PropertyField(thisAction.isSound, new GUIContent("Play Sound"));
             * if (thisAction.isSound.boolValue)
             * {
             *  EditorGUILayout.PropertyField(thisAction.sound.FindPropertyRelative("clip"), new GUIContent("Clip"));
             *  EditorGUILayout.Slider(thisAction.sound.FindPropertyRelative("volume"), 0f, 1f, new GUIContent("Volume"));
             *  EditorGUILayout.Slider(thisAction.sound.FindPropertyRelative("pitch"), 0.1f, 3f, new GUIContent("Pitch"));
             * }
             * EditorGUILayout.PropertyField(thisAction.isVibration, new GUIContent("Vibration"));
             * if (thisAction.isVibration.boolValue)
             * {
             *  EditorGUILayout.IntSlider(thisAction.vibrate, 10, 1000, new GUIContent("Duration"));
             * }
             *
             * EditorGUILayout.EndVertical();*/
            EditorGUILayout.EndVertical();
            ///////////////////////////////////
            EditorGUI.indentLevel--;
        }