using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class c2 : MonoBehaviour
{// 定時器float t1 = 0;void Start(){// 向量Vector3 v1 = new Vector3(0, 0, 2);Vector3 v2 = new Vector3(0, 0, 3);// 計算兩個向量的夾角Debug.Log(Vector3.Angle(v1, v2));// 計算向量的模Debug.Log(v2.magnitude);// 兩點之間的距離 (計算v1、v2 兩個點之間的距離) Debug.Log(Vector3.Distance(v1, v2));// 計算過程時,參數1 + (參數2 - 參數1)* 參數3// 插值 (0,0,0) (0,0,1) (0.1f) = 過程:0+ ((1-0)*0.1) = (0,0,0.1)// 插值 (0,0,2) (0,0,2) (0.2f) = 過程:2+((2-2)*0.2) = (0,0,0.2)// 插值 (0,0,2) (0,0,2) (0.2f) = 過程:2+((2-2)*0.2) = (0,0,0.2)// 插值 (3,6,1) (9,5,2) (0.1f) =// 過程:3+ ((9-3)*0.1) = 3.6// 過程:6+ ((5-6)*0.1) = 5.9// 過程:1+ ((2-1)*0.1) = 1.1// 結果:(3.6,5.9,1.1)Debug.Log(Vector3.Lerp(new Vector3(3,6,1), new Vector3(9,5,2),0.1f));// 歐拉角 x y z// 四元數 x y z w// 歐拉角Vector3 rotate = new Vector3(60, 50, 0);// 四元數Quaternion quaternion = Quaternion.identity;// 歐拉角 轉 四元數quaternion = Quaternion.Euler(rotate);Debug.Log("歐拉角 轉 四元數");Debug.Log(quaternion);// 四元數 轉 歐拉角Debug.Log("四元數 轉 歐拉角");Debug.Log(quaternion.eulerAngles);// 這是一個朝向敵人的向量Vector3 dir = Vector3.left;// 獲得一個朝向這個向量的旋轉quaternion = Quaternion.LookRotation(dir);// 輸出文本Debug.Log("輸出文本");// 輸出警告Debug.LogWarning("輸出警告");// 輸出錯誤// Debug.LogError("輸出錯誤");// 時間相關// 游戲開始到現在所用時間// Debug.Log(Time.time);// 在編輯中-》項目設置-》時間:(時間尺度、固定時間步進)// 時間尺度:時間縮放數值Debug.Log(Time.timeScale);// 修改 時間尺度 (增加重量組件可以看效果)// Time.timeScale = 0.1f;// 固定時間步進:固定時間間隔Debug.Log(Time.fixedDeltaTime);// 路徑相關// 找到 Assets 路徑下的 某文件 (可讀 某些不可寫)若PC端可讀可寫Debug.Log(Application.dataPath + "/test.txt");// 持久化路徑 可讀可寫 默認C盤Debug.Log(Application.persistentDataPath);// 在Asset文件下的 StreamingAssrts 文件夾內的文件 不會被加密(適合放配置文件)// 找到 在Asset文件下的 StreamingAssrts路徑Debug.Log(Application.streamingAssetsPath);// 在Asset文件下的 Resources 文件夾內的文件 加載比較方便// 找到 臨時文件 路徑Debug.Log(Application.temporaryCachePath);// 判斷是否 后臺運行Debug.Log(Application.runInBackground);// 打開一個網址// Application.OpenURL("http://baidu.com");// 退出 (好像有問題,后面再嘗試一下)// Application.Quit();}// Update is called once per framevoid Update(){// 幀之間的間隔時間(跟硬件相關)// Debug.Log(Time.deltaTime);// 計時器t1 += Time.deltaTime;if (t1 >= 5){Debug.Log("5秒到了");t1 = 0;}}
}