日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Unity 项目HTCvive中 PPT播放的实现

發布時間:2023/12/29 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Unity 项目HTCvive中 PPT播放的实现 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

設置一個canvas面板,用來存放之后需要觸發的ui組件。

ppt是通過image圖片的改變來實現的。

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;public class RoomPanelButtons : MonoBehaviour {public Text intro;public RoomPanelPanels panels;public void OnEnterButton(string content){intro.text = content;}public void OnExitButton(){intro.text = "";}public void Disable(){gameObject.SetActive (false);}public void Show(int panel){panels.gameObject.SetActive (true);panels.Show (panel);GetComponent<Animator> ().SetTrigger ("CLOSE");} }

設置幾個方法,分別用于button的出發,圖片點擊的觸發。



在射線進入button,點擊button,退出button的時候,分別調用各個方法。

在射線照到指到的時候 執行OnEnterButtor,將text設置為制定的字,射線離開時,執行OnExitButtor,將text至為空。

當點擊時,執行show方法,通過設定的變量panel,來決定將哪個panel面板設為setactive。


using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;public class PPT : MonoBehaviour {public Sprite[] ppts;public Image img;private int _current;public int Current {set{_current = value;img.sprite = ppts [value];}get{return _current;}}void Start(){Current = 0;}public void Next(){if (Current == ppts.Length - 1) {Current = 0;} else {Current++;}}}

設定一個sprite精靈體的數組,用來存ppt圖片,在panel下面設定一個image子物體,當在image上面點擊觸發,執行next方法,每次點擊的時候,遞加current值,當current值到數組的長度-1時,即數組中最后一張圖片時,將其至為0,從頭開始循環。

為了避免在外部修改current數值并且設置為public屬性,在外部函數中可以調用到,使用了set get這種函數形式,通過private的變量值為current賦值。

最后,當點擊close圖片的時候,執行close方法,將所在的面板setactive設置為false。

總結

以上是生活随笔為你收集整理的Unity 项目HTCvive中 PPT播放的实现的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。