Esempio n. 1
0
    public override void OnInspectorGUI()
    {
        TwineNode[] nodes = FindObjectsOfType(typeof(TwineNode)) as TwineNode[];

        if (nodes == null || nodes.Length == 0)
        {
            PrairieGUI.warningLabel("No Twine Node objects found. Have you imported your story and dragged it into the object hierarchy?");
        }
        else
        {
            List <int> selectedTwineNodeIndices = this.GetSelectedIndicesFromObjectList(associatedTwineNodes, nodes);

            if (selectedTwineNodeIndices.Count == 0)
            {
                // If the twine node has no associated indices set yet, try to auto-select
                //	a node with the same name as this object.
                int suggestedIndex = this.GetSuggestedTwineNodeIndex(nodes);
                selectedTwineNodeIndices = new List <int> ()
                {
                    suggestedIndex
                };
            }

            EditorGUI.BeginChangeCheck();
            selectedTwineNodeIndices = PrairieGUI.drawTwineNodeDropdownList("Associated Twine Nodes", "Twine Node Object",
                                                                            nodes, selectedTwineNodeIndices);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(associatedTwineNodes, "Change Associated Twine Nodes");
                associatedTwineNodes.associatedTwineNodeObjects = this.GetTwineObjectsFromIndices(nodes, selectedTwineNodeIndices);
            }
        }
    }
Esempio n. 2
0
    public void SimplePromptGUI(bool cyclicAllowed = true)
    {
        GUIContent label = new GUIContent("Prompt Text (Max 30 chararcters)", "Text displayed when a player can interact with this object.");

        EditorGUI.BeginChangeCheck();
        GUIStyle textAreaStyle = new GUIStyle(GUI.skin.textArea);

        GUILayout.Label(label);
        string _firstPrompt = GUILayout.TextArea(prompt.firstPrompt, 30, textAreaStyle, GUILayout.Height(18),
                                                 GUILayout.Width(EditorGUIUtility.currentViewWidth - 50), GUILayout.ExpandWidth(false));

        if (EditorGUI.EndChangeCheck())
        {
            // first prompt was edited
            Undo.RecordObject(prompt, "Change Prompt");
            prompt.firstPrompt = _firstPrompt;
        }

        if (string.IsNullOrEmpty(prompt.firstPrompt.Trim()))
        {
            PrairieGUI.hintLabel("No prompt will be displayed in game.");
            prompt.isCyclic = false;    // don't allow for a cycle if the first prompt is empty
            return;
        }
        if (!cyclicAllowed)
        {
            return;
        }                               // guard statement

        GUIContent cyclicLabel = new GUIContent("Cyclic Prompt", "Does this prompt have two cycling values? (i.e. open, close)");

        EditorGUI.BeginChangeCheck();
        bool _isCyclic = EditorGUILayout.Toggle(cyclicLabel, prompt.isCyclic);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(prompt, "Modify Prompt");
            prompt.isCyclic = _isCyclic;
        }

        if (prompt.isCyclic)
        {
            GUIContent secondLabel = new GUIContent("Second Prompt", "Second prompt to display, will toggle between this and first prompt.");
            GUILayout.Label(secondLabel);
            EditorGUI.BeginChangeCheck();
            string _secondPrompt = GUILayout.TextArea(prompt.secondPrompt, 30, textAreaStyle, GUILayout.Height(18),
                                                      GUILayout.Width(EditorGUIUtility.currentViewWidth - 50), GUILayout.ExpandWidth(false));
            if (EditorGUI.EndChangeCheck())
            {
                // second prompt was edited
                Undo.RecordObject(prompt, "Change Prompt");
                prompt.secondPrompt = _secondPrompt;
            }

            if (string.IsNullOrEmpty(prompt.secondPrompt.Trim()))
            {
                PrairieGUI.hintLabel("Second prompt will be ignored.");
            }
        }
    }
Esempio n. 3
0
    public void DrawWarnings()
    {
        ///run each of these as a separate loop, because we don't want the label to show up more than once for the first two,
        ///but we want both to show if they both are triggered (for instance if the first object is empty, and the second refers to itself
        /// The last loop is also separate so that it can be run for every object that might not have an interaction on it
        foreach (GameObject triggerTarget in trigger.triggeredObjects)
        {
            if (triggerTarget == null)
            {
                PrairieGUI.warningLabel("You have one or more empty slots in your list of toggles.  Please fill these slots or remove them.");
                break;
            }
        }

        foreach (GameObject triggerTarget in trigger.triggeredObjects)
        {
            if (triggerTarget == this.trigger.gameObject)
            {
                // warn users about INFINITE triggering
                PrairieGUI.warningLabel("A trigger interaction should not trigger itself!");
                break;
            }
        }

        foreach (GameObject triggerTarget in trigger.triggeredObjects)
        {
            if (triggerTarget != null && triggerTarget.GetComponent <Interaction>() == null)
            {
                // no interaction attached to this trigger target!
                string targetName = triggerTarget.name;
                PrairieGUI.warningLabel("'" + targetName + "' has no interactions attached to it. Triggering it will do nothing.");
            }
        }
    }
