LoadSafe() публичный статический Метод

public static LoadSafe ( string path ) : string
path string
Результат string
    /// <summary>
    /// Loads the currently selected TextScene. Will fail and notify user if the selected file is
    /// not a text file.
    /// </summary>
    public static void LoadContext()
    {
        if (Selection.activeObject == null)
        {
            EditorUtility.DisplayDialog("Nothing selected", "You need to select a text scene asset to load one", "OK");
            return;
        }

        TextAsset asset = Selection.activeObject as TextAsset;

        string assetPath = "";

        if (asset != null)
        {
            assetPath = AssetDatabase.GetAssetPath(asset);
        }

        if (!assetPath.EndsWith(".txt"))
        {
            EditorUtility.DisplayDialog("Not a text file", "Text scenes can only be loaded from TextAssets (*.txt)", "OK");
        }
        else
        {
            string fullPath = Application.dataPath
                              + assetPath.Substring(assetPath.IndexOf('/'));

            TextSceneDeserializer.LoadSafe(fullPath);
        }
    }
Пример #2
0
    public override void OnInspectorGUI()
    {
        TextSceneObject tso = target as TextSceneObject;

        EditorGUILayout.BeginVertical();

        GUILayout.Label("External scene");

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Open scene: ");

        if (GUILayout.Button(tso.textScene.name))
        {
            if (EditorUtility.DisplayDialog("Open scenefile?", "Do you want to close the current scene and open the scene pointed to by this TextSceneObject?", "Yes", "No"))
            {
                TextSceneDeserializer.LoadSafe(EditorHelper.GetProjectFolder() + AssetDatabase.GetAssetPath(tso.textScene));
                GUIUtility.ExitGUI();
            }
        }

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();
    }
    /// <summary>
    /// Loads a TextScene into a clean scene. Will ask user for path.
    /// </summary>
    public static void Load()
    {
        string path = EditorUtility.OpenFilePanel("Load scene file", Application.dataPath, "txt");

        TextSceneDeserializer.LoadSafe(path);
    }
Пример #4
0
    void OnGUI()
    {
        GUILayout.BeginVertical();

        scroll = GUILayout.BeginScrollView(scroll);

        GUILayout.Label("Scenes to build");

        foreach (string scene in scenes)
        {
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button(scene))
            {
                TextSceneDeserializer.LoadSafe(EditorHelper.GetProjectFolder() + scene);
                GUIUtility.ExitGUI();
                return;
            }


            if (GUILayout.Button("Remove", GUILayout.MaxWidth(60)))
            {
                if (EditorUtility.DisplayDialog("Remove scene", "Are you sure you want to remove this scene from the build settings?", "Yes", "No"))
                {
                    TextScene.RemoveSceneFromBuild(scene);
                    LoadSettings();
                }
            }

            if (GUILayout.Button("+", GUILayout.MaxWidth(20)))
            {
                TextScene.MoveScenePosition(scene, 1);
                LoadSettings();
            }

            if (GUILayout.Button("-", GUILayout.MaxWidth(20)))
            {
                TextScene.MoveScenePosition(scene, -1);
                LoadSettings();
            }

            GUILayout.EndHorizontal();
        }

        if (scenes.Count > 0)
        {
            EditorGUILayout.Separator();
            EditorGUILayout.BeginVertical(GUILayout.MaxWidth(150));

            if (GUILayout.Button("Build Temp"))
            {
                TextScene.BuildTempScenes();
                GUIUtility.ExitGUI();
                return;
            }

            if (GUILayout.Button("Build Streamed Web"))
            {
                TextScene.Build(BuildTarget.WebPlayerStreamed);
                GUIUtility.ExitGUI();
                return;
            }

            if (GUILayout.Button("Build Web"))
            {
                TextScene.Build(BuildTarget.WebPlayer);
                GUIUtility.ExitGUI();
                return;
            }

            if (GUILayout.Button("Build OSX"))
            {
                TextScene.Build(BuildTarget.StandaloneOSXUniversal);
                GUIUtility.ExitGUI();
                return;
            }

            if (GUILayout.Button("Build Windows"))
            {
                TextScene.Build(BuildTarget.StandaloneWindows);
                GUIUtility.ExitGUI();
                return;
            }

            EditorGUILayout.EndVertical();
        }
        else
        {
            GUILayout.Label("Add scenes via the TextScene menu item to enable build");
        }

        EditorGUILayout.Separator();

        if (GUILayout.Button("Add current", GUILayout.MaxWidth(100)))
        {
            TextScene.AddCurrentSceneToBuild();
            LoadSettings();
        }

        EditorGUILayout.Separator();

        if (GUILayout.Button("Validate Settings", GUILayout.MaxWidth(100)))
        {
            List <string> invalidScenes;

            if (TextScene.ValidateBuildSettings(out invalidScenes))
            {
                EditorUtility.DisplayDialog("Valid settings", "The build settings seem valid enough", "OK");
            }
            else
            {
                StringBuilder sb = new StringBuilder();

                sb.Append("There were errors in validation: \n");

                foreach (string scene in invalidScenes)
                {
                    sb.Append("   ");
                    sb.Append(scene);
                    sb.Append('\n');
                }

                sb.Append("Try running 'Build Temp' to fix them up, or inspect the console for further hints.");

                EditorUtility.DisplayDialog("Validation failed", sb.ToString(), "OK");
            }
        }

        GUILayout.EndScrollView();

        GUILayout.EndVertical();
    }