Exemple #1
0
    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);
            }
        }
    }
Exemple #2
0
 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);
         }
     }
 }