Esempio n. 4
0
    public override void OnInspectorGUI()
    {
        // Configuration:
        bool _isDecisionNode = EditorGUILayout.Toggle("Decision node?", node.isDecisionNode);

        GameObject[] _objectsToTrigger = PrairieGUI.drawObjectList("Objects To Trigger", node.objectsToTrigger);

        EditorGUILayout.LabelField("Name", node.name);
        EditorGUILayout.LabelField("Content");
        EditorGUI.indentLevel += 1;
        string _content = EditorGUILayout.TextArea(node.content);

        EditorGUI.indentLevel -= 1;

        // Read-Only Display:
        PrairieGUI.drawObjectListReadOnly("Children", node.children);
        PrairieGUI.drawObjectListReadOnly("Parents", node.parents.ToArray());

        // Save changes to the TwineNode if the user edits something in the GUI:
        if (GUI.changed)
        {
            Undo.RecordObject(node, "Modify Twine Node");
            node.isDecisionNode   = _isDecisionNode;
            node.objectsToTrigger = _objectsToTrigger;
            node.content          = _content;
        }
    }
 public void DrawWarnings()
 {
     if (audio.audioClip == null)
     {
         PrairieGUI.warningLabel("No audio clip attached to object.  Please add an audio clip to the slot above.");
     }
 }
    /// <summary>
    /// Draws the GUI of the import window
    /// </summary>
    void OnGUI()
    {
        GUILayout.Label("Import Twine Data", EditorStyles.boldLabel);

        GUILayout.BeginHorizontal();
        GUILayout.Label("Twine JSON text:");

        if (GUILayout.Button("Paste from clipboard"))
        {
            this.jsonString = GUIUtility.systemCopyBuffer;
        }

        GUILayout.EndHorizontal();

        this.jsonString = GUILayout.TextArea(this.jsonString, GUILayout.MinHeight(20), GUILayout.MaxHeight(200));

        GUILayout.BeginHorizontal();
        GUILayout.Label("Twine story prefab destination:");

        // button which selects a prefab destination
        if (GUILayout.Button(prefabDestinationDirectory))
        {
            string fullPath = EditorUtility.OpenFolderPanel("Select destination directory...", prefabDestinationDirectory, "");

            // obnoxiously, the OpenFilePanel returns a full file path,
            // and Unity will only play nice with a relative one so we must convert
            string projectDirectory = Directory.GetParent(Application.dataPath).ToString();

            prefabDestinationDirectory = GetRelativePath(fullPath, projectDirectory);

            // double check we'll have access to this file
            if (!(prefabDestinationDirectory.StartsWith("Assets/") || prefabDestinationDirectory.StartsWith("Assets\\")))
            {
                EditorUtility.DisplayDialog("Can't Load Asset", "The folder must be part of your Unity project's assets.", "OK");
            }
        }

        GUILayout.EndHorizontal();

        bool isValid = isValidJson();

        if (!isValid)
        {
            PrairieGUI.warningLabel("The JSON entered is invalid. Copy and paste JSON from Twison to import.");
        }


        // button to send to importer
        GUI.enabled = (this.jsonString != "" && isValid);
        if (GUILayout.Button("Import"))
        {
            SendToImporter(jsonString, prefabDestinationDirectory);
            this.Close();
        }
    }
 public void DrawWarnings()
 {
     foreach (GameObject obj in componentToggle.targets)
     {
         if (obj == null)
         {
             PrairieGUI.warningLabel("You have one or more empty slots in your list of toggles.  Please fill these slots or remove them.");
             break;
         }
     }
 }
