Example #1
0
 public void AddMaterialReplaceToObject(GameObject obj)
 {
     if (obj.GetComponent <MaterialReplacer>() == null && !AddedMaterialReplacerTo.Contains(obj.GetInstanceID()))
     {
         obj.AddComponent <MaterialReplacer>();
         AddedMaterialReplacerTo.Add(obj.gameObject.GetInstanceID());
     }
 }
Example #2
0
        private void SceneManager_activeSceneChanged(Scene before, Scene after)
        {
            Debug.Log(after.name);

            AddedMaterialReplacerTo.Clear();

            /*
             * I really wish I could use switch statements for this,
             * but even though the scene names are the same in every build,
             * we gotta prepare for changes.
             */

            if (Master.VersionData.SceneNameIs(after, "MainMenu"))
            {
                foreach (AudioSource source in FindObjectsOfType <AudioSource>())
                {
                    Debug.Log(source.name + " " + source.clip.name);
                    if (Master.VersionData.GameObjectNameIs(source.gameObject, "IntroMusic"))
                    {
                        source.Stop(); //Stop the audio source.
                        source.clip = AssetManager.GetAudioClip(AssetManager.Config.TitleScreenMusic.AudioFile);
                        source.loop = AssetManager.Config.TitleScreenMusic.Loop;
                        source.Play();
                    }

                    if (Master.VersionData.GameObjectNameIs(source.gameObject, "BaldiIntro") && !AssetManager.Config.TitleScreenMusic.BaldiIntro)
                    {
                        source.enabled = false;
                    }
                }
            }
            else if (Master.VersionData.SceneNameIs(after, "School"))
            {
                //Lock the cursor.
                Cursor.lockState = CursorLockMode.Locked;
                Cursor.visible   = false;
            }
            else if (Master.VersionData.SceneNameIs(after, "Win"))
            {
                //This used to have a purpose, now it doesn't, it's only here for reference.
            }
            else if (Master.VersionData.SceneNameIs(after, "GameOver"))
            {
                if (AssetManager.Config.GameOver.ReplaceDefaultGameOver)
                {
                    foreach (object obj in GetObjectsOfType("GameOver"))
                    {
                        ((MonoBehaviour)obj).gameObject.AddComponent <GameOver>();
                        Destroy((MonoBehaviour)obj);
                    }
                }
            }
        }