Пример #1
0
        private static IEnumerable <PluginDesc> RegisterVRPlugins(BuildTarget target)
        {
            List <PluginDesc> list = new List <PluginDesc>();

            if (PlayerSettings.virtualRealitySupported)
            {
                string pluginFolder = VRPostProcess.GetPluginFolder(target);
                if (pluginFolder != null)
                {
                    string pluginExtension = VRPostProcess.GetPluginExtension(target, false);
                    VRDeviceInfoEditor[] enabledVRDeviceInfo = VREditor.GetEnabledVRDeviceInfo(BuildPipeline.GetBuildTargetGroup(target));
                    string[]             array = (from d in enabledVRDeviceInfo
                                                  where !string.IsNullOrEmpty(d.externalPluginName)
                                                  select d.externalPluginName).ToArray <string>();
                    for (int i = 0; i < array.Length; i++)
                    {
                        string[] paths = new string[]
                        {
                            pluginFolder,
                            array[i]
                        };
                        list.Add(new PluginDesc
                        {
                            pluginPath = FileUtil.CombinePaths(paths) + pluginExtension
                        });
                    }
                }
                if (!list.Any <PluginDesc>())
                {
                    Debug.LogWarning("Unable to find plugins folder " + target + ". Native VR plugins will not be loaded.");
                }
            }
            return(list);
        }
Пример #2
0
 private void VRDevicesGUIOneBuildTarget(BuildTargetGroup targetGroup)
 {
     if (!this.m_VRDeviceActiveUI.ContainsKey(targetGroup))
     {
         ReorderableList reorderableList = new ReorderableList(VREditor.GetVREnabledDevices(targetGroup), typeof(VRDeviceInfoEditor), true, true, true, true);
         reorderableList.onAddDropdownCallback = delegate(Rect rect, ReorderableList list)
         {
             this.AddVRDeviceElement(targetGroup, rect, list);
         };
         reorderableList.onRemoveCallback = delegate(ReorderableList list)
         {
             this.RemoveVRDeviceElement(targetGroup, list);
         };
         reorderableList.onReorderCallback = delegate(ReorderableList list)
         {
             this.ReorderVRDeviceElement(targetGroup, list);
         };
         reorderableList.drawElementCallback = delegate(Rect rect, int index, bool isActive, bool isFocused)
         {
             this.DrawVRDeviceElement(targetGroup, rect, index, isActive, isFocused);
         };
         reorderableList.drawHeaderCallback = delegate(Rect rect)
         {
             GUI.Label(rect, "Virtual Reality SDKs", EditorStyles.label);
         };
         this.m_VRDeviceActiveUI.Add(targetGroup, reorderableList);
     }
     this.m_VRDeviceActiveUI[targetGroup].DoLayoutList();
     if (this.m_VRDeviceActiveUI[targetGroup].list.Count == 0)
     {
         EditorGUILayout.HelpBox("Must add at least one Virtual Reality SDK.", MessageType.Warning);
     }
 }
 internal void VuforiaGUI(BuildTargetGroup targetGroup)
 {
     if (this.TargetGroupSupportsVuforia(targetGroup) && this.m_VuforiaInstalled)
     {
         bool flag = VREditor.GetVREnabledOnTargetGroup(targetGroup) && this.GetVRDeviceElementIsInList(targetGroup, "Vuforia");
         using (new EditorGUI.DisabledScope(flag))
         {
             if (flag && !PlayerSettings.GetPlatformVuforiaEnabled(targetGroup))
             {
                 PlayerSettings.SetPlatformVuforiaEnabled(targetGroup, true);
             }
             bool flag2 = PlayerSettings.GetPlatformVuforiaEnabled(targetGroup);
             EditorGUI.BeginChangeCheck();
             flag2 = EditorGUILayout.Toggle(EditorGUIUtility.TrTextContent("Vuforia Augmented Reality Supported", null, null), flag2, new GUILayoutOption[0]);
             if (EditorGUI.EndChangeCheck())
             {
                 PlayerSettings.SetPlatformVuforiaEnabled(targetGroup, flag2);
             }
         }
         if (flag)
         {
             EditorGUILayout.HelpBox("Vuforia Augmented Reality is required when using the Vuforia Virtual Reality SDK.", MessageType.Info);
         }
     }
 }
        internal void VuforiaGUI(BuildTargetGroup targetGroup)
        {
            // Vuforia is not supported in the Linux Editor
            if (Application.platform == RuntimePlatform.LinuxEditor)
                return;

            if (!BuildTargetDiscovery.PlatformGroupHasVRFlag(targetGroup, VRAttributes.SupportVuforia))
                return;

            m_SharedSettingShown = true;

            // Disable toggle when Vuforia is in the VRDevice list and VR Supported == true
            bool vuforiaEnabled;
            var shouldDisableScope = VREditor.GetVREnabledOnTargetGroup(targetGroup) && GetVRDeviceElementIsInList(targetGroup, "Vuforia");
            using (new EditorGUI.DisabledScope(shouldDisableScope))
            {
                if (shouldDisableScope && !PlayerSettings.vuforiaEnabled) // Force Vuforia AR on if Vuforia is in the VRDevice List
                    PlayerSettings.vuforiaEnabled = true;

                vuforiaEnabled = PlayerSettings.vuforiaEnabled;

                EditorGUI.BeginChangeCheck();
                vuforiaEnabled = EditorGUILayout.Toggle(EditorGUIUtility.TrTextContent("Vuforia Augmented Reality Supported*"), vuforiaEnabled);
                if (EditorGUI.EndChangeCheck())
                {
                    PlayerSettings.vuforiaEnabled = vuforiaEnabled;
                }
            }

            if (shouldDisableScope)
            {
                EditorGUILayout.HelpBox("Vuforia Augmented Reality is required when using the Vuforia Virtual Reality SDK.", MessageType.Info);
            }
        }
        private void RemoveVRDeviceElement(BuildTargetGroup target, ReorderableList list)
        {
            List <string> list2 = VREditor.GetVREnabledDevicesOnTargetGroup(target).ToList <string>();

            list2.RemoveAt(list.index);
            this.ApplyChangedVRDeviceList(target, list2.ToArray());
        }
