1

我们正在开发一款适用于移动设备的 Unity 游戏。基本上它是一个带有 3D 角色和一张地图的场景,可以看到他们在哪里。我想知道当我垂直倾斜手机以查看插入到现实世界中的 3D 角色时如何激活手机摄像头,并在水平倾斜手机时返回 3D 世界的地图视图。如果可能的话,有什么想法吗?

4

1 回答 1

0

首先,您必须在更新函数中检查脚本,您可以放置​​如下内容:

using UnityEngine.UI;

    public Image image;

    void Update()
    {
    if (Input.deviceOrientation == DeviceOrientation.FaceDown)
        image.gameObject.SetActive(true);
    }
    else
   {
        image.gameObject.SetActive(false);
   }

在图像中,您应该添加一个包含以下内容的脚本:

void Start ()
     {
             plane = GameObject.FindWithTag ("Player");

             mCamera = new WebCamTexture ();
             plane.renderer.material.mainTexture = mCamera;
             mCamera.Play ();

     }
于 2016-10-28T21:18:41.097 回答