Ejemplo n.º 1
0
        private static void EnsureVersionSymbolIsSet()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }

            IEnumerable <string> atLeastVersionSymbols = new[] { CurrentVersion }
            .Concat(PreviousVersions)
            .Select(AtLeastVersionSymbol);

            string[] versionSymbols = new[] { CurrentExactVersionScriptingDefineSymbol }
            .Concat(atLeastVersionSymbols)
            .ToArray();

            foreach (BuildTargetGroup targetGroup in VRTK_SharedMethods.GetValidBuildTargetGroups())
            {
                string[] currentSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup)
                                          .Split(';')
                                          .Distinct()
                                          .OrderBy(symbol => symbol, StringComparer.Ordinal)
                                          .ToArray();
                string[] newSymbols = currentSymbols.Where(symbol => !symbol.StartsWith(VersionScriptingDefineSymbolPrefix, StringComparison.Ordinal))
                                      .Concat(versionSymbols)
                                      .ToArray();

                if (!currentSymbols.SequenceEqual(newSymbols))
                {
                    PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Join(";", newSymbols));
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Manages (i.e. adds and removes) the VR SDKs of the <see cref="PlayerSettings"/> for the currently set SDK infos.
        /// This method is only available in the editor, so usage of the method needs to be surrounded by `#if UNITY_EDITOR` and `#endif` when used
        /// in a type that is also compiled for a standalone build.
        /// </summary>
        /// <param name="force">Whether to ignore <see cref="autoManageVRSettings"/> while deciding to manage.</param>
        public void ManageVRSettings(bool force)
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode || !(force || autoManageVRSettings))
            {
                return;
            }

            Dictionary <BuildTargetGroup, string[]> deviceNamesByTargetGroup = setups
                                                                               .Where(setup => setup != null && setup.isValid)
                                                                               .SelectMany(setup => new[]
            {
                setup.systemSDKInfo, setup.boundariesSDKInfo, setup.headsetSDKInfo, setup.controllerSDKInfo
            })
                                                                               .GroupBy(info => info.description.buildTargetGroup)
                                                                               .ToDictionary(grouping => grouping.Key,
                                                                                             grouping => grouping.Select(info => info.description.vrDeviceName)
                                                                                             .Distinct()
                                                                                             .ToArray());

            foreach (BuildTargetGroup targetGroup in VRTK_SharedMethods.GetValidBuildTargetGroups())
            {
                string[] deviceNames;
                deviceNamesByTargetGroup.TryGetValue(targetGroup, out deviceNames);

                int  setupCount = deviceNames == null ? 0 : deviceNames.Length;
                bool vrEnabled  = deviceNames != null && deviceNames.Length > 0;

                if (deviceNames != null)
                {
                    deviceNames = deviceNames.Except(new[] { "None" }).ToArray();
                }

#if UNITY_5_5_OR_NEWER
                VREditor.SetVREnabledOnTargetGroup(targetGroup, vrEnabled);
#else
                VREditor.SetVREnabled(targetGroup, vrEnabled);
#endif

                string[] devices;
                if (vrEnabled)
                {
                    devices = setupCount > 1
                                  ? new[] { "None" }.Concat(deviceNames).ToArray()
                                  : deviceNames;
                }
                else
                {
                    devices = new string[0];
                }

#if UNITY_5_5_OR_NEWER
                VREditor.SetVREnabledDevicesOnTargetGroup(
#else
                VREditor.SetVREnabledDevices(
#endif
                    targetGroup,
                    devices
                    );
            }
        }