Пример #6
0
        private void RemoveVRDeviceElement(BuildTargetGroup target, ReorderableList list)
        {
            var devices = VREditor.GetVREnabledDevicesOnTargetGroup(target).ToList();

            devices.RemoveAt(list.index);
            ApplyChangedVRDeviceList(target, devices.ToArray());
        }
 private void RefreshVRDeviceList(BuildTargetGroup targetGroup)
 {
     VRDeviceInfoEditor[] array = VREditor.GetAllVRDeviceInfo(targetGroup);
     array = (from d in array
              orderby d.deviceNameUI
              select d).ToArray <VRDeviceInfoEditor>();
     this.m_AllVRDevicesForBuildTarget[targetGroup] = array;
     for (int i = 0; i < array.Length; i++)
     {
         VRDeviceInfoEditor vRDeviceInfoEditor = array[i];
         this.m_MapVRDeviceKeyToUIString[vRDeviceInfoEditor.deviceNameKey] = vRDeviceInfoEditor.deviceNameUI;
         this.m_MapVRUIStringToDeviceKey[vRDeviceInfoEditor.deviceNameUI]  = vRDeviceInfoEditor.deviceNameKey;
         VRCustomOptions vRCustomOptions;
         if (!this.m_CustomOptions.TryGetValue(vRDeviceInfoEditor.deviceNameKey, out vRCustomOptions))
         {
             Type type = Type.GetType("UnityEditorInternal.VR.VRCustomOptions" + vRDeviceInfoEditor.deviceNameKey, false, true);
             if (type != null)
             {
                 vRCustomOptions = (VRCustomOptions)Activator.CreateInstance(type);
             }
             else
             {
                 vRCustomOptions = new VRCustomOptionsNone();
             }
             vRCustomOptions.Initialize(this.m_Settings.serializedObject);
             this.m_CustomOptions.Add(vRDeviceInfoEditor.deviceNameKey, vRCustomOptions);
         }
     }
 }
