试了一下用一个按钮实现两个摄像头的相互切换(*o*)~~
很简单的,就不详细写啦~
下面是对应的脚本文件:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ChangeCamera_1 : MonoBehaviour {
private GameObject Camera_0;
private GameObject Camera_1;
void Start () {
Camera_0 = GameObject.Find ("Main Camera");
Camera_1 = GameObject.Find ("Camera_1");
}
bool a=true;
public void OnClick()//两个摄像头相互转换
{
if (a) {
a = false;
Camera_0.SetActive (false);
Camera_1.SetActive (true);
} else {
a = true;
Camera_0.SetActive (true);
Camera_1.SetActive (false);
}
}
说在后面
最近又开始接触Unity的UI部分了,累~~ 感觉知识很不够,陆续应该还会又相应的小教程出来的,对自己说一句加油!!!