public override void DrawInspectorGUI() { EditorGUILayout.PropertyField(this.mTurnOffWebCam, new GUIContent("Disable Vuforia Play Mode"), new GUILayoutOption[0]); if (!this.mTurnOffWebCam.boolValue) { if (!VuforiaRuntimeUtilities.CheckNativePluginSupport()) { EditorGUILayout.HelpBox("An error occurred while trying to enable Vuforia play mode", MessageType.Error); } int num = 0; string[] deviceNames = this.GetDeviceNames(); for (int i = 0; i < deviceNames.Length; i++) { if (deviceNames[i] != null && deviceNames[i].Equals(this.mDeviceNameSetInEditor.stringValue)) { num = i; } } if (WebCamEditor.sWebCamProfiles == null) { WebCamEditor.sWebCamProfiles = new WebCamProfile(); } if (deviceNames[num].Equals("NO CAMERAS FOUND")) { EditorGUILayout.HelpBox("No camera connected!\nTo run your application using Play Mode, please connect a webcam to your computer.", MessageType.Warning); } else if (!WebCamEditor.sWebCamProfiles.ProfileAvailable(deviceNames[num])) { EditorGUILayout.HelpBox(string.Concat(new string[] { "No webcam profile has been found for your webcam model: '", deviceNames[num], "'.\nA default profile will be used. \n\nWebcam profiles ensure that Play Mode performs well with your webcam. \nYou can create a custom profile for your camera by editing '", Path.Combine(Application.dataPath, "Editor/QCAR/WebcamProfiles/profiles.xml"), "'." }), MessageType.Warning); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.PrefixLabel("Camera Device"); int num2 = EditorGUILayout.Popup(num, deviceNames, new GUILayoutOption[0]); if (num2 != num && !deviceNames[num2].Equals("NO CAMERAS FOUND")) { this.mDeviceNameSetInEditor.stringValue = deviceNames[num2]; } EditorGUILayout.EndHorizontal(); EditorGUILayout.PropertyField(this.mFlipHorizontally, new GUIContent("Flip Horizontally"), new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.HelpBox("Here you can enter the index of the layer that will be used internally for our render to texture functionality. the ARCamera will be configured to not draw this layer.", MessageType.None); EditorGUILayout.PropertyField(this.mRenderTextureLayer, new GUIContent("Render Texture Layer"), new GUILayoutOption[0]); } }
public WebCamImpl(Camera arCamera, Camera backgroundCamera, int renderTextureLayer, string webcamDeviceName, bool flipHorizontally) { if (QCARRuntimeUtilities.IsPlayMode()) { this.mRenderTextureLayer = renderTextureLayer; this.mARCamera = arCamera; this.mOriginalCameraClearFlags = this.mARCamera.clearFlags; this.mARCamera.clearFlags = CameraClearFlags.Depth; this.mBackgroundCameraInstance = backgroundCamera; this.mBgRenderingTexBehaviour = this.mBackgroundCameraInstance.GetComponentInChildren <BGRenderingAbstractBehaviour>(); if (this.mBgRenderingTexBehaviour == null) { Debug.LogError("Instanciated Prefab does not contain VideoTextureBehaviour!"); } else { this.mOriginalCameraCullMask = this.mARCamera.cullingMask; this.mARCamera.cullingMask &= ~(((int)1) << this.mBgRenderingTexBehaviour.gameObject.layer); this.mARCamera.cullingMask &= ~(((int)1) << this.mRenderTextureLayer); WebCamProfile profile = new WebCamProfile(); if (QCARRuntimeUtilities.IsQCAREnabled() && (WebCamTexture.devices.Length > 0)) { bool flag = false; foreach (WebCamDevice device in WebCamTexture.devices) { if (device.name.Equals(webcamDeviceName)) { flag = true; } } if (!flag) { webcamDeviceName = WebCamTexture.devices[0].name; } this.mWebCamProfile = profile.GetProfile(webcamDeviceName); this.mWebCamTexture = new WebCamTexAdaptorImpl(webcamDeviceName, this.mWebCamProfile.RequestedFPS, this.mWebCamProfile.RequestedTextureSize); } else { this.mWebCamProfile = profile.Default; this.mWebCamTexture = new NullWebCamTexAdaptor(this.mWebCamProfile.RequestedFPS, this.mWebCamProfile.RequestedTextureSize); } this.mBgRenderingTexBehaviour.SetFlipHorizontally(flipHorizontally); this.mFlipHorizontally = flipHorizontally; } } }
public WebCamImpl(Camera arCamera, Camera backgroundCamera, int renderTextureLayer, string webcamDeviceName, bool flipHorizontally) { #if UNITY_EDITOR mRenderTextureLayer = renderTextureLayer; // get main camera, set correct clear flags: mARCamera = arCamera; mOriginalCameraClearFlags = mARCamera.clearFlags; mARCamera.clearFlags = CameraClearFlags.Depth; // instanciate BackgroundCamera mBackgroundCameraInstance = backgroundCamera; // make sure the correct prefab has been attached: mBgRenderingTexBehaviour = mBackgroundCameraInstance.GetComponentInChildren <BGRenderingBehaviour>(); if (mBgRenderingTexBehaviour == null) { Debug.LogError("Instanciated Prefab does not contain VideoTextureBehaviour!"); } else { mOriginalCameraCullMask = mARCamera.cullingMask; // set mask to cull away bg rendering behaviour and texture buffer layer mARCamera.cullingMask &= ~(1 << mBgRenderingTexBehaviour.gameObject.layer); mARCamera.cullingMask &= ~(1 << mRenderTextureLayer); // load the webcam profiles WebCamProfile profiles = new WebCamProfile(); if (QCARRuntimeUtilities.IsQCAREnabled() && (WebCamTexture.devices.Length > 0)) { // check if selected web cam shows up in list of available devices: bool selectedWebCamAvailable = false; foreach (WebCamDevice webCamDevice in WebCamTexture.devices) { if (webCamDevice.name.Equals(webcamDeviceName)) { selectedWebCamAvailable = true; } } // if it was not found, default to first available camera if (!selectedWebCamAvailable) { webcamDeviceName = WebCamTexture.devices[0].name; } mWebCamProfile = profiles.GetProfile(webcamDeviceName); // create webcam texture adaptor mWebCamTexture = new WebCamTexAdaptorImpl(webcamDeviceName, mWebCamProfile.RequestedFPS, mWebCamProfile.RequestedTextureSize); } else { // no webcam connected, use default profile and null implementation for webcam mWebCamProfile = profiles.Default; // create null webcam implementation mWebCamTexture = new NullWebCamTexAdaptor(mWebCamProfile.RequestedFPS, mWebCamProfile.RequestedTextureSize); } // override the texture created by the the VideoTextureBehaviour mBgRenderingTexBehaviour.SetFlipHorizontally(flipHorizontally); mFlipHorizontally = flipHorizontally; } #endif }
public WebCamImpl(Camera arCamera, Camera backgroundCamera, int renderTextureLayer, string webcamDeviceName, bool flipHorizontally) { #if UNITY_EDITOR mRenderTextureLayer = renderTextureLayer; // get main camera, set correct clear flags: mARCamera = arCamera; mOriginalCameraClearFlags = mARCamera.clearFlags; mARCamera.clearFlags = CameraClearFlags.Depth; // instanciate BackgroundCamera mBackgroundCameraInstance = backgroundCamera; // make sure the correct prefab has been attached: mBgRenderingTexBehaviour = mBackgroundCameraInstance.GetComponentInChildren<BGRenderingBehaviour>(); if (mBgRenderingTexBehaviour == null) { Debug.LogError("Instanciated Prefab does not contain VideoTextureBehaviour!"); } else { mOriginalCameraCullMask = mARCamera.cullingMask; // set mask to cull away bg rendering behaviour and texture buffer layer mARCamera.cullingMask &= ~(1 << mBgRenderingTexBehaviour.gameObject.layer); mARCamera.cullingMask &= ~(1 << mRenderTextureLayer); // load the webcam profiles WebCamProfile profiles = new WebCamProfile(); if (QCARRuntimeUtilities.IsQCAREnabled() && (WebCamTexture.devices.Length > 0)) { // check if selected web cam shows up in list of available devices: bool selectedWebCamAvailable = false; foreach (WebCamDevice webCamDevice in WebCamTexture.devices) if (webCamDevice.name.Equals(webcamDeviceName)) selectedWebCamAvailable = true; // if it was not found, default to first available camera if (!selectedWebCamAvailable) webcamDeviceName = WebCamTexture.devices[0].name; mWebCamProfile = profiles.GetProfile(webcamDeviceName); // create webcam texture adaptor mWebCamTexture = new WebCamTexAdaptorImpl(webcamDeviceName, mWebCamProfile.RequestedFPS, mWebCamProfile.RequestedTextureSize); } else { // no webcam connected, use default profile and null implementation for webcam mWebCamProfile = profiles.Default; // create null webcam implementation mWebCamTexture = new NullWebCamTexAdaptor(mWebCamProfile.RequestedFPS, mWebCamProfile.RequestedTextureSize); } // override the texture created by the the VideoTextureBehaviour mBgRenderingTexBehaviour.SetFlipHorizontally(flipHorizontally); mFlipHorizontally = flipHorizontally; } #endif }
public override void OnInspectorGUI() { if (!EditorApplication.isPlaying) { WebCamBehaviour webCam = (WebCamBehaviour)target; if (QCARUtilities.GetPrefabType(webCam) != PrefabType.Prefab) { webCam.TurnOffWebCam = EditorGUILayout.Toggle("Don't use for Play Mode", webCam.TurnOffWebCam); if (!webCam.TurnOffWebCam) { // check if play mode is supported by this Unity version: if (!webCam.CheckNativePluginSupport()) { EditorGUILayout.HelpBox("Play Mode requires a Unity Pro license!", MessageType.Warning); } int currentDeviceIndex = 0; string[] deviceNames = GetDeviceNames(); for (int i = 0; i < deviceNames.Length; i++) { if (deviceNames[i] != null) // sometimes this happens during Play Mode startup on Mac { if (deviceNames[i].Equals(webCam.DeviceName)) { currentDeviceIndex = i; } } } // check if there is a device profile for the currently selected webcam if (sWebCamProfiles == null) { sWebCamProfiles = new WebCamProfile(); } string deviceName = deviceNames[currentDeviceIndex]; if (deviceName.Equals(NO_CAMERAS_TEXT)) { EditorGUILayout.HelpBox("No camera connected!\nTo run your application using Play Mode, please connect a webcam to your computer.", MessageType.Warning); } else { if (!sWebCamProfiles.ProfileAvailable(deviceNames[currentDeviceIndex])) { EditorGUILayout.HelpBox("Webcam profile not found!\n" + "Unfortunately there is no profile for your webcam model: '" + deviceNames[currentDeviceIndex] + "'.\n\n" + "The default profile will been used. You can configure a profile yourself by editing '" + Path.Combine(Application.dataPath, "Editor/QCAR/WebcamProfiles/profiles.xml") + "'.", MessageType.Warning); } } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Camera Device"); int newDeviceIndex = EditorGUILayout.Popup(currentDeviceIndex, deviceNames); if ((newDeviceIndex != currentDeviceIndex) && (!deviceNames[newDeviceIndex].Equals(NO_CAMERAS_TEXT))) { webCam.DeviceName = deviceNames[newDeviceIndex]; } EditorGUILayout.EndHorizontal(); webCam.FlipHorizontally = EditorGUILayout.Toggle("Flip Horizontally", webCam.FlipHorizontally); EditorGUILayout.Space(); EditorGUILayout.HelpBox("Here you can enter the index of the layer that will be used internally for our render to texture " + "functionality. the ARCamera will be configured to not draw this layer.", MessageType.None); webCam.RenderTextureLayer = EditorGUILayout.IntField("Render Texture Layer", webCam.RenderTextureLayer); } if (GUI.changed) { EditorUtility.SetDirty(webCam); SceneManager.Instance.SceneUpdated(); } } else { EditorGUILayout.HelpBox("Webcam settings cannot be changed during Play Mode.", MessageType.Info); } } }
public override void OnInspectorGUI() { if (!EditorApplication.isPlaying) { WebCamAbstractBehaviour target = (WebCamAbstractBehaviour)base.target; if (QCARUtilities.GetPrefabType(target) != PrefabType.Prefab) { if (target.BackgroundCameraPrefab == null) { UnityEngine.Object obj2 = AssetDatabase.LoadAssetAtPath("Assets/Qualcomm Augmented Reality/Prefabs/Internal/BackgroundCamera.prefab", typeof(Camera)); if (obj2 != null) { target.BackgroundCameraPrefab = obj2 as Camera; } } target.TurnOffWebCam = EditorGUILayout.Toggle("Don't use for Play Mode", target.TurnOffWebCam, new GUILayoutOption[0]); if (!target.TurnOffWebCam) { if (!target.CheckNativePluginSupport()) { EditorGUILayout.HelpBox("Play Mode requires a Unity Pro license!", MessageType.Warning); } int index = 0; string[] deviceNames = this.GetDeviceNames(); for (int i = 0; i < deviceNames.Length; i++) { if ((deviceNames[i] != null) && deviceNames[i].Equals(target.DeviceName)) { index = i; } } if (sWebCamProfiles == null) { sWebCamProfiles = new WebCamProfile(); } string str = deviceNames[index]; if (str.Equals("NO CAMERAS FOUND")) { EditorGUILayout.HelpBox("No camera connected!\nTo run your application using Play Mode, please connect a webcam to your computer.", MessageType.Warning); } else if (!sWebCamProfiles.ProfileAvailable(deviceNames[index])) { EditorGUILayout.HelpBox("Webcam profile not found!\nUnfortunately there is no profile for your webcam model: '" + deviceNames[index] + "'.\n\nThe default profile will been used. You can configure a profile yourself by editing '" + Path.Combine(Application.dataPath, "Editor/QCAR/WebcamProfiles/profiles.xml") + "'.", MessageType.Warning); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.PrefixLabel("Camera Device"); int num3 = EditorGUILayout.Popup(index, deviceNames, new GUILayoutOption[0]); if ((num3 != index) && !deviceNames[num3].Equals("NO CAMERAS FOUND")) { target.DeviceName = deviceNames[num3]; } EditorGUILayout.EndHorizontal(); target.FlipHorizontally = EditorGUILayout.Toggle("Flip Horizontally", target.FlipHorizontally, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.HelpBox("Here you can enter the index of the layer that will be used internally for our render to texture functionality. the ARCamera will be configured to not draw this layer.", MessageType.None); target.RenderTextureLayer = EditorGUILayout.IntField("Render Texture Layer", target.RenderTextureLayer, new GUILayoutOption[0]); } if (GUI.changed) { EditorUtility.SetDirty(target); SceneManager.Instance.SceneUpdated(); } } else { EditorGUILayout.HelpBox("Webcam settings cannot be changed during Play Mode.", MessageType.Info); } } }