Quest 2 - Local Storage Path changed? - Quest1 App broken!
一応他にも同じような現象起きてる人いるみたいです
自分の場合は360度動画なんですが映りました
適当なのとちょっと余計な処理が入ってますが動くはず...です
環境
Unity 2019.4.11f1
Oculus Integration version 20.1
1. 以下サイトの手順を実施して実機で再生するのを確認
Unityに360度動画を取り込んで再生する
(Main Cameraの代わりにOVRCameraRig設置)
2. VideoPlayerが付いているオブジェクトにMovieManager.csを追加
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Video;
public class MovieManager : MonoBehaviour {
private VideoPlayer videoPlayer;
private RenderTexture renderTexture;
private Material skyboxMaterial;
[SerializeField] string[] targetExtensions;
private List<string> movieList = new List<string>();
private int movieCount = 0;
private void Awake() {
videoPlayer = GetComponent<VideoPlayer>();
renderTexture = videoPlayer.targetTexture;
skyboxMaterial = RenderSettings.skybox;
}
private void OnEnable() {
videoPlayer.frameReady += OnNewFrame;
}
private void Start() {
string path = Application.persistentDataPath + "/Movies";
foreach (string targetExtension in targetExtensions) {
string[] files = Directory.GetFiles(path, "*." + targetExtension, SearchOption.AllDirectories);
foreach (string file in files) {
movieList.Add(file);
}
}
PlayVideo(0);
}
private void Update() {
if (OVRInput.GetDown(OVRInput.Button.One)) {
movieCount = movieCount + 1 < movieList.Count ? movieCount + 1 : 0;
PlayVideo(movieCount);
}
}
private void PlayVideo(int no) {
videoPlayer.source = VideoSource.Url;
videoPlayer.url = movieList[no];
videoPlayer.Play();
videoPlayer.sendFrameReadyEvents = true;
}
void OnNewFrame(VideoPlayer source, long frameIdx) {
RenderTexture rt = source.texture as RenderTexture;
renderTexture = new RenderTexture(rt.width, rt.height, renderTexture.depth);
// 更新
videoPlayer.targetTexture = renderTexture;
skyboxMaterial.mainTexture = renderTexture;
videoPlayer.sendFrameReadyEvents = false;
}
}
3. 指定されたフォルダに動画を置く