public override void Initialize() { base.Initialize(); // Create MediaPlayerInterface instance. m_Player = MediaPlayerInterface.CreateMediaPlayerInterface(); m_Player.Initialize(this); if (LoopVideo && m_Player) { m_Player.SetLoop(true); } if (!m_display) { //TODO: replace the GetComponentInParent call with a definitive algorithm for locating correct object. var existingDisplay = GetComponentsInParent <AssetHandlerWidget>().FirstOrDefault(w => w is IModelWidget); if (!existingDisplay) { var displayAsset = GetComponentsInParent <AssetWidget>().FirstOrDefault(a => a != assetWidget); if (displayAsset) { waitingOnDisplayAsset = true; displayAsset.OnAssetInstanced.AddListener(delegate { OnDisplayAssetReady(displayAsset); }); } else { var defaultDisplay = gameObject.AddComponent <ModelWidget>(); defaultDisplay.Initialize(ModelWidget.Primitive.CurvedScreen); existingDisplay = defaultDisplay; } } if (!waitingOnDisplayAsset) { SetDisplay(existingDisplay); } } }
private void GetOrSetMediaPlayers() { if (GetComponentInChildren <SoundWidget>()) { audioSource = GetComponentInParent <AudioSource>(); if (!audioSource) { audioSource = gameObject.AddComponent <AudioSource>(); } } if (GetComponentInChildren <VideoWidget>()) { m_Player = gameObject.GetComponentInParent <MediaPlayerInterface>(); //if (!m_Player) // m_Player = gameObject.AddComponent<MediaPlayerInterface>(); InitializeDisplayMaterials(); } }