Exemple #1
0
    private static void TryBuildScene(string sceneFile)
    {
        string sceneName = Path.GetFileNameWithoutExtension(sceneFile);

        EditorUtility.DisplayProgressBar(pbwTitle, pbwMessage + "opening scene...", pbwProgress);
        EditorSceneManager.OpenScene(sceneFile, OpenSceneMode.Single);
        UFLevel level = Object.FindObjectOfType <UFLevel>();

        if (level == null)
        {
            Debug.LogWarning("Could not rebuild scene " + sceneName +
                             " since it did not contain any valid UF level structure.");
            return;
        }

        EditorUtility.DisplayProgressBar(pbwTitle, pbwMessage + "opening map builder...", pbwProgress);
        LevelBuilder builder = EditorWindow.GetWindow <LevelBuilder>();

        if (builder == null || !builder.TryLoadRefRFL())
        {
            Debug.LogWarning("Could not rebuild scene " + sceneName +
                             " since builder could not load it.");
            return;
        }

        if (!ShortRebuild(builder))
        {
            EditorUtility.DisplayProgressBar(pbwTitle, pbwMessage + "building UF level...", pbwProgress);
            builder.RefreshLevel();
            builder.BuildAll();

            EditorUtility.DisplayProgressBar(pbwTitle, pbwMessage + "baking lightmaps...", pbwProgress);
            BakeLightMaps();
        }

        EditorUtility.DisplayProgressBar(pbwTitle, pbwMessage + "saving scene...", pbwProgress);
        Scene scene = SceneManager.GetActiveScene();

        EditorSceneManager.SaveScene(scene);
    }