Пример #8
0
        internal void VuforiaGUI(BuildTargetGroup targetGroup)
        {
            if (!TargetGroupSupportsVuforia(targetGroup) || !m_VuforiaInstalled)
            {
                return;
            }

            // Disable toggle when Vuforia is in the VRDevice list and VR Supported == true
            bool vuforiaEnabled;
            var  shouldDisableScope = VREditor.GetVREnabledOnTargetGroup(targetGroup) && GetVRDeviceElementIsInList(targetGroup, "Vuforia");

            using (new EditorGUI.DisabledScope(shouldDisableScope))
            {
                if (shouldDisableScope && !PlayerSettings.GetPlatformVuforiaEnabled(targetGroup)) // Force Vuforia AR on if Vuforia is in the VRDevice List
                {
                    PlayerSettings.SetPlatformVuforiaEnabled(targetGroup, true);
                }

                vuforiaEnabled = PlayerSettings.GetPlatformVuforiaEnabled(targetGroup);

                EditorGUI.BeginChangeCheck();
                vuforiaEnabled = EditorGUILayout.Toggle(EditorGUIUtility.TrTextContent("Vuforia Augmented Reality Supported"), vuforiaEnabled);
                if (EditorGUI.EndChangeCheck())
                {
                    PlayerSettings.SetPlatformVuforiaEnabled(targetGroup, vuforiaEnabled);
                }
            }

            if (shouldDisableScope)
            {
                EditorGUILayout.HelpBox("Vuforia Augmented Reality is required when using the Vuforia Virtual Reality SDK.", MessageType.Info);
            }
        }
Пример #9
0
        private void RefreshVRDeviceList(BuildTargetGroup targetGroup)
        {
            VRDeviceInfoEditor[] deviceInfos = VREditor.GetAllVRDeviceInfo(targetGroup);
            deviceInfos = deviceInfos.OrderBy(d => d.deviceNameUI).ToArray();
            m_AllVRDevicesForBuildTarget[targetGroup] = deviceInfos;

            for (int i = 0; i < deviceInfos.Length; ++i)
            {
                VRDeviceInfoEditor deviceInfo = deviceInfos[i];
                m_MapVRDeviceKeyToUIString[deviceInfo.deviceNameKey] = deviceInfo.deviceNameUI;
                m_MapVRUIStringToDeviceKey[deviceInfo.deviceNameUI]  = deviceInfo.deviceNameKey;

                // Create custom UI options if they exist for this sdk
                VRCustomOptions customOptions;
                if (!m_CustomOptions.TryGetValue(deviceInfo.deviceNameKey, out customOptions))
                {
                    Type optionsType = Type.GetType("UnityEditorInternal.VR.VRCustomOptions" + deviceInfo.deviceNameKey, false, true);
                    if (optionsType != null)
                    {
                        customOptions = (VRCustomOptions)Activator.CreateInstance(optionsType);
                    }
                    else
                    {
                        customOptions = new VRCustomOptionsNone();
                    }
                    customOptions.Initialize(m_Settings.serializedObject);
                    m_CustomOptions.Add(deviceInfo.deviceNameKey, customOptions);
                }
            }
        }
Пример #10
0
 public static VRDeviceInfoEditor[] GetEnabledVRDeviceInfo(BuildTarget target)
 {
     string[] enabledVRDevices = VREditor.GetVREnabledDevicesOnTarget(target);
     return((from d in VREditor.GetAllVRDeviceInfoByTarget(target)
             where enabledVRDevices.Contains(d.deviceNameKey)
             select d).ToArray <VRDeviceInfoEditor>());
 }
 internal void XRSectionGUI(BuildTargetGroup targetGroup, int sectionIndex)
 {
     this.GUISectionIndex = sectionIndex;
     if (this.TargetGroupSupportsVirtualReality(targetGroup) || this.TargetGroupSupportsAugmentedReality(targetGroup))
     {
         if (VREditor.IsDeviceListDirty(targetGroup))
         {
             VREditor.ClearDeviceListDirty(targetGroup);
             this.m_VRDeviceActiveUI[targetGroup].list = VREditor.GetVREnabledDevicesOnTargetGroup(targetGroup);
         }
         this.CheckDevicesRequireInstall(targetGroup);
         if (this.m_Settings.BeginSettingsBox(sectionIndex, PlayerSettingsEditorVR.Styles.xrSettingsTitle))
         {
             if (EditorApplication.isPlaying)
             {
                 EditorGUILayout.HelpBox("Changing XRSettings in not allowed in play mode.", MessageType.Info);
             }
             using (new EditorGUI.DisabledScope(EditorApplication.isPlaying))
             {
                 this.DevicesGUI(targetGroup);
                 this.ErrorOnVRDeviceIncompatibility(targetGroup);
                 this.SinglePassStereoGUI(targetGroup, this.m_StereoRenderingPath);
                 this.TangoGUI(targetGroup);
                 this.VuforiaGUI(targetGroup);
                 this.Stereo360CaptureGUI();
                 this.ErrorOnARDeviceIncompatibility(targetGroup);
             }
             this.InstallGUI(targetGroup);
         }
         this.m_Settings.EndSettingsBox();
     }
 }
 private void ApplyChangedVRDeviceList(BuildTargetGroup target, string[] devices)
 {
     if (this.m_VRDeviceActiveUI.ContainsKey(target))
     {
         VREditor.SetVREnabledDevicesOnTargetGroup(target, devices);
         this.m_VRDeviceActiveUI[target].list = devices;
     }
 }
        private bool GetVRDeviceElementIsInList(BuildTargetGroup target, string deviceName)
        {
            var enabledDevices = VREditor.GetVREnabledDevicesOnTargetGroup(target);

            if (enabledDevices.Contains(deviceName))
                return true;

            return false;
        }
