public void StartButton() { // destory all managers and load the character select scene if (GameObject.Find("CatManager") != null) { Destroy(GameObject.Find("CatManager")); } if (GameObject.Find("SettingsManager") != null) { Destroy(GameObject.Find("SettingsManager")); } if (GameObject.Find("StageManager") != null) { Destroy(GameObject.Find("StageManager")); } SceneManager.LoadScene(SceneUtility.GetBuildIndexByScenePath("_Scenes/CharacterSelectScene")); }
private void CompleteLevel() { level += 1; Save(); nextLevel = "Assets/Scenes/Level " + level + ".unity"; if (SceneUtility.GetBuildIndexByScenePath(nextLevel) >= 0) { SceneManager.LoadSceneAsync(level); } else { EndGame(); Debug.Log("Game Won!"); } }
public int UpdateBestUnlockStage() { List <string> scenesInBuild = new List <string>(); for (int i = 1; i < SceneManager.sceneCountInBuildSettings; i++) { string scenePath = SceneUtility.GetScenePathByBuildIndex(i); int lastSlash = scenePath.LastIndexOf("/"); scenesInBuild.Add(scenePath.Substring(lastSlash + 1, scenePath.LastIndexOf(".") - lastSlash - 1)); } if (scenesInBuild.Contains("world" + (this.bestUnlockedStage + 1))) { this.bestUnlockedStage += 1; } return(this.bestUnlockedStage); }
private void Start() { DontDestroyOnLoad(gameObject); List <string> scenes = new List <string>(); var sceneNumber = SceneManager.sceneCountInBuildSettings; for (int i = 0; i < sceneNumber; i++) { scenes.Add(Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(i))); } Dropdown.ClearOptions(); Dropdown.AddOptions(scenes); Dropdown.onValueChanged.AddListener(OnDropdownValueChanged); }
public DatatableEntry(int i) { buildIndex = i; convertedPath = SceneUtility.GetScenePathByBuildIndex(i); deconvertedPath = ExtendedScene.DeconvertPath(convertedPath); string[] substrings = deconvertedPath.Split('/'); sceneName = substrings[substrings.Length - 1]; sceneRing = SceneRing.None; for (int r = 1; r > int.MinValue; r = r << 1) { if (deconvertedPath.Contains("/" + (SceneRing)r + "/" + sceneName)) { sceneRing = (SceneRing)r; break; } } }
public void EditorUnpack() { List <Transform> allChildren = new List <Transform>(); SceneUtility.GetChildrenRecursively(transform, ref allChildren); editorChildCount = allChildren.Count; for (int i = 0; i < allChildren.Count; i++) { Builder[] builders = allChildren[i].GetComponents <Builder>(); for (int j = 0; j < builders.Length; j++) { builders[j].OnUnpack(); } } unpacked = true; UpdateReferences(); }
#pragma warning restore CS0649 void Start() { int sceneCount = SceneManager.sceneCountInBuildSettings; string[] scenes = new string[sceneCount]; for (int i = 0; i < sceneCount; i++) { scenes[i] = System.IO.Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(i)); } foreach (var scene in scenes) { var curBtn = Instantiate(btnPrefab, content); curBtn.onClick.AddListener(() => SceneManager.LoadScene(scene)); curBtn.GetComponentInChildren <Text>().text = (scene); } }
public void Execute(Console console, params string[] args) { if (CommandUtil.IsOptionSet("-b", args)) { for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++) { console.Log($"{i} - {System.IO.Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(i))}"); } } else if (CommandUtil.IsOptionSet("-l", args) || CommandUtil.GetNumSetOptions(args) == 0) { for (int i = 0; i < SceneManager.sceneCount; i++) { console.Log($"{i} - {SceneManager.GetSceneAt(i).name}"); } } }
public void RestartScene() { IsPaused = false; Time.timeScale = 1; string scenePath = gameData.PrototypeLevel.MainScene.ScenePath; int sceneIndex = SceneUtility.GetBuildIndexByScenePath(scenePath); StartCoroutine(LoadLevel(gameData.PrototypeLevel.ActiveScene.BuildIndex)); //Scene scene = SceneManager.GetSceneByPath(scenePath); //SceneManager.LoadScene(scene.name); //SceneManager.SetActiveScene(scene); //LoadScene(gameData.PrototypeLevel.ActiveScene); OnRestartScene(); }
void Start() { // Get available scenes. int c = SceneManager.sceneCountInBuildSettings; List <string> scenes = new List <string>(c); for (int i = 1; i < c; ++i) { scenes.Add(SceneNameFromPath(SceneUtility.GetScenePathByBuildIndex(i))); } // Update the drop-down menut with them. FindObjectOfType <Dropdown>().AddOptions(scenes); // Load the first scene by default. scene = 1; SceneManager.LoadScene(1, LoadSceneMode.Additive); }
protected override void Awake() { base.Awake(); DontDestroyOnLoad(gameObject); m_AllScenes = new HashSet <string>(); for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++) { var scenePath = SceneUtility.GetScenePathByBuildIndex(i); scenePath = scenePath.Replace("Assets/", ""); scenePath = scenePath.Replace(".unity", ""); var sceneName = scenePath.Substring(scenePath.LastIndexOf("/") + 1); m_AllScenes.Add(scenePath); m_AllScenes.Add(sceneName); } }
public List <string> GetAllScenesInBuild() { List <string> scenes = new List <string>(); int sceneCount = SceneManager.sceneCountInBuildSettings; for (int i = 0; i < sceneCount; i++) { string path = SceneUtility.GetScenePathByBuildIndex(i); if (!string.IsNullOrEmpty(path)) { scenes.Add(path); } } return(scenes); }
IEnumerator WaitAndReset() { yield return(new WaitForSeconds(5f)); yield return(SceneUtility.UnloadAll(isTutorial)); yield return(SceneUtility.LoadGame(round)); EventBus.Publish <ResourceChangeEvent>(new ResourceChangeEvent(1, 1000)); EventBus.Publish <ResourceChangeEvent>(new ResourceChangeEvent(2, 1000)); EventBus.Publish <SpeedChangeEvent>(new SpeedChangeEvent(1, 50)); EventBus.Publish <SpeedChangeEvent>(new SpeedChangeEvent(2, 50)); finished = false; chest_converted[1] = chest_converted[2] = false; goal_point[1] = goal_point[2] = 0; isTutorial = false; }
private static Level[] LoadSavedSetup() { // Temporarily store copy of data and resize the data.levels array. Level[] tempDataCopy = Data.levels; Data.levels = new Level[SceneManager.sceneCountInBuildSettings]; Debug.Log(Data.levels.Length); // Reassign existing values from temporary copied data back to data.levels array. if (Data.levels.Length < tempDataCopy.Length) { for (int i = 0; i < Data.levels.Length; i++) { if (Data.levels[i] != tempDataCopy[i]) { Data.levels[i] = tempDataCopy[i]; } } } else { for (int i = 0; i < tempDataCopy.Length; i++) { if (Data.levels[i] != tempDataCopy[i]) { Data.levels[i] = tempDataCopy[i]; } } } // If any element(level) in the array is null, create a new level for (int i = 0; i < Data.levels.Length; i++) { if (Data.levels[i] == null) { Data.levels[i] = new Level(Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(i)), $"Level {i}", true, Level.LevelStars.ZERO, Level.LevelGems.Gem3, 0); // If the new level is locked, but the previous one has been completed, unlock new level. if (Data.levels[i - 1].stars != Level.LevelStars.ZERO && Data.levels[i].levelLocked) { Data.levels[i].levelLocked = false; } } } return(Data.levels); }
private void Start() { thisScene = SceneManager.GetActiveScene(); lvlname = thisScene.name.ToCharArray(); //Debug.Log(lvlname[0].ToString() + lvlname[1].ToString() + lvlname[2].ToString() + lvlname[3].ToString() + lvlname[4].ToString() + ((lvlname[5] - '0' + 1)).ToString()); if (string.Compare(thisScene.name, "LevelSelect") != 0) { if (GameObject.Find("Main/Canvas/Next Level Menu").GetComponent <RectTransform>() != null) { nextLevelMenu = GameObject.Find("Main/Canvas/Next Level Menu").GetComponent <RectTransform>(); } } //nextLevel(); for (int i = 1; i < SceneManager.sceneCountInBuildSettings; i++) { string scenePath = SceneUtility.GetScenePathByBuildIndex(i); int lastSlash = scenePath.LastIndexOf("/"); scenesInBuild.Add(scenePath.Substring(lastSlash + 1, scenePath.LastIndexOf(".") - lastSlash - 1)); } //nextLevel(); int stage, level; level = int.Parse((lvlname[1] - '0').ToString() + (lvlname[2] - '0').ToString()) + 1; stage = int.Parse((lvlname[4] - '0').ToString() + (lvlname[5] - '0').ToString()) + 1; if (level >= 10) { _nextlevel = ('l').ToString() + (int.Parse((lvlname[1] - '0').ToString() + (lvlname[2] - '0').ToString()) + 1).ToString() + "-01"; } else { _nextlevel = ('l').ToString() + ('0').ToString() + (int.Parse((lvlname[1] - '0').ToString() + (lvlname[2] - '0').ToString()) + 1).ToString() + "-01"; } if (stage >= 10) { _nextstage = ('l').ToString() + lvlname[1].ToString() + lvlname[2].ToString() + lvlname[3].ToString() + (int.Parse((lvlname[4] - '0').ToString() + (lvlname[5] - '0').ToString()) + 1).ToString(); } else { _nextstage = ('l').ToString() + lvlname[1].ToString() + lvlname[2].ToString() + lvlname[3].ToString() + ('0').ToString() + (int.Parse((lvlname[4] - '0').ToString() + (lvlname[5] - '0').ToString()) + 1).ToString(); } //Debug.Log(_nextstage+" "+_nextlevel); }
private void TransitStageToNextLevel() { // yes i know this line is very convoluted, but the scenemanager is not able to call GetSceneAt(index) for unloaded scenes. string prevSceneName = Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(SceneManager.GetActiveScene().buildIndex - 1)); if (currentSceneName.ElementAt(5) != prevSceneName.ElementAt(5) && !prevSceneName.Contains("Cutscene")) // a hack done to see if the level the user is at changed { currentLevel += 1; Debug.Log("Level Changed: " + currentLevel); // tutorial is lvl 0 // change bgm audioSources[currentLevel].volume = 0.1f; string nextSceneMusicParam = FadeMixerGroup.exposedBGMParams[currentLevel]; string prevSceneMusicParam = FadeMixerGroup.exposedBGMParams[currentLevel - 1]; StartCoroutine(FadeMixerGroup.StartFade(audioMixer, prevSceneMusicParam, 2f, 0f)); StartCoroutine(FadeMixerGroup.StartFade(audioMixer, nextSceneMusicParam, 4f, 1f)); } }
protected virtual void Start() { // NOTE: // Ignore SceneLoader scene. int sceneCount = SceneManager.sceneCountInBuildSettings; this.scenes = new string[sceneCount - 1]; for (int i = 1; i < sceneCount; i++) { this.scenes[i - 1] = " " + SceneUtility.GetScenePathByBuildIndex(i); } string sceneIndex = FileReadWriter.ReadTextFromFile(this.settingFile) ?? "1"; int.TryParse(sceneIndex, out this.sceneIndex); }
public void LoadSelectedScene(string playerName) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/Saves" + playerName + ".dat", FileMode.Open); CubeListData data = (CubeListData)bf.Deserialize(file); file.Close(); int index = SceneUtility.GetBuildIndexByScenePath("Assets/_scenes/" + data.sceneName + ".unity"); flagScene.GetComponent <DataLoad> ().playerName = data.playerName; DontDestroyOnLoad(flagScene); SceneManager.LoadScene(index, LoadSceneMode.Single); // need to load the scene before finding it Scene sceneToLoad = SceneManager.GetSceneByBuildIndex(index); Debug.Log(flagScene.name); SceneManager.MoveGameObjectToScene(flagScene, sceneToLoad); }
private static void FetchBuildScenes() { if (null == buildScenes) { buildScenes = new List <string>(); } else { buildScenes.Clear(); } for (int i = 0; i < SceneManager.sceneCountInBuildSettings; ++i) { string scenePath = SceneUtility.GetScenePathByBuildIndex(i); //int lastSlash = scenePath.LastIndexOf('/'); //string name = scenePath.Substring(lastSlash + 1, scenePath.LastIndexOf('.') - lastSlash - 1); buildScenes.Add(scenePath); } }
public void DrawSlider(SerializedProperty property, FieldOption option, GUIContent label = null) { if (property.propertyType != SerializedPropertyType.Integer) { MightyGUIUtilities.DrawPropertyField(property, label); MightyGUIUtilities.DrawHelpBox($"{nameof(SceneSliderAttribute)} can be used only on int fields"); return; } var max = SceneManager.sceneCountInBuildSettings - 1; property.intValue = option.Contains(FieldOption.HideLabel) ? EditorGUILayout.IntSlider(property.intValue, 0, max) : EditorGUILayout.IntSlider(label ?? EditorGUIUtility.TrTextContent(property.displayName), property.intValue, 0, max); EditorGUILayout.LabelField(Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(property.intValue)), EditorStyles.boldLabel); }
IEnumerator LoadAsyncOperation() { int index = 0; // AsyncOperation //Debug.Log(SceneUtility.GetBuildIndexByScenePath("Scenes/Game")); //AsyncOperation load = SceneManager.LoadSceneAsync(SceneUtility.GetBuildIndexByScenePath("Scenes/Game")); index = SceneUtility.GetBuildIndexByScenePath("Scenes/" + PlayerPrefs.GetString("SceneNameToLoad")); Debug.Log(PlayerPrefs.GetString("SceneNameToLoad")); AsyncOperation load = SceneManager.LoadSceneAsync(index); while (load.progress < 1) { progressBar.fillAmount = load.progress; yield return(new WaitForEndOfFrame()); } }
private static IEnumerable GetScenes() { var sceneCount = SceneManager.sceneCountInBuildSettings; var scenes = new List <string>(); for (int sceneIndex = 0; sceneIndex < sceneCount; ++sceneIndex) { var scenePath = SceneUtility.GetScenePathByBuildIndex(sceneIndex); if (scenePath.Contains("InitTestScene")) { continue; } scenes.Add(scenePath); } scenes.Sort(); return(scenes); }
/// <summary> /// To be called only by UI buttons or controls that should start a game. /// </summary> /// <param name="gameIndex">The Scene Index (in Build Settings) of the main scene of the game to start.</param> public string StartAGame(int gameIndex) { string resultText = ""; string scenePath = SceneUtility.GetScenePathByBuildIndex(gameIndex); if (scenePath != "") { runningGameIndex = gameIndex; SceneManager.LoadScene(gameIndex); } else { Debug.LogError("GobblerWareManager:: Failed to load game at index '" + gameIndex + "'. No such scene exists in Build Settings."); resultText = "Failed to load game at index '" + gameIndex + "'. No Scene exists in Build Settings for this game!"; } return(resultText); }
void Start() { //var content = GetComponent<ScrollContent>(); for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++) { //var path = SceneUtility.GetScenePathByBuildIndex(i); var scene = Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(i)); if (!scene.Contains("Level")) { continue; } Debug.Log($"{scene} at {i}"); var button = Instantiate(this.button, transform, true); button.GetComponent <LevelLoader>().SceneIndex = i; button.GetComponentInChildren <Text>().text = scene; } }
/// <summary> /// Gathers all scenes in the build. /// </summary> static public int AllBuildScenes(ICollection <SceneBinding> outScenes, bool inbIncludeIgnored = false) { int buildSceneCount = SceneManager.sceneCountInBuildSettings; int returnedCount = 0; for (int i = 0; i < buildSceneCount; ++i) { string path = SceneUtility.GetScenePathByBuildIndex(i); SceneBinding binding = new SceneBinding(i, path); if (inbIncludeIgnored || !IsIgnored(binding)) { outScenes.Add(binding); ++returnedCount; } } return(returnedCount); }
protected override void OnUnload(string id, Scene scene, ISceneInfo info, ISceneUnloadParameters parameters, IContext context) { LogSceneUnload(id, info, parameters, scene, UnloadUnusedAfterUnload); SceneUtility.UnloadScene(scene, parameters.Options); if (RegisterApplication) { OnUnregisterApplication(scene); } if (UnloadUnusedAfterUnload) { Resources.UnloadUnusedAssets(); } LogSceneUnloaded(id, info, parameters, UnloadUnusedAfterUnload); }
private bool IsStageScene(int sceneBuildIndex) { if (sceneBuildIndex >= 0 && sceneBuildIndex < SceneManager.sceneCountInBuildSettings) { string sceneName = SceneUtility.GetScenePathByBuildIndex(sceneBuildIndex); int start = sceneName.LastIndexOf('/') + 1; int end = sceneName.LastIndexOf('.'); sceneName = sceneName.Substring(start, end - start); return((sceneName == "Stage1") || (sceneName == "Stage2") || (sceneName == "Stage3")); } else { return(false); } }
private void RenderTabScenes() { using (new GUILayout.VerticalScope("Box")) { GUILayout.Label("All scenes", "header"); using (GUILayout.ScrollViewScope scroll = new GUILayout.ScrollViewScope(sceneScrollPos)) { sceneScrollPos = scroll.scrollPosition; for (int i = 0; i < USceneManager.sceneCountInBuildSettings; i++) { Scene currentScene = USceneManager.GetSceneByBuildIndex(i); string path = SceneUtility.GetScenePathByBuildIndex(i); bool isSelected = selectedScene.IsValid() && currentScene == selectedScene; bool isLoaded = currentScene.isLoaded; using (new GUILayout.HorizontalScope("Box")) { if (GUILayout.Button($"{(isSelected ? ">> " : "")}{i}: {path.TruncateLeft(35)}", isLoaded ? "sceneLoaded" : "label")) { selectedScene = currentScene; ActiveTab = GetTab("Hierarchy"); } if (isLoaded) { if (GUILayout.Button("Unload", "loadScene")) { USceneManager.UnloadSceneAsync(i); } } else { if (GUILayout.Button("Load", "loadScene")) { USceneManager.LoadSceneAsync(i); } } } } } } }
public static void BuildCardboard() { // Get filename. string path = EditorUtility.SaveFilePanel("Choose Location of Built Game", Environment.CurrentDirectory + "/build", "oscillations-cardboard.apk", "apk"); AssetDatabase.Refresh(); string targetAPK = GetArg("-targetPath"); string productName = PlayerSettings.productName; PlayerSettings.productName = "Oscillate-Diffusion"; string androidProductID = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.Android); PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, "com.mrl.swingdiff"); Debug.Log("Building Oscillate to path: " + targetAPK + ".\nScenes:"); List <string> scenes = new List <string>(); for (int c = 0; c < 20; c++) { string name = SceneUtility.GetScenePathByBuildIndex(c); if (name == null || name.Length == 0) { break; } scenes.Add(name); Debug.Log(name); } BuildPlayerOptions options = new BuildPlayerOptions(); options.scenes = scenes.ToArray(); options.locationPathName = path; options.target = BuildTarget.Android; options.options = BuildOptions.None; options.targetGroup = BuildTargetGroup.Android; string[] vrSDKs = PlayerSettings.GetVirtualRealitySDKs(BuildTargetGroup.Android); PlayerSettings.SetVirtualRealitySDKs(BuildTargetGroup.Android, new string[] { "Cardboard" }); BuildPipeline.BuildPlayer(options); PlayerSettings.SetVirtualRealitySDKs(BuildTargetGroup.Android, vrSDKs); PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, androidProductID); PlayerSettings.productName = productName; }
static public void Display(string title, CustomStyle myStyle) { GUILayout.BeginHorizontal(myStyle.BacgDemos); if (buttonIconHome == null) { buttonIconHome = Resources.Load <Texture2D>("Textures/home"); } if (buttonIconQuit == null) { buttonIconQuit = Resources.Load <Texture2D>("Textures/quit"); } if (buttonIconMPTK == null) { buttonIconMPTK = Resources.Load <Texture2D>("Logo_MPTK"); } if (GUILayout.Button(new GUIContent(buttonIconHome, "Go to main menu"), GUILayout.Width(60), GUILayout.Height(60))) { for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++) { if (SceneUtility.GetScenePathByBuildIndex(i).Contains("ScenesDemonstration")) { MidiPlayerGlobal.MPTK_Stop(); SceneManager.LoadScene(i, LoadSceneMode.Single); return; } } } GUILayout.Space(20); GUILayout.Label(title, myStyle.TitleLabel1, GUILayout.Height(60)); GUILayout.Space(20); if (GUILayout.Button(new GUIContent(buttonIconQuit, "Exit"), GUILayout.Width(60), GUILayout.Height(60))) { MidiPlayerGlobal.MPTK_Quit(); } if (GUILayout.Button(new GUIContent(buttonIconMPTK, "Go to web site"), GUILayout.Width(60), GUILayout.Height(60))) { Application.OpenURL("https://paxstellar.fr/setup-mptk-quick-start-v2/"); } GUILayout.EndHorizontal(); }