using UnityEngine; using System.Collections; using UnityEngine.UI; using UnityEngine.SceneManagement; using System.Diagnostics; /// <summary> /// 脚本挂载在button上
/// 跨场景,单击按钮跳转主场景,此时控制端调用虚拟端。 /// </summary> public class EnterScene : MonoBehaviour { string FileName = ""; /// <summary> /// 目标场景名称 /// </summary> public string SceneName; void Start() { FileName = Application.dataPath + "/" + "GJZY Virtual/" + "GJZY Virtual" + ".exe"; //第一个"GJZY Virtual" 为虚拟文件夹,第二个GJZY Virtual 为虚拟的exe GetComponent<Button>().onClick.AddListener(delegate() { OnButtonClick(); }); EventTriggerListener.Get(CloseBtn.gameObject).onClick = BtnClick; } /// <summary> /// 跳转至目标场景 /// </summary> void OnButtonClick() { Process.Start(FileName); SceneManager.LoadScene("ArchotectureBoilling");//跳转控制的主场景,ArchotectureBoilling为主场景名字 } }