Ejemplo n.º 1
0
    public void draw()
    {
        GameEvent ge = (GameEvent)node.Content;

        string[] editors        = EventEditorFactory.Intance.CurrentEventEditors;
        int      editorSelected = 0;

        for (int i = 1; i < editors.Length; i++)
        {
            if (editors [i].ToLower() == ge.Name.ToLower())
            {
                editorSelected = i;
            }
        }

        int was = editorSelected;

        editorSelected = EditorGUILayout.Popup(editorSelected, EventEditorFactory.Intance.CurrentEventEditors);
        if (currentEditor == null || was != editorSelected)
        {
            if (currentEditor != null)
            {
                currentEditor.detachEvent(ge);
            }

            ge.Name       = "";
            currentEditor = EventEditorFactory.Intance.createEventEditorFor(editors[editorSelected]);
            currentEditor.useEvent(ge);
        }

        currentEditor.draw();

        /**
         *  Game event synchronization
         * */

        if (!(ge.getParameter("synchronous") is bool))
        {
            ge.setParameter("synchronous", false);
        }
        ge.setParameter("synchronous", EditorGUILayout.Toggle("Synchronous",
                                                              (ge.getParameter("synchronous") == null)?false:(bool)ge.getParameter("synchronous")));

        if ((bool)ge.getParameter("synchronous"))
        {
            EditorGUILayout.HelpBox("Notice that if there is no EventFinished event, the game will stuck.", MessageType.Warning);
        }

        /**
         * Synchronization end
         * */

        node.Content = currentEditor.Result;

        if (Event.current.type != EventType.layout)
        {
            node.ChildSlots = 1;
        }
    }
Ejemplo n.º 2
0
        protected override void NodeContentInspectorGUI()
        {
            SerializableGameEvent ge = (SerializableGameEvent)target;

            string[] editors        = EventEditorFactory.Intance.CurrentEventEditors;
            int      editorSelected = 0;

            for (int i = 1; i < editors.Length; i++)
            {
                if (ge != null && editors[i].ToLower() == ge.Name.ToLower())
                {
                    editorSelected = i;
                }
            }

            int was = editorSelected;

            editorSelected = EditorGUILayout.Popup(editorSelected, EventEditorFactory.Intance.CurrentEventEditors);
            if (currentEditor == null || was != editorSelected)
            {
                if (currentEditor != null && ge != null)
                {
                    currentEditor.detachEvent(ge);
                }

                if (ge != null)
                {
                    ge.Name = "";
                }

                currentEditor = EventEditorFactory.Intance.createEventEditorFor(editors[editorSelected]);
                currentEditor.useEvent(ge);
            }

            currentEditor.draw();

            /**
             *  Game event synchronization
             * */

            if (!(ge.getParameter("synchronous") is bool))
            {
                ge.setParameter("synchronous", false);
            }
            ge.setParameter("synchronous", EditorGUILayout.Toggle("Synchronous",
                                                                  (ge.getParameter("synchronous") == null) ? false : (bool)ge.getParameter("synchronous")));

            if ((bool)ge.getParameter("synchronous"))
            {
                EditorGUILayout.HelpBox("Notice that if there is no EventFinished event, the game will stuck.", MessageType.Warning);
            }
        }
Ejemplo n.º 3
0
    public void draw()
    {
        GameEvent ge = (GameEvent)node.Content;

        string[] editors        = EventEditorFactory.Intance.CurrentEventEditors;
        int      editorSelected = 0;

        if (ge.Name == null)
        {
            ge.Name = "";
        }
        for (int i = 1; i < editors.Length; i++)
        {
            if (editors[i].ToLower() == ge.Name.ToLower())
            {
                editorSelected = i;
            }
        }
        int was = editorSelected;

        editorSelected = EditorGUILayout.Popup(editorSelected, EventEditorFactory.Intance.CurrentEventEditors);
        if (was != editorSelected && editorSelected == 0)
        {
            ge.Name = "";
        }
        EventEditor editor = EventEditorFactory.Intance.createEventEditorFor(editors[editorSelected]);

        editor.useEvent(ge);

        editor.draw();

        ge.setParameter("synchronous", EditorGUILayout.Toggle("Synchronous",
                                                              (ge.getParameter("synchronous") == null) ? false : (bool)ge.getParameter("synchronous")));
        if ((bool)ge.getParameter("synchronous"))
        {
            EditorGUILayout.HelpBox("Notice that if there is no EventFinished event, the game will stuck.", MessageType.Warning);
        }

        node.Content = editor.Result;

        if (Event.current.type != EventType.layout)
        {
            int l = node.Childs.Length;
            if (l != 1)
            {
                if (l == 0)
                {
                    node.addNewChild();
                }
                else
                {
                    while (l > 1)
                    {
                        node.removeChild(l - 1);
                        l--;
                    }
                }
                //this.Repaint ();
            }
        }
    }
Ejemplo n.º 4
0
    //int selectedTexture;
    public override void OnInspectorGUI()
    {
        EditorGUI.BeginChangeCheck();

        serializedObject.Update();

        SerializedProperty cell       = serializedObject.FindProperty("destination");
        SerializedProperty modep      = serializedObject.FindProperty("mode");
        SerializedProperty gep        = serializedObject.FindProperty("sge");
        SerializedProperty checkablep = serializedObject.FindProperty("checkable");

        EditorGUILayout.PropertyField(cell);

        modep.intValue = GUILayout.Toolbar(modep.intValue, new string[] { "Always", "Event trigger", "Checkable" });

        switch (modep.intValue)
        {
        case 1: {
            SerializableGameEvent ge = gep.objectReferenceValue as SerializableGameEvent;

            if (ge == null)
            {
                ge = ScriptableObject.CreateInstance <SerializableGameEvent> ();
            }

            string[] editors        = EventEditorFactory.Intance.CurrentEventEditors;
            int      editorSelected = 0;
            if (ge.Name == null)
            {
                ge.Name = "";
            }
            for (int i = 1; i < editors.Length; i++)
            {
                if (editors [i].ToLower() == ge.Name.ToLower())
                {
                    editorSelected = i;
                }
            }
            int was = editorSelected;

            editorSelected = EditorGUILayout.Popup(editorSelected, EventEditorFactory.Intance.CurrentEventEditors);
            if (was != editorSelected && editorSelected == 0)
            {
                ge.Name = "";
            }
            EventEditor editor = EventEditorFactory.Intance.createEventEditorFor(editors[editorSelected]);
            editor.useEvent(ge);

            editor.draw();
            ge = editor.Result;

            gep.objectReferenceValue = ge;
        }
        break;

        case 2: {
            Checkable c              = (Checkable)checkablep.objectReferenceValue;
            string[]  editors        = ForkEditorFactory.Intance.CurrentForkEditors;
            int       editorSelected = EditorGUILayout.Popup(
                ForkEditorFactory.Intance.ForkEditorIndex(c),
                ForkEditorFactory.Intance.CurrentForkEditors
                );

            ForkEditor editor = ForkEditorFactory.Intance.createForkEditorFor(editors[editorSelected]);

            editor.useFork(c);

            editor.draw();

            checkablep.objectReferenceValue = editor.Result;
        } break;
        }


        if (EditorGUI.EndChangeCheck())
        {
        }

        serializedObject.ApplyModifiedProperties();
    }