We have explored the basics of using scripting and the VideoPlayer component. As well as defining and setting up where VideoPlayer will render, as we need to each time, in the steps above we have completed the following:
- Create or get references to the VideoPlayer and AudioSource components (we will automatically have both components for this recipe since we have the RequireComponent(...) script instructions immediately before our class declaration):
videoPlayer = GetComponent<VideoPlayer>();
audioSource = GetComponent<AudioSource>();
- Set their Play On Awake properties to true/false:
videoPlayer.playOnAwake = false;
audioSource.playOnAwake = false;
- Define where the VideoPlayer will find a reference to the video clip to play:
videoPlayer.source = VideoSource.VideoClip;
videoPlayer.clip = videoClip
- Define the audio settings (so that you can output to the AudioSource component):
videoPlayer.audioOutputMode...