实例化模型有屏幕(这是一个平面),并且视频无法播放。我相信是因为克隆模型使视频无法正常工作。当我将屏幕和视频播放器拖放到分别在运行(测试)和播放视频的地方。我尝试从屏幕上使用Getcomponent,并尝试播放仍不起作用的剪辑。
public GameObject screen1;
public GameObject screen2;
public VideoPlayer vid1;
public VideoPlayer vid2;
if (Input.GetMouseButtonDown(0))
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
{
//Debug.Log ("gameobjhect" + gameObject.name);
if (hit.collider.gameObject.name == "Tochpoint1")
{
Debug.Log("Touched Point 1");
if(screen1.gameObject.tag=="Vid1")
{
Debug.Log("1111");
vid1.Play();
}
}
else if (hit.collider.gameObject.tag == "Tochpoint2")
{
Debug.Log("Touched Point 2");
if (screen2.gameObject.name == "Vid2")
{
vids2.Play()
}
}
}
}
答案 0 :(得分:0)
据我了解,当您的点击测试得到一些结果时,您想切换视频片段。因此,这是更改视频的简单示例。将此附加到您的飞机上。
VideoPlayer video;
public VideoClip vid1;
public VideoClip vid2;
// Use this for initialization
void Start () {
video = GetComponent<VideoPlayer>();
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.Mouse0))
{
video.clip = vid1;
}
else if (Input.GetKey(KeyCode.Mouse1))
{
video.clip = vid2;
}
}
当然,您必须根据需要进行管理。每次更改剪辑视频都将从头开始。