Esempio n. 8
0
    public void SimplePromptGUI(bool cyclicAllowed = true)
    {
        GUIContent label = new GUIContent("Prompt Text", "Text displayed when a player can interact with this object.");

        EditorGUI.BeginChangeCheck();
        string _firstPrompt = EditorGUILayout.TextField(label, prompt.firstPrompt);

        if (EditorGUI.EndChangeCheck())
        {
            // first prompt was edited
            Undo.RecordObject(prompt, "Change Prompt");
            prompt.firstPrompt = _firstPrompt;
        }

        if (string.IsNullOrEmpty(prompt.firstPrompt.Trim()))
        {
            PrairieGUI.hintLabel("No prompt will be displayed in game.");
            prompt.isCyclic = false;    // don't allow for a cycle if the first prompt is empty
            return;
        }
        if (!cyclicAllowed)
        {
            return;
        }                               // guard statement

        GUIContent cyclicLabel = new GUIContent("Cyclic Prompt", "Does this prompt have two cycling values? (i.e. open, close)");

        EditorGUI.BeginChangeCheck();
        bool _isCyclic = EditorGUILayout.Toggle(cyclicLabel, prompt.isCyclic);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(prompt, "Modify Prompt");
            prompt.isCyclic = _isCyclic;
        }

        if (prompt.isCyclic)
        {
            GUIContent secondLabel = new GUIContent("Second Prompt", "Second prompt to display, will toggle between this and first prompt.");
            EditorGUI.BeginChangeCheck();
            string _secondPrompt = EditorGUILayout.TextField(secondLabel, prompt.secondPrompt);
            if (EditorGUI.EndChangeCheck())
            {
                // second prompt was edited
                Undo.RecordObject(prompt, "Change Prompt");
                prompt.secondPrompt = _secondPrompt;
            }

            if (string.IsNullOrEmpty(prompt.secondPrompt.Trim()))
            {
                PrairieGUI.hintLabel("Second prompt will be ignored.");
            }
        }
    }
Esempio n. 9
0
    public void DrawWarnings()
    {
        GameObject owner           = player.gameObject;
        var        playerCompTypeA = owner.GetComponent <FirstPersonController> ();
        var        playerCompTypeB = owner.GetComponent <RigidbodyFirstPersonController> ();

        if (playerCompTypeA == null && playerCompTypeB == null)
        {
            // Neither player types are attached to this gameObject!
            PrairieGUI.warningLabel("No Controller is attached to this game object.");
            PrairieGUI.warningLabel("Please add a `FirstPersonController` or `RigidbodyFirstPersonController` to this game object, to ensure your player can move around in the scene.");
            PrairieGUI.warningLabel("If these components are unavaliable, you may need to import the 'Characters' package, from Unity's Standard Assets.");
        }
    }
Esempio n. 10
0
    public override void OnInspectorGUI()
    {
        // Configuration:
        EditorGUILayout.LabelField("Name", node.name);
        EditorGUILayout.LabelField("Content");
        EditorGUI.indentLevel += 1;
        string _content = EditorGUILayout.TextArea(node.content);

        EditorGUI.indentLevel -= 1;

        bool _isDecisionNode = EditorGUILayout.Toggle("Decision node?", node.isDecisionNode);

        GameObject[] _objectsToTrigger = PrairieGUI.drawObjectList("Objects To Trigger", node.objectsToTrigger);
        GameObject[] _objectsToEnable  = PrairieGUI.drawObjectList <GameObject>("Objects To Enable:", node.objectsToEnable);
        GameObject[] _objectsToRotate  = PrairieGUI.drawObjectList <GameObject>("Objects To Rotate:", node.objectsToRotate);
        int          _rotX             = EditorGUILayout.IntField("X-axis rotation amount:", node.rotX);
        int          _rotY             = EditorGUILayout.IntField("Y-axis rotation amount:", node.rotY);
        int          _rotZ             = EditorGUILayout.IntField("Z-axis rotation amount:", node.rotZ);

        GameObject[] _objectsToTransform = PrairieGUI.drawObjectList <GameObject>("Objects To Transform:", node.objectsToTransform);
        int          _trX = EditorGUILayout.IntField("X-axis transform amount:", node.trX);
        int          _trY = EditorGUILayout.IntField("Y-axis transform amount:", node.trY);
        int          _trZ = EditorGUILayout.IntField("Z-axis transform amount:", node.trZ);

        // Read-Only Display:
        PrairieGUI.drawObjectListReadOnly("Children", node.children);
        PrairieGUI.drawObjectListReadOnly("Parents", node.parents.ToArray());

        // Save changes to the TwineNode if the user edits something in the GUI:
        if (GUI.changed)
        {
            Undo.RecordObject(node, "Modify Twine Node");
            node.isDecisionNode     = _isDecisionNode;
            node.objectsToTrigger   = _objectsToTrigger;
            node.content            = _content;
            node.objectsToEnable    = _objectsToEnable;
            node.objectsToRotate    = _objectsToRotate;
            node.objectsToTransform = _objectsToTransform;
            node.trX  = _trX;
            node.trY  = _trY;
            node.trZ  = _trZ;
            node.rotX = _rotX;
            node.rotY = _rotY;
            node.rotZ = _rotZ;
        }
    }
