示例#1
0
    public void PlayMovie(VideoClip videoClip, MovieEnd function)
    {
        if (fadeListener == null)
        {
            fadeListener = GameObject.FindGameObjectWithTag("Listener").GetComponent <FadeListener>();
        }

        var subtitlesPath = $"Subtitles/{videoClip.name}.sv";

        Debug.Log($"loading subtitles from resource '{subtitlesPath}'");
        var textAsset = Resources.Load(subtitlesPath) as TextAsset;

        if (textAsset == null)
        {
            Debug.LogError($"missing subtitles text, should have been here '{subtitlesPath}'");
        }

        Debug.Log($"found text:{textAsset.text}");

        var subtitlesObject = GameObject.Find("Subtitles");

        Debug.Log($"Found gameobject {subtitlesObject.name}");
        subtitles = subtitlesObject.GetComponent <Subtitles>();
        subtitles.OnSubtitleStart(textAsset.text);
        fadeListener.SetTargetVolume(0);
        fadeListener.OnFadeListener(0);

        videoPlayer.clip = videoClip;
        videoPlayer.Play();
        Debug.Log("Play Movie:" + videoPlayer.name);

        endFunction    = function;
        waitingForPlay = true;
        Time.timeScale = 0;

        fadeInFadeOut.SetToTransparent(); // SetToBlack();
    }