Example #1
0
        public void OnClauseGUI()
        {
            if (target == null || serializedObject == null)
            {
                return;
            }
            serializedObject.Update();

            EditorGUILayout.PropertyField(this.spDescription);

            GUIContent gcIf   = ClausesUtilities.Get(ClausesUtilities.Icon.If);
            Rect       rectIf = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.boldLabel);

            EditorGUI.LabelField(rectIf, gcIf, EditorStyles.boldLabel);

            this.conditionsListEditor.OnInspectorGUI();
            EditorGUILayout.Space();

            GUIContent gcThen   = ClausesUtilities.Get(ClausesUtilities.Icon.Then);
            Rect       rectThen = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.boldLabel);

            EditorGUI.LabelField(rectThen, gcThen, EditorStyles.boldLabel);

            ActionsEditor.Return returnActions = ActionsEditor.PaintActionsGUI(
                this.parentConditions.gameObject,
                this.spActions,
                this.actionsEditor
                );

            if (returnActions != null)
            {
                this.spActions     = returnActions.spParentActions;
                this.actionsEditor = returnActions.parentActionsEditor;

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

            serializedObject.ApplyModifiedPropertiesWithoutUndo();
        }
Example #2
0
        public void OnInteractionGUI()
        {
            if (target == null || serializedObject == null)
            {
                return;
            }
            serializedObject.Update();

            EditorGUILayout.PropertyField(this.spDescription);

            GUIContent gcIf   = InteractionUtilities.Get(InteractionUtilities.Icon.If);
            Rect       rectIf = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.boldLabel);

            EditorGUI.LabelField(rectIf, gcIf, EditorStyles.boldLabel);

            this.conditionsListEditor.OnInspectorGUI();
            EditorGUILayout.Space();

            GUIContent gcThen   = InteractionUtilities.Get(InteractionUtilities.Icon.Then);
            Rect       rectThen = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.boldLabel);

            EditorGUI.LabelField(rectThen, gcThen, EditorStyles.boldLabel);

            ActionsEditor.Return returnActions = ActionsEditor.PaintActionsGUI(
                this.parentEvent.gameObject,
                this.spActions,
                this.actionsEditor
                );

            if (returnActions != null)
            {
                this.spActions     = returnActions.spParentActions;
                this.actionsEditor = returnActions.parentActionsEditor;

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

            serializedObject.ApplyModifiedProperties();
        }