Esempio n. 11
0
    public override void OnInspectorGUI()
    {
        // Configuration:
        bool _repeatable = EditorGUILayout.Toggle("Repeatable?", componentToggle.repeatable);

        GameObject[] _targets = PrairieGUI.drawObjectList <GameObject> ("Objects To Enable/Disable:", componentToggle.targets);

        // Save:
        if (GUI.changed)
        {
            Undo.RecordObject(componentToggle, "Modify Component Rotation");
            componentToggle.repeatable = _repeatable;
            componentToggle.targets    = _targets;
        }

        // Warnings (after properties have been updated):
        this.DrawWarnings();
    }
Esempio n. 12
0
    public override void OnInspectorGUI()
    {
        // Principle Configuration:
        bool _repeatable = EditorGUILayout.Toggle("Repeatable?", trigger.repeatable);

        GameObject[] _triggeredObjects = PrairieGUI.drawObjectList <GameObject> ("Trigger Objects:", trigger.triggeredObjects);

        // Save Changes:
        if (GUI.changed)
        {
            Undo.RecordObject(trigger, "Modify Trigger");
            trigger.repeatable       = _repeatable;
            trigger.triggeredObjects = _triggeredObjects;
        }

        // Warnings (after properties have been updated):
        this.DrawWarnings();
    }
    public override void OnInspectorGUI()
    {
        slideshow        = (Slideshow)target;
        slideshow.Slides = PrairieGUI.drawObjectList("Slides", slideshow.Slides);

        for (int i = 0; i < slideshow.Slides.Length; i++)
        {
            if (slideshow.Slides [i] == null)
            {
                DrawWarnings();
                break;
            }
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(slideshow);
        }
    }
Esempio n. 14
0
    void DisplayAreaAnnotationWarnings()
    {
        if (annotation.annotationType == (int)AnnotationTypes.AREA)
        {
            // ensure there is a collider attached to this object
            GameObject owner     = this.annotation.gameObject;
            Collider[] colliders = owner.GetComponents <Collider> ();

            if (colliders == null || colliders.Length == 0)
            {
                // error: doesn't have collider
                PrairieGUI.warningLabel("Area Annotations require a Collider to function.");
                if (GUILayout.Button("Add Collider"))
                {
                    Collider collider = owner.AddComponent <BoxCollider> () as Collider;
                    collider.isTrigger = true;
                }
            }
            else
            {
                bool foundTriggerCollider = false;
                foreach (Collider collider in colliders)
                {
                    foundTriggerCollider = foundTriggerCollider || collider.isTrigger;
                }

                // error: doesn't have any trigger collider
                if (!foundTriggerCollider)
                {
                    PrairieGUI.warningLabel("Area Annotations require a Collider set to trigger mode to function.");
                    if (GUILayout.Button("Set to Trigger"))
                    {
                        colliders[0].isTrigger = true;
                    }
                }
            }
        }
    }
    public override void OnInspectorGUI()
    {
        // Configuration:
        bool _repeatable = EditorGUILayout.Toggle("Repeatable?", componentToggle.repeatable);

        GameObject[] _targets = PrairieGUI.drawObjectList <GameObject> ("Objects To Transform:", componentToggle.targets);
        int          _trX     = EditorGUILayout.IntField("X-axis transl amount:", componentToggle.trX);
        int          _trY     = EditorGUILayout.IntField("Y-axis transl amount:", componentToggle.trY);
        int          _trZ     = EditorGUILayout.IntField("Z-axis transl amount:", componentToggle.trZ);

        // Save:
        if (GUI.changed)
        {
            Undo.RecordObject(componentToggle, "Modify Component Translation");
            componentToggle.repeatable = _repeatable;
            componentToggle.targets    = _targets;
            componentToggle.trX        = _trX;
            componentToggle.trY        = _trY;
            componentToggle.trZ        = _trZ;
        }

        // Warnings (after properties have been updated):
        this.DrawWarnings();
    }
 public void DrawWarnings()
 {
     PrairieGUI.warningLabel("One or more of the slides in your slideshow is empty.  Please fill the empty slides or remove them.");
 }