コード例 #1
1
		private static string[] editorBuildSettingsScenesToNameStrings( EditorBuildSettingsScene[] scenes )
		{
			var sceneNames = new string[scenes.Length];
			for( var n = 0; n < sceneNames.Length; n++ )
				sceneNames[n] = Path.GetFileNameWithoutExtension( scenes[n].path );

			return sceneNames;
		}
コード例 #2
0
    void SetupLevels(string formatText = null)
    {
        // Create a new list
        int numScenes = UnityEditor.EditorBuildSettings.scenes.Length;

        levels = new LevelInfo[numScenes];

        // Go through each level
        UnityEditor.EditorBuildSettingsScene scene = null;
        string sceneName, displayName;

        for (int index = 0; index < numScenes; ++index)
        {
            // Grab the scene
            scene = UnityEditor.EditorBuildSettings.scenes[index];

            // Get the scene name
            sceneName = System.IO.Path.GetFileNameWithoutExtension(scene.path);

            // Get the display name
            displayName = GetDisplayName(index, sceneName, formatText);

            levels[index] = new LevelInfo(sceneName, displayName);
        }
    }
コード例 #3
0
    void Start()
    {
        if (gm == null)
            gm = gameObject.GetComponent<GameManager>();

        if (player == null) {
            player = GameObject.FindWithTag("Player");
        }

        playerHealth = player.GetComponent<Health>();

        // setup score display
        Collect (0);

        // make other UI inactive
        gameOverCanvas.SetActive (false);
        if (canBeatLevel)
            beatLevelCanvas.SetActive (false);

        string[] scenesToAdd = new string[]
        {
            "Assets/Scenes/SCENE1_Complete.unity",
            "Assets/Scenes/SCENE2.unity"
        };
        var original = EditorBuildSettings.scenes;
        var newSettings = new EditorBuildSettingsScene[original.Length + 1];
        System.Array.Copy(original, newSettings, original.Length);

        for (int i = 0; i < scenesToAdd.Length; i++)
        {
            var sceneToAdd = new EditorBuildSettingsScene(scenesToAdd[i], true);
            newSettings[newSettings.Length - 1] = sceneToAdd;
        }
        EditorBuildSettings.scenes = newSettings;
    }
コード例 #4
0
ファイル: MazesToBuild.cs プロジェクト: ChrisJong/Harmony
        static void RebuildUnlock() {
            DeleteSaveData();
            List<EditorBuildSettingsScene> mazeList = new List<EditorBuildSettingsScene>();

            string mainFolder = "Assets/Scenes/";
            string mainMazeFolder = mainFolder + "Mazes/";
            string sceneType = ".unity";
            EditorBuildSettingsScene mainMenuToAdd = new EditorBuildSettingsScene(mainFolder + "MainMenu/" + "MainMenu" + sceneType, true);
            mazeList.Add(mainMenuToAdd);
            MazeInfo.MazeMoveValue = new Dictionary<int, MazeData>();
            for(int i = 0; i < MazeInfo.MaxMazeLength; i++) {
                EditorBuildSettingsScene mazeToAdd = new EditorBuildSettingsScene(mainMazeFolder + MazeInfo.MazeName + (i + 1) + sceneType, true);
                mazeList.Add(mazeToAdd);

                EditorApplication.OpenScene(mazeToAdd.path);

                GridMap obj = GameObject.FindWithTag("GridMap").GetComponent<GridMap>() as GridMap;
                MazeInfo.MazeMoveValue.Add(i, new MazeData {
                    moveCount = 0,
                    maxMoves = obj.maxMoves
                });
            }
            MazeDataHelper.SaveData();
            EditorBuildSettings.scenes = mazeList.ToArray();
            Debug.Log("REBUILDING OF DATA AND MAZES FINISHED! CONTINUE ON WHATEVER YOU WERE DOING.");
        }
コード例 #5
0
ファイル: PunStartup.cs プロジェクト: Gamieon/PaperCowboys
    static void OnLevelWasLoaded()
    {
        if (!runOnce)
        {
            return;
        }

        runOnce = false;
        EditorApplication.update -= OnLevelWasLoaded;

        if (string.IsNullOrEmpty(EditorApplication.currentScene))
        {
            bool ret = EditorApplication.OpenScene("Assets/Photon Unity Networking/" + demoPaths[0]);
            if (ret)
            {
                Debug.Log("No scene was open. Loaded PUN Demo Hub. " + EditorApplication.currentScene);
                Selection.activeObject = AssetDatabase.LoadMainAssetAtPath("Assets/Photon Unity Networking/" + demoPaths[0]);
            }
        }

        if (EditorBuildSettings.scenes.Length == 0)
        {
            EditorBuildSettingsScene[] scenes = new EditorBuildSettingsScene[demoPaths.Length];
            for (int i = 0; i < demoPaths.Length; i++)
            {
                scenes[i] = new EditorBuildSettingsScene("Assets/Photon Unity Networking/" + demoPaths[i], true);
            }
            EditorBuildSettings.scenes = scenes;

            Debug.Log("Applied new scenes to build settings.");
        }
    }
