void AddVRReticle() { reticle = Camera.main.GetComponentInChildren <VRReticle>(true); if (null == reticle) { reticle = UITools.AddChild <VRReticle>(Camera.main.gameObject, VRRes.Load <GameObject>(R.Prefab.VRReticle)); } }
public EditorVRViewer() { var viewer = UITools.AddChild(null, (GameObject)VRRes.Load <GameObject>(R.Prefab.EditorVRViewer)); viewer.AddComponent <ViewerMonoBehaviour>().UpdateHandler = Update; viewer.name = "VRViewer"; GameObject.DontDestroyOnLoad(viewer); Reticle = viewer.GetComponentInChildren <VRReticle>(); Head.gameObject.AddComponent <PhysicsRaycaster>(); }
public static ITransition CreateTransition <T>() where T : ITransition { ITransition transition = null; if (typeof(T) == typeof(TransitionFade)) { var o = VRRes.Load <GameObject>(R.Prefab.Fade); var newOne = GameObject.Instantiate(o); transition = newOne.GetComponent <TransitionFade>(); } return(transition); }
protected void CreateUIRoot() { uiRoot = FindObjectOfType <UIManager>(); if (null == UIRoot) { var obj = (GameObject)Instantiate(VRRes.Load <GameObject>(R.Prefab.UIManager)); uiRoot = obj.GetComponent <UIManager>(); } if (uiRoot.Canvas.worldCamera == null) { uiRoot.Canvas.worldCamera = Camera.main; } uiRoot.name = "UIRoot"; }
public override void OnInitialize() { var prefab = VRRes.Load <GameObject>(R.Prefab.GlobalUIRoot); root = gameObject.AddChild <Canvas>(prefab); root.sortingLayerName = VRSortingLayer.GlobalUI; root.worldCamera = Camera.main; mask = root.GetComponentInChildren <GlobalMask>(); mask.Hide(); panel = root.GetComponentInChildren <GlobalPanel>(); panel.ok = OnClickOK; panel.cancel = OnClickCancel; panel.Hide(true); }
public SceneConfig(string name) { var textAsset = VRRes.Load <TextAsset>(string.Format("Config/Scenes/{0}", name)); if (null != textAsset && !string.IsNullOrEmpty(textAsset.text)) { try { data = JsonMapper.ToObject(textAsset.text); } catch (Exception) { Debug.LogErrorFormat("[SceneConfig] read config of scene: {0} error", name); } } }
public static ITransition CreateTransition(string path) { ITransition transition = null; switch (path) { case FadeTransition: GameObject o = VRRes.Load <GameObject>(R.Prefab.Fade); GameObject newOne = GameObject.Instantiate(o); transition = newOne.GetComponent <TransitionFade>(); break; default: break; } return(transition); }
public override void OnInitialize() { #if APP_LUANCHER || APP_LITE_LAUNCHER || APP_MANAGER if (Application.isEditor && FirstScene == UnityEngine.SceneManagement.SceneManager.GetActiveScene().name) { VRApplication.VRPlatform = VRPlatform.Editor; Viewer = new EditorVRViewer(); Controller = new EditorVRController(); } else if (Viewer == null || Controller == null) { VRApplication.VRPlatform = VRPlatform.Launcher; Viewer = new LauncherViewer(); Controller = new LauncherController(); Debug.LogWarning("VRPlatform is Launcher!"); } #elif Cardboard VRApplication.VRPlatform = VRPlatform.Cardboard; Viewer = new CardboardViewer(); Controller = new CardboardController(); Debug.Log("VRPlatform is Cardboard"); #else VRApplication.VRPlatform = VRPlatform.Editor; Viewer = new EditorVRViewer(); Controller = new EditorVRController(); #endif GameObject o = gameObject.AddChild(VRRes.Load <GameObject>(R.Prefab.VRUserControl)); UserCtrl = o.GetComponent <VRUserControl>(); UserCtrl.SetResetActive(false); UserCtrl.SetReturnActive(false); UserCtrl.returnAction = () => { if (Controller != null) { Controller.OnClickBack(); } }; UserCtrl.resetAction = () => { if (Viewer != null) { Viewer.Recent(); } }; }
protected static void Initialize() { var textAsset = VRRes.Load <TextAsset>(AppName); if (textAsset) { var json = JsonMapper.ToObject(textAsset.text); Version = json["version"].ToString(); Revision = json["revision"].ToString(); BuildTime = json["build"].ToString(); } else { Version = Application.version; Revision = "unknown"; BuildTime = "unknown"; } //初始化语言 Localization.Language = Localization.PlayerPref; }
public override void OnInitialize() { root = gameObject.AddChild <Canvas>(VRRes.Load <GameObject>(R.Prefab.VRLog)); root.sortingLayerName = VRSortingLayer.Log; root.worldCamera = Camera.main; text = root.GetComponentInChildren <Text>(true); clear = root.GetComponentInChildren <Button>(true); if (clear) { clear.onClick.AddListener(Clear); } var frameRateTran = root.transform.FindChildRecursively("FrameRate"); if (frameRateTran) { frameDiagnosis = frameRateTran.GetComponent <Text>(); } scroll = root.GetComponentInChildren <ScrollRect>(true); logTexts = new ScrollItemPool <Text>(scroll.content.gameObject, text, 1); PrintAppInfo(); Application.logMessageReceived += LogMessageReceived; }
public static GameObject GetPrefab <T>() where T : UIWindow { return(VRRes.Load <GameObject>(UIResource.Paths[typeof(T)])); }