using UnityEngine; using UnityEngine.UI; using System; using System.Collections; using System.Collections.Generic; using System.Net.WebSockets; using DarkTonic.MasterAudio; using TMPro; using TruegearSdk; using Unity.XR.PXR; using UnityEngine.XR.Interaction.Toolkit; public class GameInit : MonoBehaviour { public static GameInit Ins { get; private set; } public Camera playerCam; public Transform leftHand; public Transform rightHand; public TruegearAndroidConnector androidConnector; public Transform[] allBossPos; [NonSerialized] public GameObject HitUI; [NonSerialized] public GameObject DieUI; [NonSerialized] public TMP_Text dieTxt; /// /// 游戏场地 /// public GamePlace gamePlace; [NonSerialized] public Player self; private void Awake() { Ins = this; Application.targetFrameRate = 60; #if !UNITY_EDITOR && UNITY_ANDROID && PICO PXR_MixedReality.EnableVideoSeeThrough(true); #endif } public void CloseLine() { // leftHand.GetComponent().enabled = false; // rightHand.GetComponent().enabled = false; } private void Start() { CloseLine(); } private void Update() { if (Input.GetKeyDown(KeyCode.Space)) { //GameManager.Ins.CreateEnemy(0, Vector3.zero,Vector3.zero); } } public void PlayAudio(string audioName, Transform tran,bool isAllStop,Action cb=null) { StartCoroutine(PlayAudioTro(audioName, tran, isAllStop, cb)); } public IEnumerator PlayAudioTro(string audioName, Transform tran,bool isAllStop,Action cb=null) { if(isAllStop) MasterAudio.StopAllSoundsOfTransform(tran); if (audioName != "") { MasterAudio.PlaySound3DAtTransform(audioName, tran); MasterAudioGroup audioGroup = MasterAudio.GrabGroup(audioName); if (cb != null) { while (audioGroup.ActiveVoices>0) { yield return new WaitForSeconds(1f); } cb?.Invoke(); } } } }