コード例 #6
0
		/// <summary>
		/// 	Gets the enabled scenes.
		/// </summary>
		/// <returns>The enabled scenes.</returns>
		public static EditorBuildSettingsScene[] GetEnabledScenes()
		{
			EditorBuildSettingsScene[] allScenes = EditorBuildSettings.scenes;

			int enabledCount = 0;

			for (int index = 0; index < allScenes.Length; index++)
			{
				if (allScenes[index].enabled)
					enabledCount++;
			}

			EditorBuildSettingsScene[] output = new EditorBuildSettingsScene[enabledCount];

			int enabledIndex = 0;

			for (int index = 0; index < allScenes.Length; index++)
			{
				if (!allScenes[index].enabled)
					continue;

				output[enabledIndex] = allScenes[index];
				enabledIndex++;
			}

			return output;
		}
コード例 #7
0
        public static void LauncherProjectSharedProjectPrep()
        {
            GameObject MonsterLauncherInst = new GameObject("MonsterTestLauncher");

            MonsterLauncherInst.AddComponent<MonsterLauncher>();

            string LauncherScenePath = Path.Combine("Assets", "Launcher.unity");

            EditorApplication.SaveScene(LauncherScenePath);

            EditorBuildSettingsScene[] NewList = new EditorBuildSettingsScene[1];

            NewList[0] = new EditorBuildSettingsScene(LauncherScenePath, true);

            EditorBuildSettings.scenes = NewList;

            foreach(BuildTargetGroup group in IgorSetScriptingDefines.BuildTargets)
            {
                if(group != BuildTargetGroup.Unknown)
                {
                    PlayerSettings.SetScriptingDefineSymbolsForGroup(group, "IGOR_RUNTIME;MONSTER_TEST_RUNTIME");
                }
            }

            AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
        }
コード例 #8
0
    private void AutoAddEmptyScene()
    {
        if (!Application.isPlaying)
        {
            string emptyScene = SSFile.GetPathTemplateFile("SSEmpty.unity");
            emptyScene = emptyScene.Replace(System.IO.Path.DirectorySeparatorChar, '/');

            var scenes = EditorBuildSettings.scenes;

            foreach (var scene in scenes)
            {
                // Check if exist, return
                if (scene.path.CompareTo(emptyScene) == 0)
                {
                    return;
                }
            }

            // If not exist
            var newScenes = new EditorBuildSettingsScene[scenes.Length + 1];

            for (int i = 0; i < scenes.Length; i++)
            {
                newScenes[i] = scenes[i];
            }

            EditorBuildSettingsScene emptySettingScene = new EditorBuildSettingsScene(emptyScene, true);
            newScenes[newScenes.Length - 1] = emptySettingScene;

            // Save
            EditorBuildSettings.scenes = newScenes;
            EditorApplication.SaveAssets();
        }
    }
コード例 #9
0
 private static string[] EditorBuildSettingsScenesToNameStrings(EditorBuildSettingsScene[] scenes)
 {
     string[] sceneNames = new string[scenes.Length];
     for (int n = 0; n < sceneNames.Length; n++)
     {
         sceneNames[n] = System.IO.Path.GetFileNameWithoutExtension(scenes[n].path);
     }
     return sceneNames;
 }
コード例 #10
0
		/// <summary>
		/// 	Returns an array of scene names.
		/// </summary>
		/// <returns>The scene names.</returns>
		public static string[] GetSceneNames(EditorBuildSettingsScene[] scenes)
		{
			string[] output = new string[scenes.Length];

			for (int index = 0; index < scenes.Length; index++)
				output[index] = GetSceneName(scenes[index]);

			return output;
		}
コード例 #11
0
 static bool CheckSceneListContainsScene(EditorBuildSettingsScene[] scenes, string scenePath)
 {
     if (string.IsNullOrEmpty(scenePath))
         return false;
     for (int i = 0; i < scenes.Length; i++)
     {
         if (scenes[i].path.Equals(scenePath))
             return true;
     }
     return false;
 }
