void Awake() { if (instance == null) { instance = this; } else { // Self-destruct if another instance exists Destroy(this); return; } audioSource = GetComponent<AudioSource>(); }
void Awake() { if (instance == null) { instance = this; } else { // Self-destruct if another instance exists Destroy(this); return; } audioSource = GetComponent <AudioSource>(); }
/** * * Coroutine Method for typing out string from * file into textbox of cutscene. * **/ IEnumerator ProcessScriptLine() { // Clear text box. textBoxString.text = ""; // Set name of speaker. nameBoxString.text = scriptLine [0]; //Manipulate Images if needed. if (scriptLine.Length > 2) { ImageProcessing(); } // Determine what image to highlight. if (scriptLine [0] == "Dr. Ndoto") { portraitLImage.color = Color.white; portraitRImage.color = Color.gray; } else if (scriptLine [0] == "Client") { portraitLImage.color = Color.gray; portraitRImage.color = Color.white; } else { portraitLImage.color = Color.gray; portraitRImage.color = Color.gray; } // Get dialogue string to write to text box. lineText = scriptLine [1]; // Play a sound effect for each character. CutsceneSoundScript.PlayTextSound(); textBoxString.text = lineText; yield return(new WaitForSeconds(0)); Debug.Log("End of Coroutine reached."); }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); // Destroy gameobject in scene Scene12 /**if (instance = SceneManager.GetActiveScene(levelToLoad)) * { * Destroy(this.gameObject); * }**/ }