Example #3
0
        private void PaintEvent()
        {
            if (this.spInteractions != null && this.spInteractions.arraySize > 0)
            {
                this.PaintInteractions();
            }
            else
            {
                EditorGUILayout.HelpBox(MSG_EMTPY_EVENTS, MessageType.None);
            }

            float widthAddInteraction = 100f;
            Rect  rectControls        = GUILayoutUtility.GetRect(GUIContent.none, CoreGUIStyles.GetToggleButtonNormalOn());
            Rect  rectAddInteraction  = new Rect(
                rectControls.x + (rectControls.width / 2.0f) - (widthAddInteraction + 25f) / 2.0f,
                rectControls.y,
                widthAddInteraction,
                rectControls.height
                );

            Rect rectPaste = new Rect(
                rectAddInteraction.x + rectAddInteraction.width,
                rectControls.y,
                25f,
                rectControls.height
                );

            if (GUI.Button(rectAddInteraction, "Add Interaction", CoreGUIStyles.GetButtonLeft()))
            {
                Interaction interactionCreated = this.instance.gameObject.AddComponent <Interaction>();

                int interactionCreatedIndex = this.spInteractions.arraySize;
                this.spInteractions.InsertArrayElementAtIndex(interactionCreatedIndex);
                this.spInteractions.GetArrayElementAtIndex(interactionCreatedIndex).objectReferenceValue = interactionCreated;

                this.AddSubEditorElement(interactionCreated, -1, true);

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

            GUIContent gcPaste = InteractionUtilities.Get(InteractionUtilities.Icon.Paste);

            EditorGUI.BeginDisabledGroup(CLIPBOARD_INTERACTION == null);
            if (GUI.Button(rectPaste, gcPaste, CoreGUIStyles.GetButtonRight()))
            {
                Interaction copy = this.instance.gameObject.AddComponent <Interaction>();
                EditorUtility.CopySerialized(CLIPBOARD_INTERACTION, copy);

                if (copy.conditionsList != null)
                {
                    IConditionsList conditionsListSource = copy.conditionsList;
                    IConditionsList conditionsListCopy   = this.instance.gameObject.AddComponent <IConditionsList>();

                    EditorUtility.CopySerialized(conditionsListSource, conditionsListCopy);
                    EventEditor.DuplicateIConditionList(conditionsListSource, conditionsListCopy);

                    SerializedObject soCopy = new SerializedObject(copy);
                    soCopy.FindProperty(InteractionEditor.PROP_CONDITIONSLIST).objectReferenceValue = conditionsListCopy;
                    soCopy.ApplyModifiedProperties();
                    soCopy.Update();
                }

                int interactionIndex = this.spInteractions.arraySize;
                this.spInteractions.InsertArrayElementAtIndex(interactionIndex);
                this.spInteractions.GetArrayElementAtIndex(interactionIndex).objectReferenceValue = copy;

                this.AddSubEditorElement(copy, -1, true);

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

                DestroyImmediate(CLIPBOARD_INTERACTION.gameObject, true);
                CLIPBOARD_INTERACTION = null;

                /*
                 * int srcIndex = duplicateInteractionIndex;
                 * int dstIndex = duplicateInteractionIndex + 1;
                 *
                 * Interaction source = (Interaction)this.subEditors[srcIndex].target;
                 * Interaction copy = (Interaction)this.instance.gameObject.AddComponent(source.GetType());
                 * EditorUtility.CopySerialized(source, copy);
                 *
                 * if (copy.conditionsList != null)
                 * {
                 *  IConditionsList conditionsListSource = copy.conditionsList;
                 *  IConditionsList conditionsListCopy = this.instance.gameObject.AddComponent<IConditionsList>();
                 *
                 *  EditorUtility.CopySerialized(conditionsListSource, conditionsListCopy);
                 *  EventEditor.DuplicateIConditionList(conditionsListSource, conditionsListCopy);
                 *
                 *  SerializedObject soCopy = new SerializedObject(copy);
                 *  soCopy.FindProperty(InteractionEditor.PROP_CONDITIONSLIST).objectReferenceValue = conditionsListCopy;
                 *  soCopy.ApplyModifiedProperties();
                 *  soCopy.Update();
                 * }
                 *
                 * this.spInteractions.InsertArrayElementAtIndex(dstIndex);
                 * this.spInteractions.GetArrayElementAtIndex(dstIndex).objectReferenceValue = copy;
                 *
                 * this.spInteractions.serializedObject.ApplyModifiedProperties();
                 * this.spInteractions.serializedObject.Update();
                 *
                 * this.AddSubEditorElement(copy, dstIndex, true);
                 */
            }
            EditorGUI.EndDisabledGroup();

            GUIContent gcElse   = InteractionUtilities.Get(InteractionUtilities.Icon.Else);
            Rect       rectElse = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.boldLabel);

            EditorGUI.LabelField(rectElse, gcElse, EditorStyles.boldLabel);

            ActionsEditor.Return returnActions = ActionsEditor.PaintActionsGUI(
                this.instance.gameObject,
                this.spDefaultActions,
                this.actionsEditor
                );

            if (returnActions != null)
            {
                this.spDefaultActions = returnActions.spParentActions;
                this.actionsEditor    = returnActions.parentActionsEditor;

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

            EditorGUILayout.Space();
        }
Example #4
0
        private void PaintConditions()
        {
            if (this.spClauses != null && this.spClauses.arraySize > 0)
            {
                this.PaintClauses();
            }
            else
            {
                EditorGUILayout.HelpBox(MSG_EMTPY_CONDITIONS, MessageType.None);
            }

            float widthAddClause = 100f;
            Rect  rectControls   = GUILayoutUtility.GetRect(GUIContent.none, CoreGUIStyles.GetToggleButtonNormalOn());
            Rect  rectAddClause  = new Rect(
                rectControls.x + (rectControls.width / 2.0f) - (widthAddClause + 25f) / 2.0f,
                rectControls.y,
                widthAddClause,
                rectControls.height
                );

            Rect rectPaste = new Rect(
                rectAddClause.x + rectAddClause.width,
                rectControls.y,
                25f,
                rectControls.height
                );

            if (GUI.Button(rectAddClause, "Add Clause", CoreGUIStyles.GetButtonLeft()))
            {
                Clause clauseCreated = this.instance.gameObject.AddComponent <Clause>();

                int clauseCreatedIndex = this.spClauses.arraySize;
                this.spClauses.InsertArrayElementAtIndex(clauseCreatedIndex);
                this.spClauses.GetArrayElementAtIndex(clauseCreatedIndex).objectReferenceValue = clauseCreated;

                this.AddSubEditorElement(clauseCreated, -1, true);

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

            GUIContent gcPaste = ClausesUtilities.Get(ClausesUtilities.Icon.Paste);

            EditorGUI.BeginDisabledGroup(CLIPBOARD_CLAUSE == null);
            if (GUI.Button(rectPaste, gcPaste, CoreGUIStyles.GetButtonRight()))
            {
                Clause copy = this.instance.gameObject.AddComponent <Clause>();
                EditorUtility.CopySerialized(CLIPBOARD_CLAUSE, copy);

                if (copy.conditionsList != null)
                {
                    IConditionsList conditionsListSource = copy.conditionsList;
                    IConditionsList conditionsListCopy   = this.instance.gameObject.AddComponent <IConditionsList>();

                    EditorUtility.CopySerialized(conditionsListSource, conditionsListCopy);
                    ConditionsEditor.DuplicateIConditionList(conditionsListSource, conditionsListCopy);

                    SerializedObject soCopy = new SerializedObject(copy);
                    soCopy.FindProperty(ClauseEditor.PROP_CONDITIONSLIST).objectReferenceValue = conditionsListCopy;
                    soCopy.ApplyModifiedPropertiesWithoutUndo();
                    soCopy.Update();
                }

                int clauseIndex = this.spClauses.arraySize;
                this.spClauses.InsertArrayElementAtIndex(clauseIndex);
                this.spClauses.GetArrayElementAtIndex(clauseIndex).objectReferenceValue = copy;

                this.AddSubEditorElement(copy, -1, true);

                serializedObject.ApplyModifiedPropertiesWithoutUndo();
                serializedObject.Update();

                if (!Application.isPlaying)
                {
                    EditorSceneManager.MarkSceneDirty(this.instance.gameObject.scene);
                }
                DestroyImmediate(CLIPBOARD_CLAUSE.gameObject, true);
                CLIPBOARD_CLAUSE = null;
            }
            EditorGUI.EndDisabledGroup();

            GUIContent gcElse   = ClausesUtilities.Get(ClausesUtilities.Icon.Else);
            Rect       rectElse = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.boldLabel);

            EditorGUI.LabelField(rectElse, gcElse, EditorStyles.boldLabel);

            ActionsEditor.Return returnActions = ActionsEditor.PaintActionsGUI(
                this.instance.gameObject,
                this.spDefaultActions,
                this.actionsEditor
                );

            if (returnActions != null)
            {
                this.spDefaultActions = returnActions.spParentActions;
                this.actionsEditor    = returnActions.parentActionsEditor;

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

            EditorGUILayout.Space();
        }