Ejemplo n.º 3
0
        static VRTK_SDKManagerEditor()
        {
            BuildTargetGroup[] targetGroups = VRTK_SharedMethods.GetValidBuildTargetGroups();
            isBuildTargetActiveSymbolsFoldOut = new Dictionary <BuildTargetGroup, bool>(targetGroups.Length);

            foreach (BuildTargetGroup targetGroup in targetGroups)
            {
                isBuildTargetActiveSymbolsFoldOut[targetGroup] = true;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Manages (i.e. adds and removes) the scripting define symbols of the PlayerSettings for the currently set SDK infos.
        /// This method is only available in the editor, so usage of the method needs to be surrounded by `#if UNITY_EDITOR` and `#endif` when used
        /// in a type that is also compiled for a standalone build.
        /// </summary>
        /// <param name="ignoreAutoManageScriptDefines">Whether to ignore `autoManageScriptDefines` while deciding to manage.</param>
        /// <param name="ignoreIsActiveAndEnabled">Whether to ignore `Behaviour.isActiveAndEnabled` while deciding to manage.</param>
        /// <returns>Whether the PlayerSettings' scripting define symbols were changed.</returns>
        public bool ManageScriptingDefineSymbols(bool ignoreAutoManageScriptDefines, bool ignoreIsActiveAndEnabled)
        {
            if (!((ignoreAutoManageScriptDefines || autoManageScriptDefines) && (ignoreIsActiveAndEnabled || isActiveAndEnabled)))
            {
                return(false);
            }

            //get valid BuildTargetGroups
            BuildTargetGroup[] targetGroups = VRTK_SharedMethods.GetValidBuildTargetGroups();
            Dictionary <BuildTargetGroup, HashSet <string> > newSymbolsByTargetGroup = new Dictionary <BuildTargetGroup, HashSet <string> >(targetGroups.Length);

            //get current non-removable scripting define symbols
            foreach (BuildTargetGroup targetGroup in targetGroups)
            {
                IEnumerable <string> nonSDKSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup)
                                                     .Split(';')
                                                     .Where(symbol => !symbol.StartsWith(SDK_ScriptingDefineSymbolPredicateAttribute.RemovableSymbolPrefix, StringComparison.Ordinal));
                newSymbolsByTargetGroup[targetGroup] = new HashSet <string>(nonSDKSymbols);
            }

            VRTK_SDKInfo[] availableSDKInfos = AvailableSystemSDKInfos
                                               .Concat(AvailableBoundariesSDKInfos)
                                               .Concat(AvailableHeadsetSDKInfos)
                                               .Concat(AvailableControllerSDKInfos)
                                               .ToArray();

            HashSet <SDK_DescriptionAttribute> descriptions = new HashSet <SDK_DescriptionAttribute>(
                availableSDKInfos.Select(info => info.description)
                .Where(description => !description.describesFallbackSDK)
                );
            HashSet <string> activeSymbols = new HashSet <string>(activeScriptingDefineSymbolsWithoutSDKClasses.Select(attribute => attribute.symbol));

            //get scripting define symbols and check whether the predicates allow us to add the symbols
            foreach (ScriptingDefineSymbolPredicateInfo predicateInfo in AvailableScriptingDefineSymbolPredicateInfos)
            {
                SDK_ScriptingDefineSymbolPredicateAttribute predicateAttribute = predicateInfo.attribute;
                string symbol = predicateAttribute.symbol;
                if (!activeSymbols.Contains(symbol) &&
                    !descriptions.Any(description => description.symbol == symbol &&
                                      description.buildTargetGroup == predicateAttribute.buildTargetGroup))
                {
                    continue;
                }

                MethodInfo methodInfo = predicateInfo.methodInfo;
                if (!(bool)methodInfo.Invoke(null, null))
                {
                    continue;
                }

                //add symbols from all predicate attributes on the method since multiple ones are allowed
                SDK_ScriptingDefineSymbolPredicateAttribute[] allAttributes = (SDK_ScriptingDefineSymbolPredicateAttribute[])methodInfo.GetCustomAttributes(typeof(SDK_ScriptingDefineSymbolPredicateAttribute), false);
                foreach (SDK_ScriptingDefineSymbolPredicateAttribute attribute in allAttributes)
                {
                    BuildTargetGroup buildTargetGroup = attribute.buildTargetGroup;
                    HashSet <string> newSymbols;
                    if (!newSymbolsByTargetGroup.TryGetValue(buildTargetGroup, out newSymbols))
                    {
                        newSymbols = new HashSet <string>();
                        newSymbolsByTargetGroup[buildTargetGroup] = newSymbols;
                    }

                    newSymbols.Add(attribute.symbol);
                }
            }

            bool changedSymbols = false;

            //apply new set of scripting define symbols
            foreach (KeyValuePair <BuildTargetGroup, HashSet <string> > keyValuePair in newSymbolsByTargetGroup)
            {
                BuildTargetGroup targetGroup    = keyValuePair.Key;
                string[]         currentSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup)
                                                  .Split(';')
                                                  .Distinct()
                                                  .OrderBy(symbol => symbol, StringComparer.Ordinal)
                                                  .ToArray();
                string[] newSymbols = keyValuePair.Value.OrderBy(symbol => symbol, StringComparer.Ordinal).ToArray();

                if (currentSymbols.SequenceEqual(newSymbols))
                {
                    continue;
                }

                PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Join(";", newSymbols));

                string[] removedSymbols = currentSymbols.Except(newSymbols).ToArray();
                if (removedSymbols.Length > 0)
                {
                    VRTK_Logger.Info(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SCRIPTING_DEFINE_SYMBOLS_REMOVED, targetGroup, string.Join(", ", removedSymbols)));
                }

                string[] addedSymbols = newSymbols.Except(currentSymbols).ToArray();
                if (addedSymbols.Length > 0)
                {
                    VRTK_Logger.Info(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SCRIPTING_DEFINE_SYMBOLS_ADDED, targetGroup, string.Join(", ", addedSymbols)));
                }

                if (!changedSymbols)
                {
                    changedSymbols = removedSymbols.Length > 0 || addedSymbols.Length > 0;
                }
            }

            return(changedSymbols);
        }
        private void RefreshData()
        {
            stringBuilder.Length = 0;

            Assembly editorAssembly = typeof(VRTK_SDKManagerEditor).Assembly;
            Assembly assembly       = typeof(VRTK_SDKManager).Assembly;

            Append(
                "Versions",
                () =>
            {
                Append("Unity", InternalEditorUtility.GetFullUnityVersion());
                Append("VRTK", VRTK_Defines.CurrentVersion + " (may not be correct if source is GitHub)");

                Type steamVRUpdateType = editorAssembly.GetType("SteamVR_Update");
                if (steamVRUpdateType != null)
                {
                    FieldInfo currentVersionField = steamVRUpdateType.GetField("currentVersion", BindingFlags.NonPublic | BindingFlags.Static);
                    if (currentVersionField != null)
                    {
                        string currentVersion = (string)currentVersionField.GetValue(null);
                        Append("SteamVR", currentVersion);
                    }
                }

                Type ovrPluginType = assembly.GetType("OVRPlugin");
                if (ovrPluginType != null)
                {
                    Append(
                        "OVRPlugin (Oculus Utilities)",
                        () =>
                    {
                        FieldInfo wrapperVersionField = ovrPluginType.GetField("wrapperVersion", BindingFlags.Public | BindingFlags.Static);
                        if (wrapperVersionField != null)
                        {
                            Version wrapperVersion = (Version)wrapperVersionField.GetValue(null);
                            Append("wrapperVersion", wrapperVersion);
                        }

                        PropertyInfo versionField = ovrPluginType.GetProperty("version", BindingFlags.Public | BindingFlags.Static);
                        if (versionField != null)
                        {
                            Version version = (Version)versionField.GetGetMethod().Invoke(null, null);
                            Append("version", version);
                        }

                        PropertyInfo nativeSDKVersionField = ovrPluginType.GetProperty("nativeSDKVersion", BindingFlags.Public | BindingFlags.Static);
                        if (nativeSDKVersionField != null)
                        {
                            Version nativeSDKVersion = (Version)nativeSDKVersionField.GetGetMethod().Invoke(null, null);
                            Append("nativeSDKVersion", nativeSDKVersion);
                        }
                    }
                        );
                }
            }
                );

            Append(
                "Scripting Define Symbols",
                () =>
            {
                foreach (BuildTargetGroup targetGroup in VRTK_SharedMethods.GetValidBuildTargetGroups())
                {
                    string symbols = string.Join(
                        ";",
                        PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup)
                        .Split(';')
                        .Where(symbol => !symbol.StartsWith(VRTK_Defines.VersionScriptingDefineSymbolPrefix, StringComparison.Ordinal))
                        .ToArray());
                    if (!string.IsNullOrEmpty(symbols))
                    {
                        Append(targetGroup, symbols);
                    }
                }
            }
                );

            stringBuilder.Length--;
        }
