環境
Unity5.6.3p4/Unity 2017.3.1p2
やりたい事
Unity標準のVideoPlayerで再生位置を指定して再生する。
試したこと
以下の記事を参考に、再生位置を指定してましたが下記の問題が出ました。
https://qiita.com/gshirato/items/1500f61b408e7af69453
起きている問題
Unity2017.3.1p2では以下のコードではクラッシュし
Unity5.6.3p4ではクラッシュしないものの、実行した時、指定位置まで飛ばすことができませんでした。
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.UI; 5using UnityEngine.Video; 6using UniRx; 7using UniRx.Triggers; 8using System; 9 10public class UIManager : MonoBehaviour { 11 12 // Use this for initialization 13 public Text text; 14 public VideoPlayer vp; 15 public Slider slider; 16 private ulong frameCount; 17 float currentRate; 18 19 void Start () 20 { 21 vp.time = 10; 22 vp.Play(); 23 24 this.UpdateAsObservable() 25 .Where(_ => vp.frameCount > 0) 26 .Subscribe(_ => 27 { 28 decimal pre = (decimal)vp.frame / (decimal)vp.frameCount; 29 slider.value = (float)pre; 30 }); 31 } 32}
またvp.frameを直接いじることも試しましたがうまく行きませんでした。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。