Unity 3d转2d再转3d
来源:互联网 发布:网络主播招聘是真的吗 编辑:程序博客网 时间:2024/04/26 04:56
我是用daydream平台测试的,目前别的平台还没有测试
大概思路是playerSettings 中设置勾选Virtual Reality Supported 后选着对应的平台这里选的是Daydream
然后在转换平台时用下面的方法加载到对应的平台,
UnityEngine.XR.XRSettings.LoadDeviceByName("None")
UnityEngine.XR.XRSettings.LoadDeviceByName("daydream");
并设置UnityEngine.XR.XRSettings.enabled = true;就可以切换到vr模式了
在同一个场景中增加两个MainCamera,
下面把脚本附上
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.XR;
public class Manger3dTo2d : MonoBehaviour
{
private bool is3d = true;
public GameObject canvas;
public GameObject mainCamare;
public GameObject camare;
//public GameObject evenSystem;
public TextMesh tm;
//public GameObject hand;
// Use this for initialization
void Start ()
{
tm.text = XRSettings.loadedDeviceName;
Debug.Log(XRSettings.loadedDeviceName + "333");
is3d = true;
canvas.SetActive(false);
camare.SetActive(false);
}
// Update is called once per frame
void Update () {
if ((GvrControllerInput.AppButtonUp || Input.GetKeyUp(KeyCode.A)) && is3d)
{
canvas.SetActive(true);
is3d = false;
//UnityEngine.XR.XRSettings.enabled = false;
XRSettings.LoadDeviceByName("None");
Debug.Log(XRSettings.loadedDeviceName);
tm.text = XRSettings.loadedDeviceName;
//evenSystem.GetComponent<GvrPointerInputModule>().enabled = false;
//evenSystem.GetComponent<StandaloneInputModule>().enabled = true;
mainCamare.SetActive(false);
camare.SetActive(true);
//hand.SetActive(false);
}
if (GvrControllerInput.ClickButtonDown || Input.GetKeyUp(KeyCode.B))
{
To3d();
}
}
public void To3d()
{
StartCoroutine(VrOn());
}
IEnumerator VrOn()
{
XRSettings.LoadDeviceByName("daydream");
Debug.Log(XRSettings.loadedDeviceName + "1111");
#if UNITY_EDITOR
#endif
#if UNITY_ANDROID
yield return new WaitUntil(() => XRSettings.loadedDeviceName == "daydream");//到这一步pc不能测试了
#endif
Debug.Log(XRSettings.loadedDeviceName + "222");
yield return null;
XRSettings.enabled = true;
Debug.Log(XRSettings.loadedDeviceName);
tm.text = XRSettings.loadedDeviceName;
canvas.SetActive(false);
is3d = true;
mainCamare.SetActive(true);
camare.SetActive(false);
//hand.SetActive(true);
//evenSystem.GetComponent<GvrPointerInputModule>().enabled = true;
//evenSystem.GetComponent<StandaloneInputModule>().enabled = false;
}
public void ButtonClick()
{
Debug.Log("这是2d场景");
}
}
- Unity 3d转2d再转3d
- 2D转3D
- unity 3D 复习2
- Unity 3D
- unity 3d 注意事项
- Unity 3d 摄像头
- Unity 3D 使用
- Unity 3D--PlayerPrefs
- Unity 3d
- Unity 3D俄罗斯方块
- unity 3d 多开
- UNITY 3D笔记
- Unity 3D接触
- unity 3d
- Unity 3D简介
- Unity 3D 琐记
- unity 3d 视频
- Unity 3D 光源
- Linux 配置环境之安装 JDK
- 使用for update导入数据
- 在你的代码之外,服务时延过长的三个追查方向(下)
- Django框架学习笔记(20.Cookies简易实例)
- 用Scrapy shell调试xpath
- Unity 3d转2d再转3d
- spring源码学习-20171220
- Dapper大规模分布式系统的跟踪系统
- Spring注解:@Configuration和@Bean
- Android内存优化大全(全)
- VUE javascript 复杂列表显示值
- 微信小程序开发-开发入门(一)
- java多线程(3)- 单例设计模式
- BZOJ3524 [Poi2014]Couriers