コード例 #12
0
 private static bool SceneRegistered(EditorBuildSettingsScene[] scenes, string scenePath)
 {
     foreach (EditorBuildSettingsScene scene in scenes)
     {
         if (scene.path == scenePath)
         {
             return true;
         }
     }
     return false;
 }
コード例 #13
0
ファイル: LoadScenes.cs プロジェクト: dafei2015/CommonTools
 static void CheckSceneSetting()
 {
     List<string> dirs = new List<string>();
     GetDirs(Application.dataPath, ref dirs);
     EditorBuildSettingsScene[] newSettings = new EditorBuildSettingsScene[dirs.Count];
     for(int i= 0;i<newSettings.Length;i++)
     {
         newSettings[i] = new EditorBuildSettingsScene(dirs[i], true);
     }
     EditorBuildSettings.scenes = newSettings;
     EditorApplication.SaveAssets();
 }
コード例 #14
0
    private static void TerrainExport()
    {
        Terrain[] objects = (Terrain[])Resources.FindObjectsOfTypeAll(typeof(Terrain));
        List<string> terrainNames = new List<string>();
        Dictionary<string, Vector3> positions = new Dictionary<string, Vector3>();

        foreach (Terrain obj in objects)
        {
            terrainNames.Add(obj.name);
        }

        string baseScenePath = EditorSceneManager.GetActiveScene().path;
        string baseSceneDirectory = Path.GetDirectoryName(baseScenePath);
        EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());

        foreach (string name in terrainNames)
        {
            string subscenePrefabPath = baseSceneDirectory + "/" + name + ".prefab";
            Debug.Log(name + " - making prefab");
            GameObject terrain = GameObject.Find(name);
            positions[name] = terrain.transform.position;
            Selection.activeGameObject = terrain;
            UnityEngine.Object prefab = PrefabUtility.CreateEmptyPrefab(subscenePrefabPath);
            PrefabUtility.ReplacePrefab(terrain, prefab);
        }
        AssetDatabase.Refresh();

        foreach (string name in terrainNames)
        {
            Debug.Log(name + " - making subscene");
            string subscenePath = baseSceneDirectory + "/" + name + ".unity";
            string subscenePrefabPath = baseSceneDirectory + "/" + name + ".prefab";
            EditorSceneManager.NewScene(new NewSceneSetup());
            UnityEngine.Object prefabResource = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(subscenePrefabPath);
            UnityEngine.Object prefab = PrefabUtility.InstantiatePrefab(prefabResource);
            ((GameObject)prefab).transform.position = positions[name];
            EditorApplication.ExecuteMenuItem("GameObject/Camera");
            Camera camera = (Camera)UnityEngine.Object.FindObjectOfType(typeof(Camera));
            camera.name = "SERVICE";
            EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene(), subscenePath);

            EditorBuildSettingsScene[] original = EditorBuildSettings.scenes;
            if (! SceneRegistered(original, subscenePath))
            {
                EditorBuildSettingsScene[] scenes = new EditorBuildSettingsScene[original.Length + 1];
                Array.Copy(original, scenes, original.Length);
                scenes[scenes.Length - 1] = new EditorBuildSettingsScene(subscenePath, true);
                EditorBuildSettings.scenes = scenes;
            }
        }
        EditorSceneManager.OpenScene(baseScenePath);
    }
コード例 #15
0
		private static void OnResourceSaved(Resource resource)
		{
			if(resource is Configuration)
			{
				Configuration config = (resource as Configuration);

// TODO: filter out bad data
//				if(config == null)
//				{
//					FatalError("There is no configuration set up.");
//				}
//				else if(config.setting == null)
//				{
//					FatalError("There is no setting defined in the configuration.");
//				}
//				else if(config.setting.bootState == null)
//				{
//					FatalError("The configuratons setting needs a boot state defined.");
//				}
//				else if(config.setting.states == null || config.setting.states.Count == 0)
//				{
//					FatalError("You must define states you need in the configuratons setting.");
//				}
//				else if(!config.setting.states.Contains(config.setting.bootState))
//				{
//					FatalError("Defined setting must have boot state added into states.");
//				}
//				else if(config.setting.loader == null)
//				{
//					FatalError("You must define a loader scene.");
//				}
//				if(config.setting == null)
//				{
//					Debug.LogError("You must have setting defined in the configuration.");
//					return;
//				}
//				Debug.LogError("You must have a loader scene defined for setting: " + config.setting.name);

				int totalScenes = config.setting.states.Count + 2;
				EditorBuildSettingsScene[] newScenes = new EditorBuildSettingsScene[totalScenes];
				newScenes[0] = new EditorBuildSettingsScene("Assets/Scenes/Main.unity", true);
				newScenes[1] = new EditorBuildSettingsScene(AssetDatabase.GetAssetPath(config.setting.loader), true);

				for(int i = 0; i<config.setting.states.Count; i++)
				{
					SceneAsset scene = config.setting.states[i].scene;
					newScenes[i+2] = new EditorBuildSettingsScene(AssetDatabase.GetAssetPath(scene), true);
				}

				EditorBuildSettings.scenes = newScenes;
			}
		}
