// Use this for initialization
    void Start()
    {
        StopAllCoroutines();
        //VoManager voManager = FindObjectOfType<VoManager>();
        //VoTimeTable[] voTables = voManager.GetComponentsInChildren<VoTimeTable>();
        VoTimeTable[] voTables = VoManager.instance.transform.GetComponentsInChildren <VoTimeTable>();

        SceneIdentifier sceneIdentifier = FindObjectOfType <SceneIdentifier>();
        VoTimeTable     voTable         = null;

        foreach (VoTimeTable table in voTables)
        {
            if (table.sceneNumber == sceneIdentifier.currentSceneNumber)
            {
                voTable = table;
            }
        }
        minDelayAfterVO = voTable.TimeAfterVoMin;
        maxDelayAfterVO = voTable.TimeAfterVoMax;
    }
Exemple #2
0
    void OnSceneLoaded(Scene _scene, LoadSceneMode _mode)
    {
        //Debug.Log("Voice Jukebox knows, a new Scene was loaded!");
        sceneIdentifier = null;
        sceneIdentifier = FindObjectOfType <SceneIdentifier>().GetComponent <SceneIdentifier>();
        delayTime       = 2f;


        if (callBackCoroutine != null)
        {
            StopCoroutine(callBackCoroutine);
        }

        // Check if there is Component in the VoTable for the current scene. If there is, switch to that voiceover.
        // If not. Stop playing voiceover.
        VoTimeTable[] timeTableComponents = gameObject.GetComponentsInChildren <VoTimeTable>();
        voTable = null;

        foreach (VoTimeTable table in timeTableComponents)
        {
            if (table.sceneNumber == sceneIdentifier.currentSceneNumber)
            {
                voTable = table;
            }
        }

        if (voTable != null)
        {
            float VOholderDelay = voTable.VoStartTime;
            delayTime = (VOholderDelay > delayTime) ? VOholderDelay : 2f;
            StartCoroutine("SwitchVoiceover");
        }
        else
        {
            StopVoiceover();
        }
    }