public void FadeOut(Image img, float time, FadeHandler handle) { if (isFade) { return; } StartCoroutine(Co_FadeOut(img, time, handle)); }
void Start() { if (instance != null && instance != this) { Destroy(gameObject); return; } else { instance = this; } DontDestroyOnLoad(this); }
IEnumerator Co_FadeOut(Image img, float time, FadeHandler handle) { isFade = true; Color col = new Color(0, 0, 0, 0); float tempTime = 0; while (img.color.a < 1) { tempTime += Time.deltaTime / time; col.a = Mathf.Lerp(0, 1, tempTime); img.color = col; yield return(null); } handle(); isFade = false; }
/// <summary> /// Finds and sets all Manager variables, /// DOES NOT INIT THE VARIABLES THEMSELVES SO DONT RUN START() DEPENDENT CODE HERE /// </summary> void Init() { GetComponentInChildren <Canvas>(true).gameObject.SetActive(true); camera = FindObjectOfType <CameraController>(); player = FindObjectOfType <Player>(); dialogue = GetComponentInChildren <DialogueHandler>(true); fadeHandler = GetComponentInChildren <FadeHandler>(true); fadeHandler.gameObject.SetActive(true); menuHandler = GetComponentInChildren <MenuHandler>(true); menuHandler.Init(); menuHandler.InstaClose(); inMenu = false; startDialogue = FindObjectOfType <DialogueTriggerSceneStart>(); player.disableInput = true; musicBus = FMODUnity.RuntimeManager.GetBus("bus:/Music"); soundBus = FMODUnity.RuntimeManager.GetBus("bus:/Sound"); inMenuPauseInstance = FMODUnity.RuntimeManager.CreateInstance("snapshot:/InMenu"); }
private void Start() { _fadeHandler = FindObjectOfType <FadeHandler>(); if (_fadeHandler == null) { Debug.LogWarning("The GameManager could not find any object that has a FadeHandler"); } else { _fadeHandler.FadeEnded += BeginningFadeDone; _fadeHandler.StartFadeIn(); if (FadeEvent != null) { FadeEvent(true); } } _mainMusicParent = FindObjectOfType <MainMusicParent>(); if (_mainMusicParent == null) { Debug.LogWarning("The GameManager could not find any object that has a MainMusicParent"); } if (_mainMusicParent == null) { Debug.LogWarning("The GameManager did not have any GameOverStingerHandler"); } else { _gameOverStinger = _mainMusicParent.gameObject.GetComponentInChildren <GameOverStingerHandler>(); } if (_camera != null) { _pauseMenuScript = _camera.GetComponentInChildren <PauseMenuScript>(); } }