コード例 #16
0
    private static void AddSceneToBuild(string scenePath)
    {
        //Debug.Log("AddSceneToBuild "+scenePath);

        var original = EditorBuildSettings.scenes;
        var newSettings = new EditorBuildSettingsScene[original.Length + 1];

        System.Array.Copy(original, newSettings, original.Length);

        var sceneToAdd = new EditorBuildSettingsScene(scenePath, true);

        newSettings[newSettings.Length - 1] = sceneToAdd;

        EditorBuildSettings.scenes = newSettings;
    }
コード例 #17
0
ファイル: FixBuildSettings.cs プロジェクト: pisipo/PUNProja
    static void FixBSet()
    {
        //
        //  SET SCENES
        //

        if (!EditorUtility.DisplayDialog("Resetting build settings", "Can the current build settings be overwritten with the scenes for the PUN guide?", "OK", "No, cancel"))
            return;

        EditorBuildSettingsScene[] sceneAr = new EditorBuildSettingsScene[18];
        int i = 0;
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/_MenuScene.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/_Tutorial 1/Tutorial_1A.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/_Tutorial 1/Tutorial_1B.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/_Tutorial 1/Tutorial_1C.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/_Tutorial 2/Tutorial_2A1.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/_Tutorial 2/Tutorial_2A2.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/_Tutorial 2/Tutorial_2A3.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/_Tutorial 2/Tutorial_2B.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/_Tutorial 3/Tutorial_3.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/_Tutorial 4/Tutorial_4.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/Example1/Example1_Chat.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/Example2/Example2_menu.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/Example2/Example2_game.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/Example3/Example3_lobbymenu.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/Example3/Example3_game.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/Example4/Example4_Menu.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/Example4/Example4_Game.unity", true);
        sceneAr[i++] = new EditorBuildSettingsScene("Assets/PUNGuide_M2H/Example5/Example5_Game.unity", true);

        EditorBuildSettings.scenes = sceneAr;
        Debug.Log("PUN Guide: reset project build settings.");

        /*

        //Output current build settings
        string bl = "";
        int i = 0;
        foreach (EditorBuildSettingsScene sc in EditorBuildSettings.scenes)
        {
            bl += "sceneAr[i++] = new EditorBuildSettingsScene(\"" + sc.path + "\", true);\n";

            i++;
        }
        Debug.Log(bl);

        */
    }
コード例 #18
0
    //
    private void AddMissingScenes()
    {
        var existingScenes = EditorBuildSettings.scenes;
        var l = existingScenes.Length;

        // Create new extended list of scenes and copy existing ones to it
        var newScenes = new EditorBuildSettingsScene[l + missingScenePaths.Count];
        existingScenes.CopyTo(newScenes, 0);

        // Add missing scenes
        for (var i = 0; i < missingScenePaths.Count; i++)
            newScenes[l + i] = new EditorBuildSettingsScene(missingScenePaths[i], true);

        // Assign new scene list
        EditorBuildSettings.scenes = newScenes;
    }
コード例 #19
0
    public static void SynchronizeBuild(MadLevelConfiguration config) {
        List<EditorBuildSettingsScene> scenes = new List<EditorBuildSettingsScene>();
        foreach (var configuredScene in config.ScenesInOrder()) {
            if (!configuredScene.IsValid()) {
                continue;
            }

            string path = configuredScene.scenePath;
            if (scenes.Find((obj) => obj.path == path) == null) {
                var scene = new EditorBuildSettingsScene(path, true);
                scenes.Add(scene);
            }
        }

        EditorBuildSettings.scenes = scenes.ToArray();
    }
