Unity3D C#打開外部應用程序,並檢測應用程序是否關閉退出


歡迎來到unity學習unity培訓、unity企業培訓教育專區,這里有很多U3D資源U3D培訓視頻U3D教程U3D常見問題U3D項目源碼,我們致力於打造業內unity3d培訓、學習第一品牌。

 

Unity3D C#打開外部應用程序,並檢測應用程序是否關閉退出實現代碼。

using UnityEngine;

using System.Collections;

using System.Diagnostics;

using System;

 

public class StartOtherApp : MonoBehaviour {

 

         private Process pc;

         void Start () {

                   StartCoroutine(StartApp());

         }

 

         IEnumerator StartApp()

         {

                   yield return new WaitForSeconds(2);

                   pc = Process.Start("C:/Users/Lee/Desktop/Flash VideoPlayer/VRPlayer/VRPlayer.app/VRPlayer.exe");

 

                   pc.EnableRaisingEvents = true;

                   pc.Exited += new EventHandler(myProcess_Exited);

         }

 

         void myProcess_Exited(object sender, EventArgs e)

         {

                   Application.Quit();

         }

}

 

Unity3D 關於運動的代碼

 

 

運動相關一般要寫在update中,實際開發中,需要分清楚哪些是需要每frame都檢測的,哪些是觸發的。

 

input下面的類一般要寫在update中,因為每個frame都需要檢測。

OnTriggerEnter();OnTriggerStay;OnTriggerExit;與之對應的是OnCollisionEnter....,如果勾選了IsTrigger則需要Trigger類。

可以用於運動的函數。我們應該更具具體的情況選擇合適的函數。

 

rigidbody(2D)velocity,

//向某個方向移動

velocity=transform.TransformDirection(Vector3.forward*100);

 

transform.translate,

//向某個方向移動

playerTransform.Translate(Vector3.right*Time.deltaTime*(-moveSpeed.x));

 

vector3.movetowards,

//移動到目標點

playerTransform.position=Vector3.MoveTowards(playerTransform.position,tagerpoint.position,200*Time.deltaTime);

 

也可以直接操作transform.position

 

 

 

 

 

更多精彩請點擊 http://www.gopedu.com/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM