VR AR === ###### tags: `school` # 期末考 富緯好帥 一個主圖加一個按鈕 按鈕連結要按,然後去該連結 [20191225-3:](https://youtu.be/RWy14Q9UnNU)時間戳記往下翻 會給程式碼 一開畫面人出來(從小變大)魔法陣迴轉 [20191218-2:](https://youtu.be/q6Kt4xe_H5I)時間戳記往下翻 有音樂 [20191225-2:](https://youtu.be/A6C1Svk-LUU) 按下按鈕,有解釋出來 [20191225-1:](https://youtu.be/Lw0Yq57vfhk) 另一張按Youtube去Youtube [20191225-3:](https://youtu.be/RWy14Q9UnNU)時間戳記往下翻 魔法陣旋轉,人放大,線性 [20191218-2:](https://youtu.be/q6Kt4xe_H5I)時間戳記往下翻 # 2019/11/13(e) [20191113-1:](https://youtu.be/py6hqJJilKc?t=1740) 影片前半只在看影片,所以不重要。 步驟只是個提醒,詳細還是看影片或許會比較快,時間做個方便告知 2017的版本喔~ - 29:00 - build setting -> android -> switch platform :這個動作再說將平台轉換到android - project setting -> player -> XR Settings的Vuforia Augmented Realit(影片模糊大概差不多好像是這些單字) -> 跳出個選項按accept - 記得要把main camera給刪掉喔 然後加入Vuforia的camera create->Vuforia ->AR camera - 33:40~33:50 - 角色上色的部分 - 36:50 - 開始講述如何Vuforia的操作過程 - AR Camera ->Open Vuforia configuration ->Add License(Vuforia的連結) - 42:45 - 在說明出現一個warning(Android TV) 解決方法 player setting->other settings的android TV Compatibility - 然後記得把角色丟到imagetarget底下,不然不會動 ==這個影片目前沒解決無法出現的問題== > 這邊是不是怪怪的 > 這個我也不知道捏 20191113-1: 要在android上執行 步驟請從2:45開始看 這部影片都是在用android的問題 這個感覺不用特別在意的感覺? # 2019/11/20(e) 4個圖片的 [20191120-1(聲音差評):](https://www.youtube.com/watch?time_continue=3&v=NB-n8_Txq2U&feature=emb_title) - 07:30 - 將game的長寬比換為16:10Portrait(10:16) <-這個不是時間喔 是長寬比 - 10:00 - 在做4個圖片的配置,然後把他們擺到scene裡面,然後就一連串的動作,建議看影片比較快 [20191120-2:](https://www.youtube.com/watch?v=AatONpPQDog&feature=emb_title) - 00:00 - 影片一開始就在設置了 設置左右按鈕的配置(不是button喔),調整好位置後,替物件加入MeshCollider - 07:40 - 設置聲音 步驟:在scene新增 Audio->Audio Source - 9:40 - 新增一個TSM 步驟:新增一個空物件(create empty,改名叫TSM)->新增 Trackable status Manager(Script) - 16:00 - 新增了scene manager 步驟看影片比較快 [20191120-3:](https://www.youtube.com/watch?v=KNrZfDoFDZg&feature=emb_title) 步驟還蠻多的 自己看影片比較實在點 我幫忙標時間 - 00:28 - 對TSM新增collider - 01:41 - 對Manager新增collider - 08:25 - 對左右按鈕新增collider # 2019/11/27(e) 家具日 他用2019做的 所以我不確定要不要標記東西 有要標記的話說一下 [20191127-1:](https://www.youtube.com/watch?v=8WFv_I_MSnA&feature=emb_title) 我沒看到重點 = = [20191127-2:](https://www.youtube.com/watch?v=Pj-sTf1sxIQ&feature=emb_title) - 19:40 - 虛擬按鈕 - 20:57 - 虛擬按鈕的材質 [20191127-3:](https://www.youtube.com/watch?v=4SZCGIClNCk&feature=emb_title) - 7:10 - Script如有發生問題 解決bug方式 - 9:15 - 開始製作左右UI按鈕 # 2019/12/04(e) 也是用2019做的 [20191204-1:](https://www.youtube.com/watch?v=dKfkcn0jE5I&feature=emb_title) [20191204-2:](https://youtu.be/-Rwdr5dhD2k) # 2019/12/11 終於肯用2017了 [20191211-1:](https://youtu.be/4WD0pbTlgd0) 先下載好Business Card - 08:30 - ==vuforia設定== - vuforia target 新增 - vuforia網站 -> Target Manager -> Add Database - 09:44 - ==Unity vuforia設定== - File -> Build Setting -> Android -> Switch Platform - Player Setting -> XR setting -> Vuforia Augmented Realit -> 打勾 - 13:15 - 把剛剛從vuforia下載的東西匯入 - 15:20 - 把Camera換成AR Camera - Main Camera刪除 - Hierachy -> 右鍵 -> Vuforia -> AR Camera - 17:08 - ==載入圖片== - AR Camera -> Vuforia Behaviour -> Open Vuforia Configuration - Add Licence -> 複製貼回來 - Databases -> Load 你的名字 Database -> 打勾 -> Activate -> 打勾 [20191211-2:](https://youtu.be/w_fkHXter9s) - 01:15 - ==名片設定== - Hierachy -> 右鍵 -> Vuforia -> Image (兩次) - 分別取名 Target_Front 、 Target_Back - Target_Front -> Image Target Behaviour -> Database -> 你的名字 (Back也一樣) - Target_Front -> Image Target Behaviour -> Image Target -> Card1 - Target_Front -> Image Target Behaviour -> Image Target -> Card2 - 05:30 - 把Audio、FBX、Image、Script、Video摳進Assets -> Go Ahead - 06:50 - Image資料夾內全選 -> Texture Type -> Sprite (2D And GUI) - 11:30 - 把FBX內的模型設成Legacy之後拉進Target_Front裡面 - 13:23 - 把Animation丟進去 - 16:25 - ==魔法陣== - 創造Plane取名Magic,拖進Target_Front裡 - 創造一個Meterial - Shader -> Particles -> Addtive - Particle Texture選擇Magic [20191211-3:](https://youtu.be/qRgZ3SgaStw) - 00:45 - 滾動文字 - 創建一個Panel取名 Introdution_Panel - Canvas -> Canvas Scaler -> X:1920 Y:1080 - 創建一個Text取名 Introdution_Text 並將它拖到Introdution_Panel底下 - Introdution_Text -> Inspertor - 物件靠上對齊 - Pivot Y: 1 - Pos Y: -160 - Height: 625 - Text內容複製貼上 - 文字上下置中 - 在Introdution_Panel底下創建Image取名 Introdution_Mask - 把Introdution_Text拉到Introdution_Mask底下 - Introdution_Mask -> Inspertor - Width: 660 - Height: 200 - Add Component -> Mask - Image -> Color -> A:1 - Introdution_Text -> Inspertor -> Pos Y: 0 # 2019/12/18 [20191218-1:](https://youtu.be/KL4nNOzZf3s) - 00:15 - 新增3個 UI-> button 分別取名 SoundOpen_btn,SoundClose_btn,PlaneClose_btn - 01:45 - 對SoundOpen_btn,SoundClose_btn,PlaneClose_btn 設定圖示 Image(Script) 的 SourceImage 分別改為他們所要的圖示 - 對SoundOpen_btn,SoundClose_btn 的 Button(Script) 的 Transition 改為 Sprite Swap - 對PlaneClose_btn 的 Button(Script) 的 Transition 改為 None - 要改它們的位置喔 影片都有說 - 13:10 - 新增 UI -> Button 取名 Introduction_btn - 設定位置 - 17:00 - 新增3個 UI -> Button 取名 MoviePlay_btn,Youtube_btn,FB_btn - 步驟跟上面01:45雷同 - 位置請參照影片所述 [20191218-2:](https://youtu.be/q6Kt4xe_H5I) - 00:50 這邊開始是人物的大小縮放 - 開始製作人物放大的動畫 - 新增一個空物件 create Empty 取名叫 LearnGo - 放在Target_Front底下 -> reset position - 再把再把LearnGo_wave變成他的子物件 - 03:18 - 對LearnGo 新增 Animation - window -> Animation -> create -> LearnGo.anim(取名取看得懂的,分辨得出來的) - 錄製打開(紅色那顆) -> Add Property -> Transform -> Scale + - 在0.00的地方更改他們的大小 scale.x,scale.y,scale.z 更改為0 - 這樣就有放大的效果囉 - 06:22 - 透過按下按鈕讓動畫產生(我感覺的意思是這樣啦 - 在LearnGo的amimator 新增 一個empty create state -> empty - 更改線的連接 entry連到new state 在New State -> Set as layer default state - 08:12 - New State 右鍵 Make Transition 到 LearnGo - 在左邊的Parameter新增Bool,取名叫Open - 再新增一個Bool,名為Close 大小寫多少注意一下 - 在New State與 LearnGo之間的線做設定 - 把Has Exit Time 關掉 - 下面的condition 新增(按+) Open true - 12:33 - 有說明F鍵能幹嘛 (考試不會考F鍵喔,只是看你會不會用到罷了 - LearnGo 右鍵 Make Transition 到 Exit - 針對他們的線去設定 Has Exit Time 關掉 - 下面的condition 新增(按+) Close true - 14:30 現在開始是魔法陣的喔 - 對Image(魔法陣的名字) 新增Animation - window -> Animation -> create -> Magic.anim(取名取看得懂的,分辨得出來的) - 錄製打開(紅色那顆) -> Add Property -> Transform -> Rotation + - 針對 Rotation y 去做更改 在0.00的地方設為0 後面的地方設置為359 - 20:42 線性的部分囉 就是曲線改為直線喔 - 在animation 下面有個 C啥啥ves的咚咚 進去裡面修改 (我看影片看不清楚他叫甚麼 - 再LearnGo的animation 去修改 到 C啥啥ves的咚咚 這個時間他調整的是角色的,魔法陣的在下禮拜的第一個影片 - 在曲線的兩個端點 分別按右鍵 ->Both Tangents -> Linear # 2019/12/25 [20191225-1:](https://youtu.be/Lw0Yq57vfhk) - 01:50 - 更改Magic(魔法陣的名字)的animation 的 C啥啥ves的咚咚 - 跟上次一樣的方式去進行修改 - 在曲線的兩個端點 分別按右鍵 ->Both Tangents -> Linear - 10:00 - 文字的動畫 - Introduction_Text 的 animation - window -> Animation -> create -> Introductino_Open.anim(取名取看得懂的,分辨得出來的) - 錄製打開(紅色那顆) -> Add Property -> Rect Transition -> Anchored Position - 這邊的步驟跟前面差不多 只是細節看影片 也要去調整線性 - 19:35 - 開啟Introduction_Open的animator - 新增 一個empty create state -> empty - entry連到new state 在New State -> Set as layer default state - New State 右鍵 Make Transition 到 Introduction_Open - 在左邊的Parameter新增Bool,取名叫Open - new state 與 Introduction_Open 的 線 Has Exit Time 關掉 - 下面的condition 新增(按+) Open true - Introduction_Open 與 exit 之間的線 Has Exit Time 關掉 [20191225-2:](https://youtu.be/A6C1Svk-LUU) - 00:25 - 新增一個Audio Source create -> Audio -> Audio Source 取名叫AudioPlayer - Play On Awake關掉 - 複製AudioPlayer 改名叫 SoundEffectPlayer - 03:55 - 新增一個空物件 create - > create Empty 取名叫 TSM_front - 座標歸零 - 加入一個Script Trackable status Manager(Script) Add Component -> Trackable status Manager(Script) - Target_Front拉過去到裏頭的Target - 新增一個空物件 create - > create Empty 取名叫 TSM_back - 座標歸零 - 加入一個Script Trackable status Manager(Script) Add Component -> Trackable status Manager(Script) - Target_Back拉過去到裏頭的Target - 10:55 - 新增一個空物件 create - > create Empty 取名叫 Manager - 加入一個Script UI Manager(Script) Add Component -> UI Manager - 在script上設定 這個好多 你看影片吧 - 17:41 - 在Manager新增一個 Audio Manager(Script) Add Component -> Audio Manager - 裏頭細節麻煩看一下影片吧 - 20:29~20:35 - 有在Manager的UI Manager 中的AM放入Manager本身喔 提醒一下 - 20:48 - TSM_front 新增一個 AudioPlayer(Script) Add Component -> AudioPlayer - 細節依舊看影片 - 24:45 - 在Introduction_btn 新增事件 - 詳情請觀看影片 - 38:00 - 在SoundOpen_btn 新增事件 - 在SoundClose_btn 新增事件 - 在PlaneClose_btn 新增事件 - 上述詳情請觀看影片 [20191225-3:](https://youtu.be/RWy14Q9UnNU) - 00:20 - SoundOpen_Btn,SoundClose_Btn 做設定 - 設定內容請參照影片 - 記得SoundClose_Btn 記得把Image的勾勾拿掉,讓他預設為不顯示 - 07:30 - 對Introduction_Btn 新增一個Script Single UI Switch(Script) Add Component -> Single UI Switch - 再把TSM_front拉到Script Single UI Switch 的 TSM - 接著再對Introduction_Btn 再新增一個新的事件 - 設定哪些看影片吧 - 11:00 - 再對PlaneClose_Btn 新增事件 - 細節依舊看影片 - 12:33 - 對TSM_front 新增一個 Animation Manager - 內容設定參照影片 - 15:38 - unity 影片不能直接放在assests/video裡面 - 要放在StreamingAssests裡面喔 - 看影片步驟最清楚了 - 16:50 - 對Manager新增一個Script Video Manager(Script) Add Component -> Video Manager - 然後就細節看影片 - 19:45 - 對MoviePlay_Btn加事件 - 細節看影片 - MoviePlay_Btn 新增一個Script Single UI Switch(Script) Add Component -> Single UI Switch - 這個的TSM是選TSM_back喔 - 24:23 - Youtube_btn 新增一個Script Single UI Switch(Script) Add Component -> Single UI Switch - TSM選的是TSM_back - Youtube_btn 新增一個Script Open Url(Script) Add Component -> Open Url - 再URL上 貼上一個Youtube連結 - Youtube_btn 新增事件 - 設定看影片 - 25:40 - FB_btn 的做法跟 Youtube_btn 差不多 - 後面就沒什麼東西的樣子了 C# === ## C# 場景轉換 ```csharp= using UnityEngine.SceneManagement; public void Start_button(){ SceneManager.LoadScene("Scene Name"); } ``` ## C# 人物前進後退 ```csharp= using System.Collections; using System.Collections.Generic; using UnityEngine; public class BoyControl : MonoBehaviour { public float speed = 10f; // Use this for initialization void Start () { } // Update is called once per frame void Update () { float hDistance = speed * Time.deltaTime * Input.GetAxis("Horizontal"); float vDistance = speed * Time.deltaTime * Input.GetAxis("Vertical"); transform.Translate (Vector3.right * hDistance, Space.World); transform.Translate (Vector3.forward * vDistance, Space.Self); } } ``` ## C# 點button圖片變換(Image、RawImage) ```csharp= using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class BtnClick : MonoBehaviour { private int iTime = 0; public Button pressButton; public Text textButton; public Text ValueText; private bool bShow = false; public Image Image1; public RawImage Image2; public Sprite ImageFor11; public Sprite ImageFor12; public Sprite ImageFor13; public Sprite ImageFor14; private Sprite[] imagesAry = new Sprite[4]; public Texture ImageFor2; // Use this for initialization void Start () { textButton = pressButton.GetComponentsInChildren<Transform> () [1].GetComponent<Text> (); textButton.text = "Show"; imagesAry [0] = ImageFor11; imagesAry [1] = ImageFor12; imagesAry [2] = ImageFor13; imagesAry [3] = ImageFor14; } // Update is called once per frame void Update () { } public void ButtonClick(){ ValueText.text = (++iTime).ToString(); if (bShow) { // Image1.sprite = null; Image2.texture = null; textButton.text = "Show"; } else { // Image1.sprite = ImageFor11; Image2.texture = ImageFor2; textButton.text = "Hide"; } bShow = !bShow; Image1.sprite = imagesAry [(iTime - 1) % 4 ]; // switch ((iTime-1) % 4) { // case 0: // Image1.sprite = ImageFor11; // break; // case 1: // Image1.sprite = ImageFor12; // break; // case 2: // Image1.sprite = ImageFor13; // break; // case 3: // Image1.sprite = ImageFor14; // break; // } } } ``` # Dark Theme CSS {%hackmd theme-dark %}