Ejemplo n.º 1
0
        private void DoLayoutConfigurationOptions()
        {
            int removeIndex = -1;

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.BeginHorizontal();

            int ignIndex = GUILayout.Toolbar(this.ignitersIndex, IGNITERS_PLATFORM_NAMES);

            if (ignIndex != this.ignitersIndex)
            {
                this.ignitersIndex = ignIndex;
                EditorPrefs.SetInt(KEY_IGNITER_INDEX_PREF, this.ignitersIndex);
            }

            if (GUILayout.Button("+", CoreGUIStyles.GetButtonLeft(), GUILayout.Width(25f)))
            {
                this.SelectPlatformMenu();
            }

            EditorGUI.BeginDisabledGroup(this.ignitersIndex == 0);
            if (GUILayout.Button("-", CoreGUIStyles.GetButtonMid(), GUILayout.Width(25f)))
            {
                removeIndex = this.ignitersIndex;
            }
            EditorGUI.EndDisabledGroup();

            GUIStyle settingStyle = (this.foldoutAdvancedSettings
                ? CoreGUIStyles.GetToggleButtonRightOn()
                : CoreGUIStyles.GetToggleButtonRightOff()
                                     );

            if (GUILayout.Button(GC_SETTINGS, settingStyle, GUILayout.Width(25f), GUILayout.Height(18f)))
            {
                this.foldoutAdvancedSettings = !this.foldoutAdvancedSettings;
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.PrefixLabel(this.ignitersCache[this.ignitersIndex].name, EditorStyles.miniBoldLabel);
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Change Trigger", GUILayout.Width(SelectTypePanel.WINDOW_WIDTH)))
            {
                SelectTypePanel selectTypePanel = new SelectTypePanel(this.SelectNewIgniter, "Triggers", typeof(Igniter));
                PopupWindow.Show(this.selectIgniterButtonRect, selectTypePanel);
            }

            if (UnityEngine.Event.current.type == EventType.Repaint)
            {
                this.selectIgniterButtonRect = GUILayoutUtility.GetLastRect();
            }

            EditorGUILayout.EndHorizontal();

            if (this.ignitersCache[this.ignitersIndex].serializedObject != null)
            {
                string comment = this.ignitersCache[this.ignitersIndex].comment;
                if (!string.IsNullOrEmpty(comment))
                {
                    EditorGUILayout.HelpBox(comment, MessageType.Info);
                }

                Igniter.PaintEditor(this.ignitersCache[this.ignitersIndex].serializedObject);
            }

            if (this.ignitersCache[this.ignitersIndex].requiresCollider)
            {
                Collider collider = this.trigger.GetComponent <Collider>();
                if (!collider)
                {
                    this.PaintNoCollider();
                }
            }

            if (this.foldoutAdvancedSettings)
            {
                EditorGUILayout.Space();
                this.PaintAdvancedSettings();
            }

            EditorGUILayout.EndVertical();

            if (removeIndex > 0)
            {
                UnityEngine.Object obj = this.spIgnitersValues.GetArrayElementAtIndex(removeIndex).objectReferenceValue;
                this.spIgnitersValues.GetArrayElementAtIndex(removeIndex).objectReferenceValue = null;

                this.spIgnitersKeys.DeleteArrayElementAtIndex(removeIndex);
                this.spIgnitersValues.DeleteArrayElementAtIndex(removeIndex);

                if (obj != null)
                {
                    DestroyImmediate(obj, true);
                }

                if (!Application.isPlaying)
                {
                    EditorSceneManager.MarkSceneDirty(this.trigger.gameObject.scene);
                }
                this.serializedObject.ApplyModifiedPropertiesWithoutUndo();
                this.serializedObject.Update();

                this.updateIgnitersPlatforms = true;
                if (this.ignitersIndex >= this.spIgnitersKeys.arraySize)
                {
                    this.ignitersIndex = this.spIgnitersKeys.arraySize - 1;
                }
            }
        }