Exemplo n.º 1
0
        private void SelectPlatformCallback(object data)
        {
            if (this.trigger.igniters.ContainsKey((int)data))
            {
                return;
            }

            int index = this.spIgnitersKeys.arraySize;

            this.spIgnitersKeys.InsertArrayElementAtIndex(index);
            this.spIgnitersValues.InsertArrayElementAtIndex(index);

            this.spIgnitersKeys.GetArrayElementAtIndex(index).intValue = (int)data;

            Igniter igniter = this.trigger.gameObject.AddComponent <IgniterStart>();

            igniter.Setup(this.trigger);
            igniter.enabled = false;

            this.spIgnitersValues.GetArrayElementAtIndex(index).objectReferenceValue = igniter;

            this.ignitersIndex = index;
            EditorPrefs.SetInt(KEY_IGNITER_INDEX_PREF, this.ignitersIndex);

            this.serializedObject.ApplyModifiedProperties();
            this.serializedObject.Update();

            this.updateIgnitersPlatforms = true;
        }
Exemplo n.º 2
0
        private void OnEnable()
        {
            SerializedObject   serializedObject = new SerializedObject(this);
            SerializedProperty spIgniters       = serializedObject.FindProperty("igniters");
            SerializedProperty spValues         = spIgniters.FindPropertyRelative("values");

            bool updated      = false;
            int  spValuesSize = spValues.arraySize;

            for (int i = 0; i < spValuesSize; ++i)
            {
                SerializedProperty spIgniter = spValues.GetArrayElementAtIndex(i);
                Igniter            igniter   = spIgniter.objectReferenceValue as Igniter;
                if (igniter != null && igniter.gameObject != gameObject)
                {
                    Igniter newIgniter = gameObject.AddComponent(igniter.GetType()) as Igniter;
                    EditorUtility.CopySerialized(igniter, newIgniter);
                    spIgniter.objectReferenceValue = newIgniter;
                    updated = true;
                }
            }

            if (updated)
            {
                serializedObject.ApplyModifiedPropertiesWithoutUndo();
            }
        }
Exemplo n.º 3
0
        private void SelectNewIgniter(Type igniterType)
        {
            SerializedProperty property = this.spIgnitersValues.GetArrayElementAtIndex(this.ignitersIndex);

            if (property.objectReferenceValue != null)
            {
                DestroyImmediate(property.objectReferenceValue, true);
                property.objectReferenceValue = null;
            }

            Igniter igniter = (Igniter)this.trigger.gameObject.AddComponent(igniterType);

            igniter.Setup(this.trigger);
            igniter.enabled = false;

            property.objectReferenceValue          = igniter;
            this.ignitersCache[this.ignitersIndex] = new IgniterCache(igniter);

            if (!Application.isPlaying)
            {
                EditorSceneManager.MarkSceneDirty(this.trigger.gameObject.scene);
            }
            serializedObject.ApplyModifiedPropertiesWithoutUndo();
            serializedObject.Update();
        }
Exemplo n.º 4
0
        // INITIALIZERS: -----------------------------------------------------------------------------------------------

        private void OnEnable()
        {
            if (target == null || serializedObject == null)
            {
                return;
            }
            this.trigger = (Trigger)target;

            SerializedProperty spIgniters = serializedObject.FindProperty("igniters");

            this.spIgnitersKeys   = spIgniters.FindPropertyRelative("keys");
            this.spIgnitersValues = spIgniters.FindPropertyRelative("values");

            if (this.spIgnitersKeys.arraySize == 0)
            {
                Igniter igniter = this.trigger.gameObject.AddComponent <IgniterStart>();
                igniter.Setup(this.trigger);
                igniter.enabled = false;

                this.spIgnitersKeys.InsertArrayElementAtIndex(0);
                this.spIgnitersValues.InsertArrayElementAtIndex(0);

                this.spIgnitersKeys.GetArrayElementAtIndex(0).intValue = Trigger.ALL_PLATFORMS_KEY;
                this.spIgnitersValues.GetArrayElementAtIndex(0).objectReferenceValue = igniter;

                this.serializedObject.ApplyModifiedProperties();
                this.serializedObject.Update();
            }

            this.UpdateIgnitersPlatforms();

            this.ignitersIndex = EditorPrefs.GetInt(KEY_IGNITER_INDEX_PREF, 0);
            if (this.ignitersIndex >= this.spIgnitersKeys.arraySize)
            {
                this.ignitersIndex = this.spIgnitersKeys.arraySize - 1;
                EditorPrefs.SetInt(KEY_IGNITER_INDEX_PREF, this.ignitersIndex);
            }

            this.spEvents  = serializedObject.FindProperty("events");
            this.spActions = serializedObject.FindProperty("actions");

            this.eventsList  = new ReorderableList(serializedObject, this.spEvents, true, true, false, false);
            this.actionsList = new ReorderableList(serializedObject, this.spActions, true, true, false, false);

            this.eventsList.drawElementCallback = this.DrawEventElement;
            this.eventsList.drawHeaderCallback  = this.DrawEventHeader;

            this.actionsList.drawElementCallback = this.DrawActionsElement;
            this.actionsList.drawHeaderCallback  = this.DrawActionsHeader;

            this.spMinDistance         = serializedObject.FindProperty("minDistance");
            this.spMinDistanceToPlayer = serializedObject.FindProperty("minDistanceToPlayer");
        }