Пример #14
0
 public static string[] GetAvailableVirtualRealitySDKs(BuildTargetGroup targetGroup)
 {
     VRDeviceInfoEditor[] allVRDeviceInfo = VREditor.GetAllVRDeviceInfo(targetGroup);
     string[]             array           = new string[allVRDeviceInfo.Length];
     for (int i = 0; i < allVRDeviceInfo.Length; i++)
     {
         array[i] = allVRDeviceInfo[i].deviceNameKey;
     }
     return(array);
 }
        private void AddVRDeviceElement(BuildTargetGroup target, Rect rect, ReorderableList list)
        {
            VRDeviceInfoEditor[] source         = this.m_AllVRDevicesForBuildTarget[target];
            List <string>        enabledDevices = VREditor.GetVREnabledDevicesOnTargetGroup(target).ToList <string>();

            string[] options = (from d in source
                                select d.deviceNameUI).ToArray <string>();
            bool[] enabled = (from d in source
                              select !enabledDevices.Any((string enabledDeviceName) => d.deviceNameKey == enabledDeviceName)).ToArray <bool>();
            EditorUtility.DisplayCustomMenu(rect, options, enabled, null, new EditorUtility.SelectMenuItemFunction(this.AddVRDeviceMenuSelected), target);
        }
Пример #16
0
        public static bool ShouldInjectVRDependenciesForBuildTarget(BuildTarget target)
        {
            if (!PlayerSettings.virtualRealitySupported)
            {
                return(false);
            }

            VRDeviceInfoEditor[] enabledVRDevices = VREditor.GetEnabledVRDeviceInfo(target);

            return(enabledVRDevices.Length > 0);
        }
Пример #17
0
        private void AddVRDeviceElement(BuildTargetGroup target, Rect rect, ReorderableList list)
        {
            VRDeviceInfoEditor[] allDevices = m_AllVRDevicesForBuildTarget[target];

            var enabledDevices = VREditor.GetVREnabledDevicesOnTargetGroup(target).ToList();

            var names   = allDevices.Select(d => d.deviceNameUI).ToArray();
            var enabled = allDevices.Select(d => !enabledDevices.Any(enabledDeviceName => d.deviceNameKey == enabledDeviceName)).ToArray();

            EditorUtility.DisplayCustomMenu(rect, names, enabled, null, AddVRDeviceMenuSelected, target);
        }