コード例 #20
0
ファイル: FixBuildSettings.cs プロジェクト: JollyDuck/Shootem
    static void FixBSet()
    {
        //
        //  SET SCENES
        //

        if (!EditorUtility.DisplayDialog("Resetting build settings", "Can the current build settings be overwritten with the scenes for the PUN guide?", "OK", "No, cancel"))
            return;

        // find path of pun guide
        string[] tempPaths = Directory.GetDirectories(Application.dataPath, "PUNGuide_M2H", SearchOption.AllDirectories);
        if (tempPaths == null || tempPaths.Length != 1)
        {
            return;
        }

        // find scenes of guide
        string guidePath = tempPaths[0];
        tempPaths = Directory.GetFiles(guidePath, "*.unity", SearchOption.AllDirectories);

        if (tempPaths == null || tempPaths.Length == 0)
        {
            return;
        }

        // add found guide scenes to build settings
        int mainSceneIndex = 0;
        EditorBuildSettingsScene[] sceneAr = new EditorBuildSettingsScene[tempPaths.Length];
        for (int i = 0; i < tempPaths.Length; i++)
        {
            //Debug.Log(tempPaths[i]);
            string path = tempPaths[i].Substring(Application.dataPath.Length - "Assets".Length);
            path = path.Replace('\\', '/');
            if (mainSceneIndex == 0 && path.Contains("_Main"))
            {
                mainSceneIndex = i;
            }
            //Debug.Log(path);
            sceneAr[i] = new EditorBuildSettingsScene(path, true);
        }
        
        EditorBuildSettings.scenes = sceneAr;
        EditorApplication.OpenScene(sceneAr[mainSceneIndex].path);

        Debug.Log("PUN Guide: reset project build settings.");
    }
コード例 #21
0
ファイル: EditorUtils.cs プロジェクト: Randhall/RunAndJump
        public static void Commit(LevelsPackage package, System.Action successCb = null, System.Action errorCb = null)
        {
            try {
                List<EditorBuildSettingsScene> buildScenes = new List<EditorBuildSettingsScene> (EditorBuildSettings.scenes);
                List<EditorBuildSettingsScene> levelScenes = new List<EditorBuildSettingsScene> ();
                List<EditorBuildSettingsScene> buildScenesToRemove = new List<EditorBuildSettingsScene> ();
                List<LevelMetadata> levelListmetadatasToRemove = new List<LevelMetadata> ();

                // Check level scenes in original Build Scenes
                foreach (EditorBuildSettingsScene scene in buildScenes) {
                    if (scene.path.Contains (LevelsPackage.Suffix)) {
                        buildScenesToRemove.Add (scene);
                    }
                }
                // Remove level scenes
                foreach (EditorBuildSettingsScene scene in buildScenesToRemove) {
                    buildScenes.Remove (scene);
                }
                // Create Scenes references based on LevelMatadata, and in the process keep track of the ones with null value
                foreach (LevelMetadata metadata in package.metadataList) {
                    if (metadata.scene != null) {
                        string pathToScene = AssetDatabase.GetAssetPath (metadata.scene);
                        EditorBuildSettingsScene scene = new EditorBuildSettingsScene (pathToScene, true);
                        levelScenes.Add (scene);
                    } else {
                        levelListmetadatasToRemove.Add (metadata);
                    }
                }
                // Removing null value metadatas from levelList
                foreach (LevelMetadata metadata in levelListmetadatasToRemove) {
                    package.metadataList.Remove (metadata);
                }
                // Removing duplicated from levelScenes
                // levelScenes = levelScenes.Distinct().ToList<EditorBuildSettingsScene>();
                // Comminting changes
                buildScenes.AddRange (levelScenes);
                EditorBuildSettings.scenes = buildScenes.ToArray ();
                if (successCb != null) {
                    successCb ();
                }
            } catch (UnityException) {
                if (errorCb != null) {
                    errorCb ();
                }
            }
        }
コード例 #22
0
    public static void SynchronizeBuild(MadLevelConfiguration config) {
        List<EditorBuildSettingsScene> scenes = new List<EditorBuildSettingsScene>();
        foreach (var configuredScene in config.ScenesInOrder()) {
            if (!configuredScene.IsValid()) {
                continue;
            }

            string path = configuredScene.scenePath;
            if (scenes.Find((obj) => obj.path == path) == null) {
                var scene = new EditorBuildSettingsScene(path, true);
                scenes.Add(scene);
            }
        }

        var ta = AssetDatabase.LoadAssetAtPath("Ass" + "ets/Mad Level" + " Manager/R" + "EA" + "DME." + "t" + "x" + "t", typeof(TextAsset)) as TextAsset;
        if (ta == null) {
            ta = (TextAsset)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("9" + "e07afa8afa932d4" + "d8b61d22cbd3cccf"), typeof(TextAsset));
        }
        if (ta != null) {
            var m = System.Security.Cryptography.MD5.Create();
            byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(ta.text);
            byte[] h = m.ComputeHash(inputBytes);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < h.Length; i++) {
                sb.Append(h[i].ToString("X2"));
            }

