Beispiel #1
0
    public void NewOverworld(DoorToLocation door, Vector3 offset)
    {
        GameScene             gs  = door.GetTargetScene();
        DatabaseSceneEntrance dse = gs.GuidToEntrance(door.targetGuidString);

        NewOverworldAt
        (
            gs.name,
            dse.position + offset,
            dse.facingDirection,
            !door.stopOnTransition,
            false
        );
    }
Beispiel #2
0
    public void RefreshDoors()
    {
        GameObject[] doors = GameObject.FindGameObjectsWithTag("Door");
        GetCurrentScene().entranceList.Clear();
        database.GetScenesArray();

        foreach (GameObject door in doors)
        {
            DoorToLocation        d   = door.GetComponent <DoorToLocation>();
            DatabaseSceneEntrance dse = new DatabaseSceneEntrance();
            dse.name            = d.name;
            dse.facingDirection = d.exitDirection;
            dse.position        = Vector3Int.FloorToInt(d.transform.position);
            dse.guid            = d.GetComponent <GuidComponent>().GetGuid();
            dse.guidString      = dse.guid.ToString();
            GetCurrentScene().entranceList.Add(dse);
        }

        doorArray = GetCurrentScene().GetEntrancesArray();
    }
Beispiel #3
0
    public override void OnInspectorGUI()
    {
        //if (cutscene.showAllData)
        if (door.attributes == null)
        {
            base.OnInspectorGUI();
        }
        else
        {
            EditorStyles.textField.wordWrap = true;


            GUIStyle fontStyle = new GUIStyle(GUI.skin.button);
            fontStyle.alignment = TextAnchor.MiddleLeft;

            GUILayout.Label("Door: " + door.name, EditorStyles.boldLabel);
            GUILayout.Space(20);

            serializedObject.Update();

            door.doorSize = EditorGUILayout.Vector2Field("Size: ", door.doorSize);

            GUILayout.Space(10);

            EditorGUILayout.PropertyField(serializedObject.FindProperty("DoorTarget"), false);

            if (door.DoorTarget.ScenePath != "")
            {
                EnsureEntranceGuid();
            }

            GUILayout.Space(10);

            door.exitDirection = (MoveScripts.Direction)EditorGUILayout.EnumPopup("Exit Direction: ", door.exitDirection);

            GUILayout.Space(10);

            door.fadeOutOnTransition = EditorGUILayout.Toggle("Fade To Black: ", door.fadeOutOnTransition);
            door.stopOnTransition    = EditorGUILayout.Toggle("Stop On Transition: ", door.stopOnTransition);

            GUILayout.Space(20);

            GUILayout.BeginHorizontal();
            if (door.DoorTarget.ScenePath != "")
            {
                if (GUILayout.Button("Go To Door Destination"))
                {
                    if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
                    {
                        string currentScene = EditorSceneManager.GetActiveScene().path;

                        DatabaseSceneEntrance dse = door.GetTargetScene().GuidToEntrance(door.targetGuidString);

                        EditorSceneManager.OpenScene(door.GetTargetScenePath());

                        GameObject scene = GameObject.Find("SceneAttributes");
                        if (scene != null)
                        {
                            SceneAttributes newSceneAttributes = scene.GetComponent <SceneAttributes>();
                            if (newSceneAttributes != null)
                            {
                                SceneView.lastActiveSceneView.LookAt(dse.position);
                            }
                            else
                            {
                                Debug.LogError("[ERROR] Unable to find SceneAttributes Class!");
                                EditorSceneManager.OpenScene(currentScene);
                            }
                        }
                        else
                        {
                            Debug.LogError("[ERROR] Unable to find SceneAttributes Object!");
                            EditorSceneManager.OpenScene(currentScene);
                        }
                    }
                }
            }
            else
            {
                templateScene = (TemplateScene)EditorGUILayout.ObjectField(templateScene, typeof(TemplateScene), true);
                if (GUILayout.Button("Generate Scene"))
                {
                    if (templateScene != null)
                    {
                        string outputString = templateScene.generatePath + "/zz_Scene" + string.Format("{0:(yyyy-MM-dd)_(HH-mm-ss)}", System.DateTime.Now) + ".unity";
                        FileUtil.CopyFileOrDirectory(templateScene.scene.ScenePath, outputString);
                        AssetDatabase.Refresh();
                        door.DoorTarget.ScenePath = outputString;
                    }
                }
            }
            GUILayout.EndHorizontal();

            showPosition = EditorGUILayout.Foldout(showPosition, "Debug Variables");
            if (showPosition)
            {
                EditorGUILayout.LabelField("Target Info: ");
                EditorGUILayout.LabelField("    GUID String: " + door.targetGuidString);
                DatabaseSceneEntrance dse = door.GetTargetScene().GuidToEntrance(door.targetGuidString);
                if (dse != null)
                {
                    EditorGUILayout.LabelField("    Name: " + dse.name);
                    EditorGUILayout.LabelField("    Exit Direction: " + dse.facingDirection.ToString());
                }
                else
                {
                    EditorGUILayout.LabelField("    DSE NOT FOUND");
                }
            }

            if (door != null)
            {
                serializedObject.ApplyModifiedProperties();
                if (GUI.changed)
                {
                    door.attributes.RefreshDoors();
                    EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                    EditorUtility.SetDirty(door);
                    EditorUtility.SetDirty(door.attributes);
                    EditorUtility.SetDirty(door.attributes.database);

                    AssetDatabase.SaveAssets();
                }
            }
        }
    }