AddSceneToBuild() public static méthode

Adds a project-relative TextScene to the TextScene buildsettings and the corresponding binary temp file is written to the standard Unity build settings.
public static AddSceneToBuild ( string scene ) : bool
scene string
Résultat bool
Exemple #1
0
    /// <summary>
    /// Adds the selected TextScene file to buildsettings. Also updates the standard Unity
    /// buildsettings.
    /// </summary>
    public static void AddSelectedSceneToBuild()
    {
        if (Selection.activeObject == null)
        {
            EditorUtility.DisplayDialog("Nothing selected", "You need to select a text scene asset to add to build", "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 be TextAssets (*.txt)", "OK");
        }
        else
        {
            TextScene.AddSceneToBuild(assetPath);
        }
    }
Exemple #2
0
    /// <summary>
    /// Adds the currently open scene to the TextScene buildsettings, and updates
    /// the standard Unity buildsettings with the corresponding temp binary scene file.
    /// User will be notified if the current scene is not saved or is not a temp binary
    /// file.
    /// </summary>
    public static void AddCurrentSceneToBuild()
    {
        string currentScene = EditorApplication.currentScene;

        if (currentScene.Length == 0)
        {
            EditorUtility.DisplayDialog("Unsaved", "The currently open scene is not saved. Please save it using the TextScene menu option and try again.", "OK");
            return;
        }

        if (currentScene.StartsWith("Assets/"))
        {
            EditorUtility.DisplayDialog("Invalid scene", "The currently open scene is not a TextScene. Please re-save using the TextScene menu options and try again", "OK");
            return;
        }

        //Debug.Log("Text scene file to save in build settings: " + textSceneFile);

        TextScene.AddSceneToBuild(TextScene.TempToTextSceneFile(EditorApplication.currentScene));
    }