Ejemplo n.º 6
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            VRTK_SDKManager sdkManager = (VRTK_SDKManager)target;

            EditorGUILayout.PropertyField(serializedObject.FindProperty("persistOnLoad"));

            const string manageNowButtonText = "Manage Now";

            using (new EditorGUILayout.VerticalScope("Box"))
            {
                VRTK_EditorUtilities.AddHeader("Scripting Define Symbols", false);

                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUI.BeginChangeCheck();
                    bool autoManage = EditorGUILayout.Toggle(
                        VRTK_EditorUtilities.BuildGUIContent <VRTK_SDKManager>("autoManageScriptDefines", "Auto Manage"),
                        sdkManager.autoManageScriptDefines,
                        GUILayout.ExpandWidth(false)
                        );
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.FindProperty("autoManageScriptDefines").boolValue = autoManage;
                        serializedObject.ApplyModifiedProperties();
                        sdkManager.ManageScriptingDefineSymbols(false, true);
                    }

                    using (new EditorGUI.DisabledGroupScope(sdkManager.autoManageScriptDefines))
                    {
                        GUIContent manageNowGUIContent = new GUIContent(
                            manageNowButtonText,
                            "Manage the scripting define symbols defined by the installed SDKs."
                            + (sdkManager.autoManageScriptDefines
                                   ? "\n\nThis button is disabled because the SDK Manager is set up to manage the scripting define symbols automatically."
                               + " Disable the checkbox on the left to allow managing them manually instead."
                                   : "")
                            );
                        if (GUILayout.Button(manageNowGUIContent, GUILayout.MaxHeight(GUI.skin.label.CalcSize(manageNowGUIContent).y)))
                        {
                            sdkManager.ManageScriptingDefineSymbols(true, true);
                        }
                    }
                }

                using (new EditorGUILayout.VerticalScope("Box"))
                {
                    VRTK_EditorUtilities.AddHeader("Active Symbols Without SDK Classes", false);

                    VRTK_SDKInfo[] availableSDKInfos = VRTK_SDKManager
                                                       .AvailableSystemSDKInfos
                                                       .Concat(VRTK_SDKManager.AvailableBoundariesSDKInfos)
                                                       .Concat(VRTK_SDKManager.AvailableHeadsetSDKInfos)
                                                       .Concat(VRTK_SDKManager.AvailableControllerSDKInfos)
                                                       .ToArray();
                    HashSet <string> sdkSymbols = new HashSet <string>(availableSDKInfos.Select(info => info.description.symbol));
                    IGrouping <BuildTargetGroup, VRTK_SDKManager.ScriptingDefineSymbolPredicateInfo>[] availableGroupedPredicateInfos = VRTK_SDKManager
                                                                                                                                        .AvailableScriptingDefineSymbolPredicateInfos
                                                                                                                                        .GroupBy(info => info.attribute.buildTargetGroup)
                                                                                                                                        .ToArray();
                    foreach (IGrouping <BuildTargetGroup, VRTK_SDKManager.ScriptingDefineSymbolPredicateInfo> grouping in availableGroupedPredicateInfos)
                    {
                        VRTK_SDKManager.ScriptingDefineSymbolPredicateInfo[] possibleActiveInfos = grouping
                                                                                                   .Where(info => !sdkSymbols.Contains(info.attribute.symbol) &&
                                                                                                          grouping.Except(new[] { info })
                                                                                                          .All(predicateInfo => !(predicateInfo.methodInfo == info.methodInfo &&
                                                                                                                                  sdkSymbols.Contains(predicateInfo.attribute.symbol))))
                                                                                                   .OrderBy(info => info.attribute.symbol)
                                                                                                   .ToArray();
                        if (possibleActiveInfos.Length == 0)
                        {
                            continue;
                        }

                        EditorGUI.indentLevel++;

                        BuildTargetGroup targetGroup = grouping.Key;
                        isBuildTargetActiveSymbolsFoldOut[targetGroup] = EditorGUI.Foldout(
                            EditorGUILayout.GetControlRect(),
                            isBuildTargetActiveSymbolsFoldOut[targetGroup],
                            targetGroup.ToString(),
                            true
                            );

                        if (isBuildTargetActiveSymbolsFoldOut[targetGroup])
                        {
                            foreach (VRTK_SDKManager.ScriptingDefineSymbolPredicateInfo predicateInfo in possibleActiveInfos)
                            {
                                int symbolIndex = sdkManager
                                                  .activeScriptingDefineSymbolsWithoutSDKClasses
                                                  .FindIndex(attribute => attribute.symbol == predicateInfo.attribute.symbol);
                                string symbolLabel = predicateInfo.attribute.symbol.Remove(
                                    0,
                                    SDK_ScriptingDefineSymbolPredicateAttribute.RemovableSymbolPrefix.Length
                                    );

                                if (!(bool)predicateInfo.methodInfo.Invoke(null, null))
                                {
                                    symbolLabel += " (not installed)";
                                }

                                EditorGUI.BeginChangeCheck();
                                bool isSymbolActive = EditorGUILayout.ToggleLeft(symbolLabel, symbolIndex != -1);
                                if (EditorGUI.EndChangeCheck())
                                {
                                    Undo.RecordObject(sdkManager, "Active Symbol Change");
                                    if (isSymbolActive)
                                    {
                                        sdkManager.activeScriptingDefineSymbolsWithoutSDKClasses.Add(predicateInfo.attribute);
                                    }
                                    else
                                    {
                                        sdkManager.activeScriptingDefineSymbolsWithoutSDKClasses.RemoveAt(symbolIndex);
                                    }
                                    sdkManager.ManageScriptingDefineSymbols(false, true);
                                }
                            }
                        }

                        EditorGUI.indentLevel--;
                    }
                }

                VRTK_EditorUtilities.DrawUsingDestructiveStyle(GUI.skin.button, style =>
                {
                    GUIContent clearSymbolsGUIContent = new GUIContent(
                        "Remove All Symbols",
                        "Remove all scripting define symbols of VRTK. This is handy if you removed the SDK files from your project but still have"
                        + " the symbols defined which results in compile errors."
                        + "\nIf you have the above checkbox enabled the symbols will be managed automatically after clearing them. Otherwise hit the"
                        + " '" + manageNowButtonText + "' button to add the symbols for the currently installed SDKs again."
                        );

                    if (GUILayout.Button(clearSymbolsGUIContent, style))
                    {
                        BuildTargetGroup[] targetGroups = VRTK_SharedMethods.GetValidBuildTargetGroups();

                        foreach (BuildTargetGroup targetGroup in targetGroups)
                        {
                            string[] currentSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup)
                                                      .Split(';')
                                                      .Distinct()
                                                      .OrderBy(symbol => symbol, StringComparer.Ordinal)
                                                      .ToArray();
                            string[] newSymbols = currentSymbols
                                                  .Where(symbol => !symbol.StartsWith(SDK_ScriptingDefineSymbolPredicateAttribute.RemovableSymbolPrefix, StringComparison.Ordinal))
                                                  .ToArray();

                            if (currentSymbols.SequenceEqual(newSymbols))
                            {
                                continue;
                            }

                            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Join(";", newSymbols));

                            string[] removedSymbols = currentSymbols.Except(newSymbols).ToArray();
                            if (removedSymbols.Length > 0)
                            {
                                VRTK_Logger.Info(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SCRIPTING_DEFINE_SYMBOLS_REMOVED, targetGroup, string.Join(", ", removedSymbols)));
                            }
                        }
                    }
                });
            }

            using (new EditorGUILayout.VerticalScope("Box"))
            {
                VRTK_EditorUtilities.AddHeader("Script Aliases", false);
                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("scriptAliasLeftController"),
                    VRTK_EditorUtilities.BuildGUIContent <VRTK_SDKManager>("scriptAliasLeftController", "Left Controller")
                    );
                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("scriptAliasRightController"),
                    VRTK_EditorUtilities.BuildGUIContent <VRTK_SDKManager>("scriptAliasRightController", "Right Controller")
                    );
            }

            using (new EditorGUILayout.VerticalScope("Box"))
            {
                VRTK_EditorUtilities.AddHeader("Setups", false);

                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUI.BeginChangeCheck();
                    bool autoManage = EditorGUILayout.Toggle(
                        VRTK_EditorUtilities.BuildGUIContent <VRTK_SDKManager>("autoManageVRSettings"),
                        sdkManager.autoManageVRSettings,
                        GUILayout.ExpandWidth(false)
                        );
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.FindProperty("autoManageVRSettings").boolValue = autoManage;
                        serializedObject.ApplyModifiedProperties();
                        sdkManager.ManageVRSettings(false);
                    }

                    using (new EditorGUI.DisabledGroupScope(sdkManager.autoManageVRSettings))
                    {
                        GUIContent manageNowGUIContent = new GUIContent(
                            manageNowButtonText,
                            "Manage the VR settings of the Player Settings to allow for all the installed SDKs."
                            + (sdkManager.autoManageVRSettings
                                   ? "\n\nThis button is disabled because the SDK Manager is set up to manage the VR Settings automatically."
                               + " Disable the checkbox on the left to allow managing them manually instead."
                                   : "")
                            );
                        if (GUILayout.Button(manageNowGUIContent, GUILayout.MaxHeight(GUI.skin.label.CalcSize(manageNowGUIContent).y)))
                        {
                            sdkManager.ManageVRSettings(true);
                        }
                    }
                }

                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("autoLoadSetup"),
                    VRTK_EditorUtilities.BuildGUIContent <VRTK_SDKManager>("autoLoadSetup", "Auto Load")
                    );

                setupsList.DoLayoutList();

                GUIContent autoPopulateGUIContent = new GUIContent("Auto Populate", "Automatically populates the list of SDK Setups with Setups in the scene.");
                if (GUILayout.Button(autoPopulateGUIContent))
                {
                    SerializedProperty serializedProperty = setupsList.serializedProperty;
                    serializedProperty.ClearArray();
                    VRTK_SDKSetup[] setups = sdkManager.GetComponentsInChildren <VRTK_SDKSetup>(true)
                                             .Concat(VRTK_SharedMethods.FindEvenInactiveComponents <VRTK_SDKSetup>())
                                             .Distinct()
                                             .ToArray();

                    for (int index = 0; index < setups.Length; index++)
                    {
                        VRTK_SDKSetup setup = setups[index];
                        serializedProperty.InsertArrayElementAtIndex(index);
                        serializedProperty.GetArrayElementAtIndex(index).objectReferenceValue = setup;
                    }
                }

                if (sdkManager.setups.Length > 1)
                {
                    EditorGUILayout.HelpBox("Duplicated setups are removed automatically.", MessageType.Info);
                }

                if (Enumerable.Range(0, sdkManager.setups.Length).Any(IsSDKSetupNeverUsed))
                {
                    EditorGUILayout.HelpBox("Gray setups will never be loaded because either the SDK Setup isn't valid or there"
                                            + " is a valid Setup before it that uses any non-VR SDK.",
                                            MessageType.Warning);
                }
            }

            using (new EditorGUILayout.VerticalScope("Box"))
            {
                VRTK_EditorUtilities.AddHeader("Target Platform Group Exclusions", false);
                SerializedProperty excludeTargetGroups = serializedObject.FindProperty("excludeTargetGroups");
                excludeTargetGroups.arraySize = EditorGUILayout.IntField("Size", excludeTargetGroups.arraySize);
                for (int i = 0; i < excludeTargetGroups.arraySize; i++)
                {
                    EditorGUILayout.PropertyField(excludeTargetGroups.GetArrayElementAtIndex(i));
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 7
0
        private void RefreshData()
        {
            stringBuilder.Length = 0;

            Assembly editorAssembly = typeof(VRTK_SDKManagerEditor).Assembly;
            Assembly assembly       = typeof(VRTK_SDKManager).Assembly;

            Append(
                "Versions",
                () =>
            {
                Append("Unity", InternalEditorUtility.GetFullUnityVersion());

                Type steamVRUpdateType = editorAssembly.GetType("SteamVR_Update");
                if (steamVRUpdateType != null)
                {
                    FieldInfo currentVersionField = steamVRUpdateType.GetField("currentVersion", BindingFlags.NonPublic | BindingFlags.Static);
                    if (currentVersionField != null)
                    {
                        string currentVersion = (string)currentVersionField.GetValue(null);
                        Append("SteamVR", currentVersion);
                    }
                }

                Type ovrPluginType = assembly.GetType("OVRPlugin");
                if (ovrPluginType != null)
                {
                    Append(
                        "OVRPlugin (Oculus Utilities)",
                        () =>
                    {
                        FieldInfo wrapperVersionField = ovrPluginType.GetField("wrapperVersion", BindingFlags.Public | BindingFlags.Static);
                        if (wrapperVersionField != null)
                        {
                            Version wrapperVersion = (Version)wrapperVersionField.GetValue(null);
                            Append("wrapperVersion", wrapperVersion);
                        }

                        PropertyInfo versionField = ovrPluginType.GetProperty("version", BindingFlags.Public | BindingFlags.Static);
                        if (versionField != null)
                        {
                            Version version = (Version)versionField.GetGetMethod().Invoke(null, null);
                            Append("version", version);
                        }

                        PropertyInfo nativeSDKVersionField = ovrPluginType.GetProperty("nativeSDKVersion", BindingFlags.Public | BindingFlags.Static);
                        if (nativeSDKVersionField != null)
                        {
                            Version nativeSDKVersion = (Version)nativeSDKVersionField.GetGetMethod().Invoke(null, null);
                            Append("nativeSDKVersion", nativeSDKVersion);
                        }
                    }
                        );
                }
            }
                );

            Append(
                "VR Settings",
                () =>
            {
                foreach (BuildTargetGroup targetGroup in VRTK_SharedMethods.GetValidBuildTargetGroups())
                {
                    bool isVREnabled;
#if UNITY_5_5_OR_NEWER
                    isVREnabled = VREditor.GetVREnabledOnTargetGroup(targetGroup);
#else
                    isVREnabled = VREditor.GetVREnabled(targetGroup);
#endif
                    if (!isVREnabled)
                    {
                        continue;
                    }

                    string[] vrEnabledDevices;
#if UNITY_5_5_OR_NEWER
                    vrEnabledDevices = VREditor.GetVREnabledDevicesOnTargetGroup(targetGroup);
#else
                    vrEnabledDevices = VREditor.GetVREnabledDevices(targetGroup);
#endif
                    Append(targetGroup, string.Join(", ", vrEnabledDevices));
                }
            }
                );

            Append(
                "Scripting Define Symbols",
                () =>
            {
                foreach (BuildTargetGroup targetGroup in VRTK_SharedMethods.GetValidBuildTargetGroups())
                {
                    string symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
                    if (!string.IsNullOrEmpty(symbols))
                    {
                        Append(targetGroup, symbols);
                    }
                }
            }
                );

            stringBuilder.Length--;
        }