Пример #18
0
 private void RefreshVRDeviceList(BuildTargetGroup targetGroup)
 {
     VRDeviceInfoEditor[] allVRDeviceInfo = VREditor.GetAllVRDeviceInfo(targetGroup);
     this.m_AllVRDevicesForBuildTarget[targetGroup] = allVRDeviceInfo;
     for (int i = 0; i < allVRDeviceInfo.Length; i++)
     {
         VRDeviceInfoEditor vRDeviceInfoEditor = allVRDeviceInfo[i];
         this.m_MapVRDeviceKeyToUIString[vRDeviceInfoEditor.deviceNameKey] = vRDeviceInfoEditor.deviceNameUI;
         this.m_MapVRUIStringToDeviceKey[vRDeviceInfoEditor.deviceNameUI]  = vRDeviceInfoEditor.deviceNameKey;
     }
 }
        private void AddVRDeviceMenuSelected(object userData, string[] options, int selected)
        {
            BuildTargetGroup target = (BuildTargetGroup)userData;
            var enabledDevices = VREditor.GetVREnabledDevicesOnTargetGroup(target).ToList();

            string deviceKey;
            if (!m_MapVRUIStringToDeviceKey.TryGetValue(options[selected], out deviceKey))
                deviceKey = options[selected];

            enabledDevices.Add(deviceKey);

            ApplyChangedVRDeviceList(target, enabledDevices.ToArray());
        }
        private void AddVRDeviceMenuSelected(object userData, string[] options, int selected)
        {
            BuildTargetGroup buildTargetGroup = (BuildTargetGroup)userData;
            List <string>    list             = VREditor.GetVREnabledDevicesOnTargetGroup(buildTargetGroup).ToList <string>();
            string           item;

            if (!this.m_MapVRUIStringToDeviceKey.TryGetValue(options[selected], out item))
            {
                item = options[selected];
            }
            list.Add(item);
            this.ApplyChangedVRDeviceList(buildTargetGroup, list.ToArray());
        }
        private bool IsWindowsMixedRealityCurrentTarget()
        {
            if (!VREditor.GetVREnabledOnTargetGroup(BuildTargetGroup.WSA))
            {
                return(false);
            }

            if (Array.IndexOf(XRSettings.supportedDevices, "WindowsMR") < 0)
            {
                return(false);
            }

            return(true);
        }
 private void ErrorOnVRDeviceIncompatibility(BuildTargetGroup targetGroup)
 {
     if (PlayerSettings.GetVirtualRealitySupported(targetGroup))
     {
         if (targetGroup == BuildTargetGroup.Android)
         {
             List <string> list = VREditor.GetVREnabledDevicesOnTargetGroup(targetGroup).ToList <string>();
             if (list.Contains("Oculus") && list.Contains("daydream"))
             {
                 EditorGUILayout.HelpBox("To avoid initialization conflicts on devices which support both Daydream and Oculus based VR, build separate APKs with different package names, targeting only the Daydream or Oculus VR SDK in the respective APK.", MessageType.Warning);
             }
         }
     }
 }
        private void RemoveVRDeviceElement(BuildTargetGroup target, ReorderableList list)
        {
            var devices = VREditor.GetVREnabledDevicesOnTargetGroup(target).ToList();
            var device = devices[list.index];
            devices.RemoveAt(list.index);

            VRCustomOptions customOptions;
            if (m_CustomOptions.TryGetValue(device, out customOptions))
            {
                customOptions.IsExpanded = true;
            }


            ApplyChangedVRDeviceList(target, devices.ToArray());
        }
 private void ApplyChangedVRDeviceList(BuildTargetGroup target, string[] devices)
 {
     if (this.m_VRDeviceActiveUI.ContainsKey(target))
     {
         if (target == BuildTargetGroup.iPhone)
         {
             if (devices.Contains("cardboard") && PlayerSettings.iOS.cameraUsageDescription == "")
             {
                 PlayerSettings.iOS.cameraUsageDescription = "Used to scan QR codes";
             }
         }
         VREditor.SetVREnabledDevicesOnTargetGroup(target, devices);
         this.m_VRDeviceActiveUI[target].list = devices;
     }
 }