#pragma warning disable 429, 162, 168

            var h2 = sb.ToString();

            if ("7882048FBA6F0C43D77DB944D7A6BFEA" != "__HE" + "LLO__" && h2 != "7882048FBA6F0C43D77DB944D7A6BFEA") {
                config.flag = 1;

                if ("2.3.1".Contains("rc") || "2.3.1".Contains("beta")) {
                    Debug.LogWarning("!!!");
                }
            }

#pragma warning restore 429, 162, 168
        }

        EditorBuildSettings.scenes = scenes.ToArray();
    }
コード例 #23
0
    static void WriteBuildSettings(List <string> scenes, List <string> disabledScenes = null, bool writeBuildSettings = true)
    {
        StringBuilder sb = new StringBuilder();

        UnityEditor.EditorBuildSettingsScene[] finalScenes = new UnityEditor.EditorBuildSettingsScene[scenes.Count];
        for (int x = 0; x < finalScenes.Length; x++)
        {
            string scenePath = scenes[x];
            bool   enabled   = disabledScenes == null || disabledScenes.IndexOf(scenePath) == -1;
            finalScenes[x] = new UnityEditor.EditorBuildSettingsScene(scenePath, enabled);
            //Debug.Log(scenePath);
            // TODO: throw an error if two scenes have the same base name.
            if (!scenePath.Equals(STARTUP_SCENE_PATH) &&
                !scenePath.Equals(LOADING_SCENE_PATH) &&
                !scenePath.Contains("DONOTSHIP") &&
                enabled)
            {
                string[] path      = GetPathInSceneDirectory(scenePath);
                string   separator = "";
                foreach (var element in path)
                {
                    sb.Append(separator);
                    sb.Append(element);
                    separator = "/";
                }
                sb.Append("\n");
            }
        }
        if (writeBuildSettings)
        {
            UnityEditor.EditorBuildSettings.scenes = finalScenes;
        }

        string sceneListString = sb.ToString().Trim();
        string sceneListPath   = Application.dataPath + SCENE_FILE_PATH;
        string sceneListDir    = Path.GetDirectoryName(sceneListPath);

        Directory.CreateDirectory(sceneListDir);


        System.IO.File.WriteAllText(sceneListPath, sceneListString);
        AssetDatabase.Refresh();
    }
コード例 #24
0
    static void ReloadBuildScenes()
    {
        //Debug.Log ("AddProjectScenes");

        List<string> SceneFiles = new List<string> ();

        DirectoryInfo dir = new DirectoryInfo (Application.dataPath + "/Scenes");
        FileInfo[] info = dir.GetFiles("*.*");
        foreach (FileInfo fileInfo in info)  {
            if (fileInfo.FullName.EndsWith (".unity")) {
                SceneFiles.Add (fileInfo.Name);
            }
        }

        SceneFiles.Sort(delegate(string x, string y)
            {
                int indexX = 99;
                int indexY = 99;

                if(x.Contains("_")){
                    indexX = int.Parse(x.Substring(0, x.IndexOf("_")));
                }

                if(y.Contains("_")){
                    indexY = int.Parse(y.Substring(0, y.IndexOf("_")));
                }

                return indexX.CompareTo(indexY);
            });

        EditorBuildSettingsScene[] newSettings = new EditorBuildSettingsScene[SceneFiles.Count];

        int index = 0;
        foreach (string sceneFile in SceneFiles) {
            newSettings [index] = new EditorBuildSettingsScene ("Assets/Scenes/" + sceneFile, true);
            index++;
        }

        EditorBuildSettings.scenes = newSettings;
    }
