【发布时间】:2019-05-22 05:15:59
【问题描述】:
我遵循了在 github 上的 AugmentedImageController for ARCore unity 中列出的示例代码:https://github.com/google-ar/arcore-unity-sdk/blob/master/Assets/GoogleARCore/Examples/AugmentedImage/Scripts/AugmentedImageExampleController.cs。即使按照本示例中的代码进行操作,它也不会播放视频播放器中的视频,如下面的 AugmentedImageVisualizer 代码所示:
如果我将 AugmentedImageVirtulizer 拖放到场景中并放置 playOnAwake,视频就会播放。但是,当我关闭 playOnAwake,将应用程序发送到我的手机,然后将相机对准增强图像(在我的情况下是空奶瓶标签)时,它不会播放。我希望从奶瓶中出现一个诸如鬼魂之类的物体。
using GoogleARCore;
using UnityEngine;
using UnityEngine.Video;
public class AugmentedImageVisualizer : MonoBehaviour {
private VideoPlayer vidPlayer;
public VideoClip[] vidClips;
public AugmentedImage Image;
// Use this for initialization
void Start () {
vidPlayer = GetComponent<VideoPlayer>();
vidPlayer.loopPointReached += OnStop;
}
private void OnStop(VideoPlayer source)
{
gameObject.SetActive(false);
}
// Update is called once per frame
void Update () {
if (Image == null || Image.TrackingState != TrackingState.Tracking)
{
return;
}
if (!vidPlayer.isPlaying)
{
vidPlayer.clip = vidClips[Image.DatabaseIndex];
vidPlayer.Play();
}
transform.localScale = new Vector3(Image.ExtentX, Image.ExtentZ,
1f);
}
}
没有显示控制台错误,但没有显示视频
【问题讨论】: