我正在与Google VR SDK for Unity合作,试图使用开发工具包附带的组件来构建一个简单的360视频查看器。我正在尝试扩展他们的PanoVideoSample,当用户从菜单导航时,可以动态改变源视频。
我在通过代码更改GvrVideoPlayerTexture的网址时遇到了问题。在他们的演示场景(VideoDemo)中,他们有一个包含Video Sphere的PanoVideoSample,您可以编辑检查器面板中的GVRVideoPlayerTexture脚本以指向正确的视频URL。
我想在C#中动态设置视频地址,而不是硬编码一堆单独的视频球体,然后隐藏/显示它们。使用下面的代码,我几乎已经完成了这项工作。
public void SwapVideo(int index){
videoSphere.GetComponentInChildren<GvrVideoPlayerTexture> ().videoURL = urls [index];// my new url
videoSphere.GetComponentInChildren<GvrVideoPlayerTexture>().ReInitializeVideo ();
videoSphere.SetActive (true);
}
public void ReturnToMainMenu(){
videoSphere.GetComponentInChildren<GvrVideoPlayerTexture>().CleanupVideo();
videoSphere.SetActive (false);
this.gameObject.SetActive (true);
}上面的代码似乎可以工作,但问题是在设置url并重新初始化纹理后,videoSphere上的纹理变为白色。我可以看到新的视频加载,我可以听到新视频的音频,但场景只显示白色纹理。See the output here
我想知道我是否遗漏了GvrVideoPlayerTexture上的一个关键步骤,或者可能是用于更新用于渲染场景的StereoPanoSphereMaterial的额外调用。这是一个非常新的SDK,似乎没有多少人在写它,所以任何帮助都是非常感谢的。
发布于 2017-02-02 02:38:35
我最终在谷歌VR文档(Streaming Video Support)上找到了我问题的答案。我仍然不完全清楚我在第一次尝试中做错了什么,但这是为我工作的代码。
videoSphere.GetComponentInChildren<GvrVideoPlayerTexture> ().videoURL = urls [index];
videoSphere.GetComponentInChildren<GvrVideoPlayerTexture> ().videoType = GvrVideoPlayerTexture.VideoType.Other;
videoSphere.GetComponentInChildren<GvrVideoPlayerTexture> ().videoProviderId = string.Empty;
videoSphere.GetComponentInChildren<GvrVideoPlayerTexture> ().videoContentID = string.Empty;
videoSphere.GetComponentInChildren<GvrVideoPlayerTexture> ().CleanupVideo ();
videoSphere.GetComponentInChildren<GvrVideoPlayerTexture> ().ReInitializeVideo ();https://stackoverflow.com/questions/41814328
复制相似问题