/// <summary> /// An easy way to find the current HardlightSuit in the scene (this becomes trickier if you have multiple suits in play at once IE a networking situation) /// It will initialized the VRMimic if it is not yet initialized. /// </summary> /// <returns></returns> public static HardlightSuit Find() { HardlightSuit suit = FindObjectOfType <HardlightSuit>(); if (suit != null) { suit.Init(); return(suit); } if (VRMimic.ValidInstance()) { suit = FindObjectOfType <HardlightSuit>(); if (suit != null) { suit.Init(); return(suit); } } else { Debug.Log("Attempted to run HardlightSuit.Find() before calling VRMimic.Initialize()\nMust run VRMimic Initialize first - so you can configure hiding settings."); } return(null); }
void Awake() { //This sets up a base body. It hands in the camera so the body follows/mimics the likely movements of the user. It also hides the body from the camera (since the body is by default on layer 31) VRMimic.Initialize(targetCamera.gameObject); //Hold onto a reference to the suit. Gives us access to a variety of helper functions. suit = HardlightSuit.Find(); }
/// <summary> /// Initializes and sets up /// </summary> /// <param name="vrCamera"></param> /// <param name="hapticLayer"></param> public static void Initialize(GameObject vrCamera, int hapticLayer = NSManager.HAPTIC_LAYER) { if (ValidInstance()) { Debug.LogError("VRMimic is already initialized\nDoes not yet support multiple initializations"); } else if (vrCamera == null) { Debug.LogError("VRMimic was requested initialization with a null VR Camera\n"); } else { //Debug.Log("VR Camera [" + vrCamera.name + "] for initialization\n"); GameObject singleton = new GameObject(); instance = singleton.AddComponent <VRMimic>(); instance.Init(vrCamera, hapticLayer); singleton.name = "VRMimic [Runtime Singleton]"; } }