Exemplo n.º 5
0
        // INITIALIZERS: -----------------------------------------------------------------------------------------------

        private void OnEnable()
        {
            if (target == null || serializedObject == null)
            {
                return;
            }
            this.trigger = (Trigger)target;

            SerializedProperty spIgniters = serializedObject.FindProperty("igniters");

            this.spIgnitersKeys   = spIgniters.FindPropertyRelative("keys");
            this.spIgnitersValues = spIgniters.FindPropertyRelative("values");

            if (this.spIgnitersKeys.arraySize == 0)
            {
                Igniter igniter = this.trigger.gameObject.AddComponent <IgniterStart>();
                igniter.Setup(this.trigger);
                igniter.enabled = false;

                this.spIgnitersKeys.InsertArrayElementAtIndex(0);
                this.spIgnitersValues.InsertArrayElementAtIndex(0);

                this.spIgnitersKeys.GetArrayElementAtIndex(0).intValue = Trigger.ALL_PLATFORMS_KEY;
                this.spIgnitersValues.GetArrayElementAtIndex(0).objectReferenceValue = igniter;

                this.serializedObject.ApplyModifiedPropertiesWithoutUndo();
                this.serializedObject.Update();
            }

            this.UpdateIgnitersPlatforms();

            this.ignitersIndex = EditorPrefs.GetInt(KEY_IGNITER_INDEX_PREF, 0);
            if (this.ignitersIndex >= this.spIgnitersKeys.arraySize)
            {
                this.ignitersIndex = this.spIgnitersKeys.arraySize - 1;
                EditorPrefs.SetInt(KEY_IGNITER_INDEX_PREF, this.ignitersIndex);
            }

            this.spItems      = serializedObject.FindProperty("items");
            this.sortableList = new EditorSortableList();

            this.spMinDistance         = serializedObject.FindProperty("minDistance");
            this.spMinDistanceToPlayer = serializedObject.FindProperty("minDistanceToPlayer");
        }
Exemplo n.º 6
0
        private void SelectNewIgniter(Type igniterType)
        {
            SerializedProperty property = this.spIgnitersValues.GetArrayElementAtIndex(this.ignitersIndex);

            if (property.objectReferenceValue != null)
            {
                DestroyImmediate(property.objectReferenceValue, true);
                property.objectReferenceValue = null;
            }

            Igniter igniter = (Igniter)this.trigger.gameObject.AddComponent(igniterType);

            igniter.Setup(this.trigger);
            igniter.enabled = false;

            property.objectReferenceValue          = igniter;
            this.ignitersCache[this.ignitersIndex] = new IgniterCache(igniter);

            serializedObject.ApplyModifiedProperties();
            serializedObject.Update();
        }
Exemplo n.º 7
0
        private void SetupPlatformIgniter()
        {
            bool overridePlatform = false;

                        #if UNITY_STANDALONE
            if (!overridePlatform)
            {
                overridePlatform = this.CheckPlatformIgniter(Platforms.Desktop);
            }
                        #endif

                        #if UNITY_EDITOR
            if (!overridePlatform)
            {
                overridePlatform = this.CheckPlatformIgniter(Platforms.Editor);
            }
            #endif

            #if UNITY_ANDROID || UNITY_IOS
            if (!overridePlatform)
            {
                overridePlatform = this.CheckPlatformIgniter(Platforms.Mobile);
            }
            #endif

            #if UNITY_TVOS
            if (!overridePlatform)
            {
                overridePlatform = this.CheckPlatformIgniter(Platforms.tvOS);
            }
            #endif

            #if UNITY_PS4
            if (!overridePlatform)
            {
                overridePlatform = this.CheckPlatformIgniter(Platforms.PS4);
            }
            #endif

            #if UNITY_XBOXONE
            if (!overridePlatform)
            {
                overridePlatform = this.CheckPlatformIgniter(Platforms.XBoxOne);
            }
            #endif

            #if UNITY_WIIU
            if (!overridePlatform)
            {
                overridePlatform = this.CheckPlatformIgniter(Platforms.WiiU);
            }
            #endif

            #if UNITY_SWITCH
            if (!overridePlatform)
            {
                overridePlatform = this.CheckPlatformIgniter(Platforms.Switch);
            }
            #endif

            if (!overridePlatform)
            {
                if (!this.igniters.ContainsKey(ALL_PLATFORMS_KEY))
                {
                    Igniter igniter = this.gameObject.AddComponent <IgniterStart>();
                    igniter.Setup(this);
                }

                this.igniters[ALL_PLATFORMS_KEY].enabled = true;
            }
        }
Exemplo n.º 8
0
        private void DoLayoutConfigurationOptions()
        {
            int removeIndex = -1;

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

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

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

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

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

            EditorGUI.EndDisabledGroup();
            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();
                }
            }

            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);
                }

                this.serializedObject.ApplyModifiedProperties();
                this.serializedObject.Update();

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