public override void Initialize(MediaPlayerController controller, Transform target) { m_controller = controller; if (target == null) { Debug.LogWarning("[VideoPlayer360][Warning] The 'target' property is required."); return; } m_target = target; videoPlayer = target.gameObject.AddComponent <VideoPlayer>(); // Normally I would check to see if the component already existed, but for some reason GetComponent<VideoPlayer>() doesn't return null even if there isn't a component videoPlayer.renderMode = VideoRenderMode.MaterialOverride; videoPlayer.targetMaterialRenderer = target.GetComponent <MeshRenderer>(); var audioSource = videoPlayer.gameObject.AddComponent <AudioSource>(); videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource; videoPlayer.SetTargetAudioSource(0, audioSource); videoPlayer.skipOnDrop = true; videoPlayer.isLooping = true; videoPlayer.prepareCompleted += (e) => { OnVideoReady(); }; videoPlayer.loopPointReached += (e) => { OnVideoEnd(); }; videoPlayer.seekCompleted += (e) => { OnSeekComplete(); }; }
void Start() { videoWallUnits = this.transform.GetComponentsInChildren <VideoWallUnit>().ToList(); mediaPlayerController = GameObject.FindObjectOfType <MediaPlayerController>(); InitializeWallUnits(); }
public override void Initialize(MediaPlayerController controller, Transform target) { m_controller = controller; if (target == null) { Debug.LogWarning("[VideoPlayer360][Warning] The 'target' property is required."); return; } m_target = target; // EMT has code in Awake() which processes m_TargetMaterial, so if you set the target material after Awake() is called, // it doesn't work correctly. To avoid this problem, we disable the target object first, then set the target material, // then re-enable the target object again (at the end of the frame) var wasActive = m_target.gameObject.activeInHierarchy; m_target.gameObject.SetActive(false); mediaPlayerCtrl = target.GetComponent <MediaPlayerCtrl>() ?? m_target.gameObject.AddComponent <MediaPlayerCtrl>(); mediaPlayerCtrl.m_TargetMaterial = new GameObject[] { m_target.gameObject }; mediaPlayerCtrl.m_bLoop = true; mediaPlayerCtrl.OnEnd += OnVideoEnd; mediaPlayerCtrl.OnVideoFirstFrameReady += OnVideoReady; if (wasActive) { controller.StartCoroutine(EnableTarget()); } }
public void Initialize(MediaPlayerController mediaPlayerController) { this.mediaPlayerController = mediaPlayerController; }
public abstract void Initialize(MediaPlayerController controller, Transform target);