cmdr2 Posted January 12, 2019 Share Posted January 12, 2019 Hi, I'm looking for a way to hide the controller model at runtime, since I need to show the controller only during parts of the game. I'm using the Unity SDK. Presently what works for me (but I'm not sure if this is the correct, future-proof way): 1. Store the Controller's GameObject provided by the CONTROLLER_MODEL_LOADED event: WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.CONTROLLER_MODEL_LOADED, onControllerLoadedEvent); 2. Keep setting that controllerGameObject.SetActive to false in an Update(), since it seems to become active a few frames after the event callback above. I verified that the controller's orientation data continues to be reported correctly, even when the controller's gameObject is hidden. I was curious to know if there's a better way to do this. Thanks! ~cmdr2 Link to comment Share on other sites More sharing options...
Tony PH Lin Posted January 16, 2019 Share Posted January 16, 2019 Hi , Yes, this is a correct way and easiest way. We also provide alternative way for your reference. Assuming listening to CONTROLLER_MODEL_LOADED : void OnEnable() { WaveVR_Utils.Event.Listen (WaveVR_Utils.Event.CONTROLLER_MODEL_LOADED, OnControllerLoaded); } // In SDK 2.1.8 private GameObject loadedController_R = null, loadedController_L; void OnControllerLoaded(params object[] args) { WVR_DeviceType _type = (WVR_DeviceType)args [0]; if (_type == WVR_DeviceType.WVR_DeviceType_Controller_Right) this.loadedController_R = (GameObject)args [1]; if (_type == WVR_DeviceType.WVR_DeviceType_Controller_Left) this.loadedController_L = (GameObject)args [1]; } Then you can call ShowControllerModels (bool) to show / hide controller models. // True to show, false to hide controller models. private void ShowControllerModels(bool show) { int _children_count = this.loadedController_R.transform.childCount; for (int i = 0; i < _children_count; i++) { this.loadedController_R.transform.GetChild (i).gameObject.SetActive (show); } _children_count = this.loadedController_L.transform.childCount; for (int i = 0; i < _children_count; i++) { this.loadedController_L.transform.GetChild (i).gameObject.SetActive (show); } } Hope this is helpful. Thanks. Link to comment Share on other sites More sharing options...
cmdr2 Posted January 22, 2019 Author Share Posted January 22, 2019 Thanks for your help! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.