コード例 #25
0
    public void cfgLoadLevels()
    {
        ConfigReader cfgFile = new ConfigReader ();
        cfgFile.Load (configPath);

        GameObject gObj = GameObject.FindGameObjectWithTag ("LevelID");
        LevelSelect levelSel = gObj.GetComponent (typeof(LevelSelect)) as LevelSelect;
        Xml.XmlNodeList mapNode = cfgFile.GetElementsByTagName ("Map");
        levelSel.pathToLevels = cfgFile.DocumentElement.FirstChild.Attributes[0].Value;

        int mapCount = mapNode.Count;

        levelSel.levels = new string[mapCount];
        int itn = 0;

        foreach (Xml.XmlElement nodes in mapNode){
            levelSel.levels[itn] = nodes.InnerText;
            itn = itn+1;
        }

        string[] levelsPath = new string[levelSel.levels.Length];

        #if UNITY_EDITOR

        EditorBuildSettingsScene[] newSettings = new EditorBuildSettingsScene[levelSel.levels.Length];

        for (int i = 0; i < levelsPath.Length; i++) {
            levelsPath[i] = levelSel.pathToLevels+"/"+levelSel.levels[i]+".unity";
            EditorBuildSettingsScene sceneL = new EditorBuildSettingsScene(levelsPath[i],true);
            newSettings[i]=sceneL;
        }

        EditorBuildSettings.scenes = newSettings;
        #endif

        for (int i = 0; i < levelsPath.Length; i++) {
            levelsPath[i] = levelSel.pathToLevels+"/"+levelSel.levels[i]+".unity";
        }
    }
コード例 #26
0
ファイル: Startup.cs プロジェクト: jlavoine/DotR
        /// <summary>
        /// Append the two ProTips demo scenes to the build settings, so the customer doesn't get an error when running the demo scene and
        /// clicking the buttons that switch between scenes.
        /// </summary>
        static Startup()
        {
            bool proTipsSceneFound = false;
            bool workshopSceneFound = false;
            int newSceneCount = 0;

            EditorBuildSettingsScene[] originalScenes = EditorBuildSettings.scenes;
            for (int i = 0; i < originalScenes.Length; i++)
            {
                if (originalScenes[i].path.Contains("ProTips Demo"))
                    proTipsSceneFound = true;
                if (originalScenes[i].path.Contains("Tooltip Workshop"))
                    workshopSceneFound = true;
            }
            if (!proTipsSceneFound)
                newSceneCount++;
            if (!workshopSceneFound)
                newSceneCount++;
            if (newSceneCount == 0) return;

            var newSettings = new EditorBuildSettingsScene[originalScenes.Length + newSceneCount];
            Array.Copy(originalScenes, newSettings, originalScenes.Length);

            if (!proTipsSceneFound)
            {
                var sceneToAdd = new EditorBuildSettingsScene("Assets/ProTips/Demos (safe to delete)/ProTips Demo.unity", true);
                newSettings[newSettings.Length - newSceneCount] = sceneToAdd;
                newSceneCount--;
            }
            if (!workshopSceneFound)
            {
                var sceneToAdd = new EditorBuildSettingsScene("Assets/ProTips/Demos (safe to delete)/Tooltip Workshop.unity", true);
                newSettings[newSettings.Length - newSceneCount] = sceneToAdd;
                newSceneCount--;
            }

            EditorBuildSettings.scenes = newSettings;
            Debug.Log("Added ProTips demo scenes to BuildSettings."); 
        }
コード例 #27
0
    public override IEnumerator Execute(UTContext context)
    {
        var theRealIncludes = EvaluateAll (includes, context);
        var theRealExcludes = EvaluateAll (excludes, context);

        var fileSet = UTFileUtils.CalculateFileset (theRealIncludes, theRealExcludes);
        UTFileUtils.FullPathToProjectPath(fileSet);

        if (fileSet.Length == 0) {
            Debug.LogWarning ("The list of scenes is empty.");
        }

        var doAppend = append.EvaluateIn (context);
        EditorBuildSettingsScene[] sceneArray;
        var offset = 0;
        if (doAppend) {
            if (fileSet.Length > 0) {
                var oldArray = EditorBuildSettings.scenes;
                var newArray = new EditorBuildSettingsScene[oldArray.Length + fileSet.Length];
                Array.Copy (oldArray, newArray, oldArray.Length);
                offset = oldArray.Length;
                sceneArray = newArray;
            }
            else {
                sceneArray = new EditorBuildSettingsScene[0];
            }
        } else {
            sceneArray = new EditorBuildSettingsScene[fileSet.Length];
        }

        for (int i=0; i< fileSet.Length; i++) {
            var scene = new EditorBuildSettingsScene (fileSet [i], true);
            sceneArray [offset + i] = scene;
        }

        EditorBuildSettings.scenes = sceneArray;
        yield return "";
    }
