예제 #1
0
    void CreateDestNode()
    {
        // Set up required variables
        _quickTeleport = (MonoBehaviour)target as QuickTeleport;

        // Create the destination node
        GameObject teleDest = new GameObject("teleport destination");

        // Select the prefab and update the components
        Selection.activeObject = teleDest;
        teleDest.AddComponent <QuickGizmo> ();
        SetGizmo(teleDest.GetComponent <QuickGizmo> ());


        // Move the prefab to the Editor's camera position
        var sceneView = SceneView.lastActiveSceneView;

        if (sceneView != null)
        {
            teleDest.transform.position = sceneView.camera.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 10f));
        }

        // Child the prefab to its relevant Spawner and add it to the list of Spawn Points
        teleDest.transform.parent = _quickTeleport.transform;
        _quickTeleport.destinationNodes.Add(teleDest);
    }
예제 #2
0
    public override void OnInspectorGUI()
    {
        showHelp = (bool)EditorGUILayout.Toggle("Show Help", showHelp);
        if (showHelp)
        {
            EditorGUILayout.BeginFadeGroup(1);
            EditorGUILayout.HelpBox(helpText, MessageType.None);
            if (GUILayout.Button("User Guide"))
            {
                OpenUserGuide();
            }
            EditorGUILayout.EndFadeGroup();
        }


        if (_quickTeleport.interactableTags.Count == 0)
        {
            EditorGUILayout.BeginFadeGroup(1);
            EditorGUILayout.HelpBox("There are no interactable tags. Nothing will be able to use this trigger. \n Tick 'Edit Tags' to make changes.", MessageType.Error);
        }

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Interactable Tags:", EditorStyles.boldLabel);
        // Update Tags
        EditorGUILayout.LabelField(tags, EditorStyles.helpBox);
        tags = "";
        foreach (string t in _quickTeleport.interactableTags)
        {
            tags += t + "\n";
        }
        showTags = (bool)EditorGUILayout.Toggle("Edit Tags", showTags);
        if (showTags)
        {
            EditorGUILayout.BeginFadeGroup(1);
            selectedTag = EditorGUILayout.TagField("Interactable Tag", selectedTag);
            if (GUILayout.Button("Add Tag"))
            {
                _quickTeleport.AddTag(selectedTag);
            }
            if (GUILayout.Button("Remove Tag"))
            {
                _quickTeleport.RemoveTag(selectedTag);
            }
            if (GUILayout.Button("Remove Last"))
            {
                _quickTeleport.RemoveLast();
            }
            EditorGUILayout.EndFadeGroup();
        }
        GUILayout.Space(10);
        //Draw Rest of Script
        DrawPropertiesExcluding(serializedObject, _dontIncludeMe);
        GUILayout.Space(10);

        if (GUILayout.Button("Create Destination Node"))
        {
            CreateDestNode();
        }
        if (GUILayout.Button("Refresh Destination Nodes"))
        {
            _quickTeleport = (MonoBehaviour)target as QuickTeleport;
            _quickTeleport.RefreshDestNodes();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(_quickTeleport);
            serializedObject.ApplyModifiedProperties();
        }
    }
예제 #3
0
 void OnEnable()
 {
     _quickTeleport = (MonoBehaviour)target as QuickTeleport;
 }