void Start() { Image [] images = GetComponentsInChildren <Image>(false); ReadSceneNames readNames = GetComponent <ReadSceneNames>(); string [] names = readNames.scenes; int imageCount = 0; for (int i = 0; i < names.Length; i++) { Image image = images[imageCount++]; GameObject newObj = new GameObject(names[i]); newObj.transform.parent = image.transform; newObj.transform.localPosition = Vector3.zero; Text text = newObj.AddComponent <Text>(); text.text = names[i]; text.color = Color.black; text.font = Font; text.fontSize = 15; text.transform.localScale = Vector3.one * 10f; text.horizontalOverflow = HorizontalWrapMode.Wrap; text.verticalOverflow = VerticalWrapMode.Overflow; text.alignment = TextAnchor.MiddleCenter; text.GetComponent <RectTransform>().sizeDelta = new Vector2(45, 45); } }
private void Awake() { instance = this; // read the scene Reset(); }
/* Setter & Getter */ /* Functions */ private void OnGUI() { instance = this; // read the scene Reset(); }
// Use this for initialization void Start() { //DO NOT DESTROY ON LOAD TO BONUS DontDestroyOnLoad(this.gameObject); DontDestroyOnLoad(player.gameObject); DontDestroyOnLoad(rounds.gameObject); DontDestroyOnLoad(totalRoundsText.gameObject); DontDestroyOnLoad(scoreGUI.gameObject); DontDestroyOnLoad(scoreText.gameObject); DontDestroyOnLoad(weapon.gameObject); DontDestroyOnLoad(weaponHeat.gameObject); DontDestroyOnLoad(healthBackground.gameObject); DontDestroyOnLoad(health.gameObject); DontDestroyOnLoad(centreRounds.gameObject); DontDestroyOnLoad(centreTotalRoundsText.gameObject); DontDestroyOnLoad(bonusRoundText.gameObject); DontDestroyOnLoad(gameOverText.gameObject); DontDestroyOnLoad(congratulationsText.gameObject); DontDestroyOnLoad(pausedText.gameObject); DontDestroyOnLoad(powerupText.gameObject); totalRounds = 1; roundsCount = 1; finalLevel = false; sceneNames = GameObject.FindGameObjectWithTag("Manager").GetComponent <ReadSceneNames>(); GO = GameObject.FindGameObjectWithTag("Manager").GetComponent <GameOver>(); centreRounds.enabled = false; centreTotalRoundsText.enabled = false; bonusRoundText.enabled = false; gameOverText.enabled = false; congratulationsText.enabled = false; pausedText.enabled = false; powerupText.enabled = false; }
public void managerRestart() { Destroy(this.gameObject); Destroy(player.gameObject); Destroy(rounds.gameObject); Destroy(totalRoundsText.gameObject); Destroy(scoreGUI.gameObject); Destroy(scoreText.gameObject); Destroy(weapon.gameObject); Destroy(weaponHeat.gameObject); Destroy(healthBackground.gameObject); Destroy(health.gameObject); Destroy(centreRounds.gameObject); Destroy(centreTotalRoundsText.gameObject); Destroy(bonusRoundText.gameObject); Destroy(gameOverText.gameObject); Destroy(congratulationsText.gameObject); Destroy(pausedText.gameObject); Destroy(powerupText.gameObject); totalRounds = 1; roundsCount = 1; finalLevel = false; sceneNames = GameObject.FindGameObjectWithTag("Manager").GetComponent <ReadSceneNames>(); centreRounds.enabled = false; centreTotalRoundsText.enabled = false; bonusRoundText.enabled = false; gameOverText.enabled = false; congratulationsText.enabled = false; pausedText.enabled = false; powerupText.enabled = false; }
private static void UpdateNames(UnityEditor.MenuCommand command) { ReadSceneNames context = (ReadSceneNames)command.context; var allSceneNames = ReadNames(); var testSceneNames = allSceneNames.GetRange(1, allSceneNames.Count - 1); context.testSceneNames = testSceneNames; }
void Start() { sceneNamesScript = gameObject.GetComponent <ReadSceneNames>(); List <string> sceneNames = sceneNamesScript.testSceneNames; for (int i = 0; i < sceneNames.Count; i++) { createOneToggle(new Vector2(0.0f, -i * toggleHeight), sceneNames[i]); if (selectedScenes.Count != 0 && !selectedScenes.Contains(sceneNames[i])) { toggles[toggles.Count - 1].isOn = false; } } }
private static void UpdateNames(UnityEditor.MenuCommand command) { ReadSceneNames context = (ReadSceneNames)command.context; context.scenes = ReadNames(); }
private static void UpdateNames(UnityEditor.MenuCommand command) { ReadSceneNames context = (ReadSceneNames)command.context; context.SCENES_IN_BUILD_SETTING = ReadNames(); }
public ArraysToDictionaryMagic(ReadSceneNames readSceneNames) { GetScenes = new Dictionary<string, List<string>>(); int count = 0; for (int i = 0; i < readSceneNames.zNames.Count; i++) { string name = readSceneNames.zNames[i]; List<string> levels = new List<string>(); int levelCount = readSceneNames.zIndexes[i]; for (int j = 0; j < levelCount; j++) { levels.Add(readSceneNames.zLevels[count++]); } GetScenes[name] = levels; } }
/// <summary> /// Load scene with self-define fade in time. /// </summary> /// <param name="sceneName"> scene name to load </param> /// <param name="fadeInTime"> time to fade in </param> /// <param name="screenColor"> screen color </param> /// <param name="keepBGM"> keep background music playing? </param> public void LoadScene(string sceneName, float fadeInTime, Color screenColor, bool keepBGM) { #if (UNITY_EDITOR) // only do this in Editor Mode, // this help level designer to do their job. if (!ReadSceneNames.CheckSceneAvailable(sceneName)) { JCS_Debug.LogReminder("Scene [" + sceneName + "] you want to load is not in the Build Setting"); return; } #endif // if is loading already, dont load it agian if (mSwitchSceneEffect) { return; } // set the next scene name this.mNextSceneName = sceneName; var gs = JCS_GameSettings.instance; if (gs.SAVE_ON_SWITCH_SCENE && gs.SAVE_GAME_DATA_FUNC != null) { // do the saving. gs.SAVE_GAME_DATA_FUNC.Invoke(); } // preload the scene mAsyncOperation = SceneManager.LoadSceneAsync(mNextSceneName); mAsyncOperation.allowSceneActivation = false; switch (mSwitchSceneType) { case JCS_SwitchSceneType.BLACK_SCREEN: { // move to the last child in order // to render the black screen in front of // any UI's GUI mBlackScreen.MoveToTheLastChild(); // set the screen color. // NOTE(jenchieh): always start with opacity the same // as previous. screenColor.a = mBlackScreen.LocalColor.a; mBlackScreen.LocalColor = screenColor; // record down the screen color. JCS_SceneSettings.instance.SCREEN_COLOR = screenColor; // start fading in (black screen) mBlackScreen.FadeIn(fadeInTime); } break; case JCS_SwitchSceneType.SLIDE_SCREEN: { mBlackSlideScreen.MoveToTheLastChild(); mBlackSlideScreen.StartSlideIn(mAlign, fadeInTime); } break; } var ss = JCS_SoundSettings.instance; ss.KEEP_BGM_SWITCH_SCENE = keepBGM; if (!keepBGM) { // start fading sound if (ss.SMOOTH_SWITCH_SOUND_BETWEEN_SCENE) { // get the component. if (mJCSFadeSound == null) { mJCSFadeSound = this.gameObject.AddComponent <JCS_FadeSound>(); } mJCSFadeSound.SetAudioSource(JCS_SoundManager.instance.GetBGMAudioSource()); // fade out sound to zero mJCSFadeSound.FadeOut(0, fadeInTime); } } // start check to switch scene or not mSwitchSceneEffect = true; // Pause the game depends on setting... JCS_GameManager.instance.GAME_PAUSE = mPauseGameWhileLoadingScene; }