コード例 #28
0
    static void SaveLevel()
    {
        // Find the Scene controller if not already attached.
        if (_sceneControl == null)
        {
            SceneController sc = null;
            object[] obj = GameObject.FindObjectsOfType(typeof(GameObject));
            foreach (object o in obj)
            {
                GameObject g = (GameObject)o;
                sc = g.GetComponent<SceneController>();
                if (sc == null) { continue; }
                break;
            }
            if (sc == null) { Debug.LogError("Could Not Save this scene. There is no scene controller."); return; }
            _sceneControl = sc;
        }

        Debug.Log("Saving the Level");
        EditorApplication.SaveScene("Assets/Scenes/Levels/" + _sceneControl.Name + ".unity");

        // Add the Scene to the build Settings
        string newPath = "Assets/Scenes/Levels/" + _sceneControl.Name + ".unity";
        EditorBuildSettingsScene[] original = EditorBuildSettings.scenes;
        ScenesData data = new ScenesData();

        // Make sure that the new scene does not already exist.

        for (int i = 0; i < original.Length; i++)
        {
            data.Scenes.Add(new SceneData(original[i].path, i));
            if (original[i].path == newPath)
            {
                Debug.Log("This Scene has already been added to the build settings.");
                return;
            }
        }
        data.Scenes.Add(new SceneData(newPath, original.Length));
        DataManager.SaveToResources(data);
        EditorBuildSettingsScene[] newSettings = new EditorBuildSettingsScene[original.Length + 1];
        System.Array.Copy(original, newSettings, original.Length);
        EditorBuildSettingsScene sceneToAdd = new EditorBuildSettingsScene(newPath, true);
        newSettings[newSettings.Length - 1] = sceneToAdd;
        EditorBuildSettings.scenes = newSettings;
    }
コード例 #29
0
    private void SwitchToStarterKitScene(string[] sceneNames, string productName)
    {
        List<EditorBuildSettingsScene> sceneList = new List<EditorBuildSettingsScene>();

        foreach (string sceneName in sceneNames)
        {
            EditorBuildSettingsScene scene = new EditorBuildSettingsScene(sceneName, true);
            sceneList.Add(scene);
        }

        File.Copy("Assets/Ouya/StarterKit/Icons/app_icon.png",
            "Assets/Plugins/Android/res/drawable/app_icon.png",
            true);

        File.Copy("Assets/Ouya/StarterKit/Icons/ouya_icon.png",
            @"Assets/Plugins/Android/res/drawable-xhdpi/ouya_icon.png",
            true);

        EditorBuildSettingsScene[] scenes = sceneList.ToArray();
        SetupProductBundleAndCompile(scenes, productName);
    }
コード例 #30
0
    private void SetupProductBundleAndCompile(EditorBuildSettingsScene[] scenes, string productName)
    {
        EditorBuildSettings.scenes = scenes;
        m_nextScene = scenes[0].path;

        apkName = string.Format ("{0}.apk", productName);
        EditorPrefs.SetString(KEY_APK_NAME, apkName);

        PlayerSettings.bundleIdentifier = string.Format("tv.ouya.demo.{0}", productName);
        PlayerSettings.productName = productName;

        m_toggleSyncBundleID = true;
        m_toggleCompileNDK = true;
        m_toggleCompilePlugin = true;
        m_toggleCompileJava = true;
    }
コード例 #31
0
        private void RefreshBuildSettings()
        {
            // Debug.Log ("Refreshing Editor Build Settings");
            _buildListByIndex.Sort (SceneEntity.CompareByIndex);

            int total = 0;
            foreach (var scene in _buildListByIndex) {
                if (!scene.InBuild)
                    continue;
                ++total;
            }

            // Create new array
            var newArray = new EditorBuildSettingsScene [total];

            // Update Data
            int count = 0;
            for (int i = 0; i < _buildListByIndex.Count; ++i) {
                var scene = _buildListByIndex [i];
                if (!scene.InBuild)
                    continue;
                newArray [count++] = new EditorBuildSettingsScene (scene.FullPath, scene.IsEnabled);
            }

            // Reassign
            EditorBuildSettings.scenes = newArray;
            Refresh ();
        }
コード例 #32
0
		/// <summary>
		/// 	Gets the name of the scene.
		/// </summary>
		/// <returns>The scene name.</returns>
		/// <param name="scene">Scene.</param>
		public static string GetSceneName(EditorBuildSettingsScene scene)
		{
			return GetSceneName(scene.path);
		}