ボタンを押したらGameObjectにつけたvideoplayerが再生されるようにしたいのですが、下記サイトを参考に記入してみたのですがエラーがおこってしまいます。
参考サイト
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.Video; 5using UnityEngine.UI; 6using System; 7 8public class VideplayerControl : MonoBehaviour 9{ 10 private VideoPlayer mPlayer; 11 12 void Start() 13 { 14 mPlayer = GetComponent<VideoPlayer>(); 15 16 } 17 18 private void print(object interactiveMainMenuBooth) 19 { 20 throw new NotImplementedException(); 21 } 22 public void OnClick() 23 { 24 Debug.Log("クリックされた"); 25 } 26 void Update() 27 { 28 if (Input.GetButtonDown("Fire1")) 29 { 30 // 再生中でなければ再生 31 if (!mPlayer.isPlaying) 32 { 33 mPlayer.Play(); 34 // 再生中であれば停止 35 } 36 else 37 { 38 mPlayer.Pause(); 39 } 40 } 41 } 42} 43
どのようなスクリプトを書けばよいでしょうか。
また、再生終了後違うボタンを表示させるにはどのようなスクリプトを記入すればよいでしょうか。
以上、何卒宜しくお願い致します。
申し訳ありません。情報不足でした。以下がエラー内容です。
MissingComponentException: There is no 'VideoPlayer' attached to the "Movie" game object, but a script is trying to access it. You probably need to add a VideoPlayer to the game object "Movie". Or your script needs to check if the component is attached before using it. VideplayerControl.Update () (at Assets/Scripts/VideplayerControl.cs:31)
回答2件
あなたの回答
tips
プレビュー