Exemple #1
0
        public void GUITick(ref GameDesignerEditorProfile GameDesignerEditorProfile)
        {
            this.OnEnabled();
            var rawSelectedObj     = GameDesignerHelper.GetCurrentSceneSelectedObject();
            C   currentSelectedObj = default(C);

            if (rawSelectedObj != null)
            {
                currentSelectedObj = rawSelectedObj.GetComponent <C>();
            }

            if (currentSelectedObj == null)
            {
                this.cachedEditor = null;
            }
            if (currentSelectedObj != null)
            {
                if (currentSelectedObj != this.lastFrameObj)
                {
                    CreateEditor(currentSelectedObj);
                }

                if (GUILayout.Button("REFRESH", GUILayout.Width(50f)))
                {
                    CreateEditor(currentSelectedObj);
                }

                if (this.cachedEditor != null)
                {
                    this.cachedEditor.OnInspectorGUI();
                }
            }
            this.lastFrameObj = currentSelectedObj;
        }
Exemple #2
0
 public virtual void GUITick(ref GameDesignerEditorProfile GameDesignerEditorProfile)
 {
     this.currentSelectedObjet = GameDesignerHelper.GetCurrentSceneSelectedObject();
     this.prefabToAdd          = (T)EditorGUILayout.ObjectField(this.prefabToAdd, typeof(T), false);
     EditorGUI.BeginDisabledGroup(!this.IsAbleToAdd());
     if (GUILayout.Button("ADD TO SCENE"))
     {
         if (this.prefabToAdd != null)
         {
             var parent = this.ParentGameObject.Invoke();
             if (parent != null)
             {
                 PrefabUtility.InstantiatePrefab(this.prefabToAdd, this.ParentGameObject.Invoke().transform);
             }
             else
             {
                 Debug.LogError("Parent not found.");
             }
         }
         else
         {
             Debug.LogError("Prefab not set.");
         }
     }
     EditorGUI.EndDisabledGroup();
 }
Exemple #3
0
 public virtual void GUITick(ref GameDesignerEditorProfile GameDesignerEditorProfile)
 {
     this.currentSelectedObjet = GameDesignerHelper.GetCurrentSceneSelectedObject();
     EditorGUI.BeginDisabledGroup(this.IsDisabled());
     if (GUILayout.Button("EDIT"))
     {
         this.OnEdit(this.currentSelectedObjet.GetComponent <T>());
         EditorUtility.SetDirty(this.currentSelectedObjet);
     }
     EditorGUI.EndDisabledGroup();
 }
Exemple #4
0
        public void GUITick(ref GameDesignerEditorProfile GameDesignerEditorProfile)
        {
            var currentSelectedObj = GameDesignerHelper.GetCurrentSceneSelectedObject();

            this.ModelObject = (GameObject)EditorGUILayout.ObjectField("New Model : ", this.ModelObject, typeof(GameObject), false);

            EditorGUI.BeginDisabledGroup(this.ModelObject == null || currentSelectedObj == null || currentSelectedObj.GetComponent <T>() == null);
            if (GUILayout.Button("SET MODEL"))
            {
                this.OnClick(currentSelectedObj);
            }
            EditorGUI.EndDisabledGroup();
        }
Exemple #5
0
        public void GUITick(ref GameDesignerEditorProfile GameDesignerEditorProfile)
        {
            if (CommonGameConfigurations == null)
            {
                CommonGameConfigurations = new CommonGameConfigurations();
                EditorInformationsHelper.InitProperties(ref CommonGameConfigurations);
            }

            if (this.GameDesignerEditorProfile == null)
            {
                this.GameDesignerEditorProfile = GameDesignerEditorProfile;
            }

            if (GameDesignerEditorProfileSO == null)
            {
                GameDesignerEditorProfileSO = new SerializedObject(this.GameDesignerEditorProfile);
            }

            currentSelectedObjet = GameDesignerHelper.GetCurrentSceneSelectedObject();
            selectedModuleIndex  = EditorGUILayout.Popup(selectedModuleIndex, AvailableModules.ConvertAll(t => t.Name).ToArray());
            EditorGUILayout.HelpBox(POIModuleDescription(AvailableModules[selectedModuleIndex]), MessageType.None);

            T selectedPointOfIterestType = null;

            if (currentSelectedObjet != null)
            {
                selectedPointOfIterestType = currentSelectedObjet.GetComponent <T>();
            }

            var additionalEditAllowed = AdditionalEditCondition(AvailableModules[selectedModuleIndex]);

            EditorGUILayout.BeginHorizontal();
            var newAdd    = GUILayout.Toggle(add, "ADD", EditorStyles.miniButtonLeft);
            var newRemove = GUILayout.Toggle(remove, "REMOVE", EditorStyles.miniButtonRight);

            if (newAdd && newRemove)
            {
                if (add && !remove)
                {
                    add    = false;
                    remove = true;
                }
                else if (!add && remove)
                {
                    add    = true;
                    remove = false;
                }
                else
                {
                    add    = newAdd;
                    remove = newRemove;
                }
            }
            else
            {
                add    = newAdd;
                remove = newRemove;
            }

            EditorGUILayout.EndHorizontal();


            EditorGUI.BeginDisabledGroup(IsDisabled() || !additionalEditAllowed);
            if (GUILayout.Button("EDIT"))
            {
                OnEnabled();
                OnEdit(selectedPointOfIterestType, AvailableModules[selectedModuleIndex]);
                EditorUtility.SetDirty(currentSelectedObjet);
            }

            EditorGUI.EndDisabledGroup();

            if (currentSelectedObjet != null && selectedPointOfIterestType != null)
            {
                DoModuleListing(selectedPointOfIterestType);
            }

            GameDesignerEditorProfileSO.ApplyModifiedProperties();
            GameDesignerEditorProfileSO.Update();
        }