Exemplo n.º 1
0
    void Awake()
    {
        //Check for duplicates in the scene
        UnityEngine.Object[] introloopPlayers = FindObjectsOfType(typeof(IntroloopPlayer));
        for (int i = 0; i < introloopPlayers.Length; i++)
        {
            if (introloopPlayers[i] != this)              //Not conform to singleton pattern
            //Self destruct!
            {
                Destroy(gameObject);
            }
        }

        DontDestroyOnLoad(gameObject);

        introloopSettings = gameObject.GetComponent <IntroloopSettings>();
        if (introloopSettings == null)
        {
            introloopSettings = gameObject.AddComponent <IntroloopSettings>();
        }

        towardsVolume = new float[2];
        willStop      = new bool[2];
        willPause     = new bool[2];
        twoTracks     = new IntroloopTrack[2];
        fadeLength    = new float[2] {
            introloopSettings.defaultFadeLength, introloopSettings.defaultFadeLength
        };

        CreateImportantChilds();
    }
    void Awake()
    {
        //Check for duplicates in the scene
        UnityEngine.Object[] introloopPlayers = FindObjectsOfType(typeof(IntroloopPlayer));
        for(int i = 0; i < introloopPlayers.Length; i++) {
            if(introloopPlayers[i] != this) { //Not conform to singleton pattern
                //Self destruct!
                Destroy(gameObject);
            }
        }

        DontDestroyOnLoad(gameObject);

        introloopSettings = gameObject.GetComponent<IntroloopSettings>();
        if(introloopSettings == null)
        {
            introloopSettings = gameObject.AddComponent<IntroloopSettings>();
        }

        towardsVolume = new float[2];
        willStop = new bool[2];
        willPause = new bool[2];
        twoTracks = new IntroloopTrack[2];
        fadeLength = new float[2]{introloopSettings.defaultFadeLength,introloopSettings.defaultFadeLength};

        CreateImportantChilds();
    }