Exemple #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);
            }
        }
    }
Exemple #2
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.");
            }
        }
    }
 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;
         }
     }
 }
Exemple #6
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.");
        }
    }
Exemple #7
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 void DrawWarnings()
 {
     PrairieGUI.warningLabel("One or more of the slides in your slideshow is empty.  Please fill the empty slides or remove them.");
 }