/// <summary> /// Executed everytime the gameobject is selected /// </summary> public void OnEnable() { OVRInitController ovrInitController = (OVRInitController)target; if (!ovrInitController.IsInitialized) { #if !ENABLE_VUFORIA_OCULUS_INTEGRATION // if the OVR SDK is present, set the scripting define to enable integration if (CheckOVRSDK()) { AddIntegrationScriptingDefine(INTEGRATION_DEFINE); } else { // the OVR SDK was not detected - do not attempt to add everything automatically again. // an error will be shown in the inspector instead. ovrInitController.SetInitialized(); } #else // automatically add OVR scripts if they are not set up yet: if (!OVRSupportAdded(ovrInitController.gameObject)) { AddOVRSupport(ovrInitController.gameObject); } // initialization finished. ovrInitController.SetInitialized(); #endif } }
/// <summary> /// draws the inspector for the component /// </summary> public override void OnInspectorGUI() { #if !ENABLE_VUFORIA_OCULUS_INTEGRATION if (CheckOVRSDK()) { AddIntegrationScriptingDefine(INTEGRATION_DEFINE); } else { // the OVR SDK was not detected - show an error EditorGUILayout.HelpBox("Please import the Oculus SDK into your project to enable automatic integration with Vuforia. " + "Please see the developer library for more information: developer.vuforia.com", MessageType.Error); } #else OVRInitController ovrInitController = (OVRInitController)target; if (OVRSupportAdded(ovrInitController.gameObject)) { EditorGUILayout.HelpBox("Oculus integration is correctly set up.", MessageType.None); if (GUILayout.Button("Remove OVR scripts from ARCamera")) { RemoveOVRSupport(ovrInitController.gameObject); } if (GUILayout.Button("Remove this component and OVR scripts from ARCamera")) { RemoveOVRInitController(ovrInitController); } } else { if (GUILayout.Button("Add OVR scripts to ARCamera")) { AddOVRSupport(ovrInitController.gameObject); } if (GUILayout.Button("Remove this component from ARCamera")) { RemoveOVRInitController(ovrInitController); } } #endif }
/// <summary> /// Removes OVRInitController, any OVR scripts on the ARCamera and /// the script define to enalbe OVR support. /// </summary> /// <param name="ovrInitController"></param> private static void RemoveOVRInitController(OVRInitController ovrInitController) { RemoveOVRSupport(ovrInitController.gameObject); Undo.DestroyObjectImmediate(ovrInitController); }