Пример #25
0
        internal void XRSectionGUI(BuildTargetGroup targetGroup, int sectionIndex)
        {
            GUISectionIndex = sectionIndex;

            if (!TargetGroupSupportsVirtualReality(targetGroup) && !TargetGroupSupportsAugmentedReality(targetGroup))
            {
                return;
            }

            if (m_VRDeviceActiveUI.ContainsKey(targetGroup) && VREditor.IsDeviceListDirty(targetGroup))
            {
                VREditor.ClearDeviceListDirty(targetGroup);
                m_VRDeviceActiveUI[targetGroup].list = VREditor.GetVREnabledDevicesOnTargetGroup(targetGroup);
            }

            // Check to see if any devices require an install and need their GUI hidden
            CheckDevicesRequireInstall(targetGroup);

            if (m_Settings.BeginSettingsBox(sectionIndex, Styles.xrSettingsTitle))
            {
                if (EditorApplication.isPlaying)
                {
                    EditorGUILayout.HelpBox("Changing XR Settings is not allowed in play mode.", MessageType.Info);
                }

                using (new EditorGUI.DisabledScope(EditorApplication.isPlaying)) // switching VR flags in play mode is not supported
                {
                    DevicesGUI(targetGroup);

                    ErrorOnVRDeviceIncompatibility(targetGroup);

                    SinglePassStereoGUI(targetGroup, m_StereoRenderingPath);

                    TangoGUI(targetGroup);

                    VuforiaGUI(targetGroup);

                    RemotingWSAHolographicGUI(targetGroup);

                    Stereo360CaptureGUI(targetGroup);

                    ErrorOnARDeviceIncompatibility(targetGroup);
                }

                InstallGUI(targetGroup);
            }
            m_Settings.EndSettingsBox();
        }
 private void DevicesGUI(BuildTargetGroup targetGroup)
 {
     if (this.TargetGroupSupportsVirtualReality(targetGroup))
     {
         bool flag = VREditor.GetVREnabledOnTargetGroup(targetGroup);
         EditorGUI.BeginChangeCheck();
         flag = EditorGUILayout.Toggle(PlayerSettingsEditorVR.Styles.supportedCheckbox, flag, new GUILayoutOption[0]);
         if (EditorGUI.EndChangeCheck())
         {
             VREditor.SetVREnabledOnTargetGroup(targetGroup, flag);
         }
         if (flag)
         {
             this.VRDevicesGUIOneBuildTarget(targetGroup);
         }
     }
 }
 internal void DevicesGUI(BuildTargetGroup targetGroup)
 {
     if (this.TargetGroupSupportsVirtualReality(targetGroup))
     {
         bool flag = VREditor.GetVREnabledOnTargetGroup(targetGroup);
         EditorGUI.BeginChangeCheck();
         flag = EditorGUILayout.Toggle(EditorGUIUtility.TextContent("Virtual Reality Supported"), flag, new GUILayoutOption[0]);
         if (EditorGUI.EndChangeCheck())
         {
             VREditor.SetVREnabledOnTargetGroup(targetGroup, flag);
         }
         if (flag)
         {
             this.VRDevicesGUIOneBuildTarget(targetGroup);
         }
     }
 }
Пример #28
0
        public static bool IsVRDeviceEnabledForBuildTarget(BuildTarget target, string deviceName)
        {
            string[] vREnabledDevicesOnTarget = VREditor.GetVREnabledDevicesOnTarget(target);
            string[] array = vREnabledDevicesOnTarget;
            bool     result;

            for (int i = 0; i < array.Length; i++)
            {
                string a = array[i];
                if (a == deviceName)
                {
                    result = true;
                    return(result);
                }
            }
            result = false;
            return(result);
        }
        private void ApplyChangedVRDeviceList(BuildTargetGroup target, string[] devices)
        {
            if (!m_VRDeviceActiveUI.ContainsKey(target))
                return;

            if (target == BuildTargetGroup.iOS)
            {
                // Set a sensible default if cardboard is enabled, as it uses that feature and
                // the setting is mandatory on iOS
                if (devices.Contains("cardboard") && PlayerSettings.iOS.cameraUsageDescription == "")
                {
                    PlayerSettings.iOS.cameraUsageDescription = "Used to scan QR codes";
                }
            }

            VREditor.SetVREnabledDevicesOnTargetGroup(target, devices);
            m_VRDeviceActiveUI[target].list = devices;
        }
        private void DevicesGUI(BuildTargetGroup targetGroup)
        {
            if (!TargetGroupSupportsVirtualReality(targetGroup))
                return;

            bool vrSupported = VREditor.GetVREnabledOnTargetGroup(targetGroup);

            EditorGUI.BeginChangeCheck();
            vrSupported = EditorGUILayout.Toggle(Styles.supportedCheckbox, vrSupported);
            if (EditorGUI.EndChangeCheck())
            {
                VREditor.SetVREnabledOnTargetGroup(targetGroup, vrSupported);
            }

            if (vrSupported)
            {
                VRDevicesGUIOneBuildTarget(targetGroup);
            }
        }