Exemplo n.º 1
0
        /// <summary>
        /// Populates the lists of available and installed SDK infos for a specific SDK base type.
        /// </summary>
        /// <typeparam name="BaseType">The SDK base type of which to populate the lists for. Must be a subclass of <see cref="SDK_Base"/>.</typeparam>
        /// <typeparam name="FallbackType">The SDK type to fall back on if problems occur. Must be a subclass of <typeparamref name="BaseType"/>.</typeparam>
        /// <param name="availableSDKInfos">The list of available SDK infos to populate.</param>
        /// <param name="installedSDKInfos">The list of installed SDK infos to populate.</param>
        /// <param name="symbolsOfInstalledSDKs">The list of symbols of all the installed SDKs.</param>
        private static void PopulateAvailableAndInstalledSDKInfos <BaseType, FallbackType>(List <VRTK_SDKInfo> availableSDKInfos, List <VRTK_SDKInfo> installedSDKInfos, ICollection <string> symbolsOfInstalledSDKs) where BaseType : SDK_Base where FallbackType : BaseType
        {
            Type baseType     = typeof(BaseType);
            Type fallbackType = SDKFallbackTypesByBaseType[baseType];

            availableSDKInfos.Add(VRTK_SDKInfo.Create <BaseType, FallbackType, FallbackType>());
#if NETFX_CORE
            availableSDKInfos.AddRange(baseType.GetTypeInfo().Assembly.GetExportedTypes()
                                       .Where(type => type.GetTypeInfo().IsSubclassOf(baseType) && type != fallbackType && !type.GetTypeInfo().IsAbstract)
                                       .Select <Type, VRTK_SDKInfo>(VRTK_SDKInfo.Create <BaseType, FallbackType>));
#else
            availableSDKInfos.AddRange(baseType.Assembly.GetExportedTypes()
                                       .Where(type => type.IsSubclassOf(baseType) && type != fallbackType && !type.IsAbstract)
                                       .Select <Type, VRTK_SDKInfo>(VRTK_SDKInfo.Create <BaseType, FallbackType>));
#endif
            availableSDKInfos.Sort((x, y) => x.description.prettyName == "Fallback"
                ? -1 //the fallback SDK should always be the first SDK in the list
                : string.Compare(x.description.prettyName, y.description.prettyName, StringComparison.Ordinal));

            installedSDKInfos.AddRange(availableSDKInfos.Where(info =>
            {
                string symbol = info.description.symbol;
                return(string.IsNullOrEmpty(symbol) || symbolsOfInstalledSDKs.Contains(symbol));
            }));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new SDK info for a type.
        /// </summary>
        /// <typeparam name="BaseType">The SDK base type. Must be a subclass of <see cref="SDK_Base"/>.</typeparam>
        /// <typeparam name="FallbackType">The SDK type to fall back on if problems occur. Must be a subclass of <typeparamref name="BaseType"/>.</typeparam>
        /// <param name="actualType">The SDK type to use. Must be a subclass of <typeparamref name="BaseType"/>.</param>
        /// <returns>A newly created instance.</returns>
        public static VRTK_SDKInfo Create<BaseType, FallbackType>(Type actualType) where BaseType : SDK_Base where FallbackType : BaseType
        {
            var sdkInfo = new VRTK_SDKInfo();
            sdkInfo.SetUp(typeof(BaseType), typeof(FallbackType), actualType.FullName);

            return sdkInfo;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns an error description in case any of these are true for the current SDK info:
        /// <list type="bullet">
        /// <item> <description>Its type doesn't exist anymore.</description> </item>
        /// <item> <description>It's a fallback SDK.</description> </item>
        /// <item> <description>It doesn't have its scripting define symbols added.</description> </item>
        /// <item> <description>It's missing its vendor SDK.</description> </item>
        /// </list>
        /// </summary>
        /// <typeparam name="BaseType">The SDK base type of which to return the error description for. Must be a subclass of <see cref="SDK_Base"/>.</typeparam>
        /// <param name="prettyName">The pretty name of the base SDK to use when returning error descriptions.</param>
        /// <param name="info">The SDK info of which to return the error description for.</param>
        /// <param name="installedInfos">The installed SDK infos.</param>
        /// <returns>An error description if there is one, else <see langword="null"/>.</returns>
        private static string GetSDKErrorDescription <BaseType>(string prettyName, VRTK_SDKInfo info, IEnumerable <VRTK_SDKInfo> installedInfos) where BaseType : SDK_Base
        {
            Type selectedType = info.type;
            Type baseType     = typeof(BaseType);
            Type fallbackType = SDKFallbackTypesByBaseType[baseType];

            if (selectedType == fallbackType)
            {
                return(string.Format("The fallback {0} SDK is being used because there is no other {0} SDK set in the SDK Manager.", prettyName));
            }

            if (!baseType.IsAssignableFrom(selectedType) || fallbackType.IsAssignableFrom(selectedType))
            {
                string description = string.Format("The fallback {0} SDK is being used despite being set to '{1}'.", prettyName, selectedType.Name);

                if (installedInfos.Select(installedInfo => installedInfo.type).Contains(selectedType))
                {
                    return(description + " Its needed scripting define symbols are not added. You can click the GameObject with the `VRTK_SDKManager` script attached to it in Edit Mode and choose to automatically let the manager handle the scripting define symbols.");
                }

                return(description + " The needed vendor SDK isn't installed.");
            }

            return(null);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new SDK info by copying an existing one.
 /// </summary>
 /// <param name="infoToCopy">The SDK info to copy.</param>
 public VRTK_SDKInfo(VRTK_SDKInfo infoToCopy)
 {
     SetUp(Type.GetType(infoToCopy.baseTypeName),
           Type.GetType(infoToCopy.fallbackTypeName),
           infoToCopy.typeName,
           infoToCopy.descriptionIndex);
 }
Exemplo n.º 5
0
        private void UndoRedoPerformed()
        {
            //make sure to trigger populating the object references in case an SDK change was undone
            var          sdkManager        = (VRTK_SDKManager)target;
            VRTK_SDKInfo systemSDKInfo     = sdkManager.systemSDKInfo;
            VRTK_SDKInfo boundariesSDKInfo = sdkManager.boundariesSDKInfo;
            VRTK_SDKInfo headsetSDKInfo    = sdkManager.headsetSDKInfo;
            VRTK_SDKInfo controllerSDKInfo = sdkManager.controllerSDKInfo;

            bool populatesObjectReferences = sdkManager.autoPopulateObjectReferences;

            sdkManager.autoPopulateObjectReferences = false;

            sdkManager.systemSDKInfo     = null;
            sdkManager.boundariesSDKInfo = null;
            sdkManager.headsetSDKInfo    = null;
            sdkManager.controllerSDKInfo = null;

            sdkManager.systemSDKInfo     = systemSDKInfo;
            sdkManager.boundariesSDKInfo = boundariesSDKInfo;
            sdkManager.headsetSDKInfo    = headsetSDKInfo;
            sdkManager.controllerSDKInfo = controllerSDKInfo;

            sdkManager.autoPopulateObjectReferences = populatesObjectReferences;

            if (!sdkManager.ManageScriptingDefineSymbols(false, false))
            {
                sdkManager.PopulateObjectReferences(false);
            }
        }
        private static void DrawVRDeviceNameLabel(VRTK_SDKInfo info, string sdkBaseName, int indentLevelToRemove)
        {
            float maxVRDeviceNameTextWidth = new[]
            {
                VRTK_SDKManager.AvailableSystemSDKInfos,
                VRTK_SDKManager.AvailableBoundariesSDKInfos,
                VRTK_SDKManager.AvailableHeadsetSDKInfos,
                VRTK_SDKManager.AvailableControllerSDKInfos,
                VRTK_SDKManager.AvailableTrackerSDKInfos,
                VRTK_SDKManager.AvailableHandSDKInfos,
            }
            .SelectMany(infos => infos.Select(sdkInfo => sdkInfo.description.vrDeviceName))
            .Concat(XRSettings.supportedDevices)
            .Concat(new[] { "None" })
            .Distinct()
            .Select(deviceName => GUI.skin.label.CalcSize(new GUIContent(deviceName)).x)
            .Max();

            EditorGUI.indentLevel -= indentLevelToRemove;
            EditorGUILayout.LabelField(
                new GUIContent(info.description.vrDeviceName,
                               string.Format("The VR Device used by the {0} {1} SDK.", info.description.prettyName, sdkBaseName)),
                new GUIStyle(EditorStyles.centeredGreyMiniLabel)
            {
                alignment = TextAnchor.MiddleRight
            },
                GUILayout.Width(maxVRDeviceNameTextWidth)
                );
            EditorGUI.indentLevel += indentLevelToRemove;
        }
Exemplo n.º 7
0
        public bool Equals(VRTK_SDKInfo other)
        {
            if ((object)other == null)
            {
                return false;
            }

            return type == other.type;
        }
Exemplo n.º 8
0
        public override bool Equals(object obj)
        {
            VRTK_SDKInfo other = obj as VRTK_SDKInfo;

            if ((object)other == null)
            {
                return(false);
            }

            return(this == other);
        }
Exemplo n.º 9
0
        // Token: 0x06001B6A RID: 7018 RVA: 0x0008F540 File Offset: 0x0008D740
        private static void HandleSDKGetter <BaseType>(string prettyName, VRTK_SDKInfo info, IEnumerable <VRTK_SDKInfo> installedInfos) where BaseType : SDK_Base
        {
            if (VRTK_SharedMethods.IsEditTime())
            {
                return;
            }
            string sdkerrorDescription = VRTK_SDKSetup.GetSDKErrorDescription <BaseType>(prettyName, info, installedInfos);

            if (!string.IsNullOrEmpty(sdkerrorDescription))
            {
                VRTK_Logger.Error(sdkerrorDescription);
            }
        }
        /// <summary>
        /// Draws a popup menu and handles the selection for an SDK info.
        /// </summary>
        /// <typeparam name="BaseType">The SDK base type. Must be a subclass of <see cref="SDK_Base"/>.</typeparam>
        /// <param name="description">The description of the SDK base.</param>
        private void DrawAndHandleSDKSelection <BaseType>(string description, int indentLevelToRemove) where BaseType : SDK_Base
        {
            Type   baseType       = typeof(BaseType);
            Type   sdkManagerType = typeof(VRTK_SDKManager);
            string baseName       = baseType.Name.Remove(0, typeof(SDK_Base).Name.Length);

            ReadOnlyCollection <VRTK_SDKInfo> availableSDKInfos = (ReadOnlyCollection <VRTK_SDKInfo>)sdkManagerType
                                                                  .GetProperty(string.Format("Available{0}SDKInfos", baseName), BindingFlags.Public | BindingFlags.Static)
                                                                  .GetGetMethod()
                                                                  .Invoke(null, null);
            ReadOnlyCollection <VRTK_SDKInfo> installedSDKInfos = (ReadOnlyCollection <VRTK_SDKInfo>)sdkManagerType
                                                                  .GetProperty(string.Format("Installed{0}SDKInfos", baseName), BindingFlags.Public | BindingFlags.Static)
                                                                  .GetGetMethod()
                                                                  .Invoke(null, null);

            PropertyInfo  sdkInfoPropertyInfo = typeof(VRTK_SDKSetup).GetProperty(string.Format("{0}SDKInfo", baseName.ToLowerInvariant()));
            VRTK_SDKSetup sdkSetup            = (VRTK_SDKSetup)target;
            VRTK_SDKInfo  selectedSDKInfo     = (VRTK_SDKInfo)sdkInfoPropertyInfo.GetGetMethod().Invoke(sdkSetup, null);

            List <string> availableSDKNames = availableSDKInfos.Select(info => info.description.prettyName + (installedSDKInfos.Contains(info) ? "" : SDKNotInstalledDescription)).ToList();
            int           selectedSDKIndex  = availableSDKInfos.IndexOf(selectedSDKInfo);

            if (selectedSDKInfo.originalTypeNameWhenFallbackIsUsed != null)
            {
                availableSDKNames.Add(selectedSDKInfo.originalTypeNameWhenFallbackIsUsed + SDKNotFoundAnymoreDescription);
                selectedSDKIndex = availableSDKNames.Count - 1;
            }

            GUIContent[] availableSDKGUIContents = availableSDKNames.Select(availableSDKName => new GUIContent(availableSDKName)).ToArray();

            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUI.BeginChangeCheck();
                int newSelectedSDKIndex = EditorGUILayout.Popup(
                    new GUIContent(baseName, description),
                    selectedSDKIndex,
                    availableSDKGUIContents
                    );
                VRTK_SDKInfo newSelectedSDKInfo = selectedSDKInfo.originalTypeNameWhenFallbackIsUsed != null &&
                                                  newSelectedSDKIndex == availableSDKNames.Count - 1
                                                      ? selectedSDKInfo
                                                      : availableSDKInfos[newSelectedSDKIndex];
                if (EditorGUI.EndChangeCheck() && newSelectedSDKInfo != selectedSDKInfo)
                {
                    Undo.RecordObject(sdkSetup, string.Format("{0} SDK Change", baseName));
                    sdkInfoPropertyInfo.GetSetMethod().Invoke(sdkSetup, new object[] { newSelectedSDKInfo });
                }

                DrawVRDeviceNameLabel(selectedSDKInfo, baseName, indentLevelToRemove);
            }
        }
        /// <summary>
        /// The GetSimplifiedErrorDescriptions method checks the setup for errors and creates an array of error descriptions.
        /// </summary>
        /// <remarks>
        /// The returned error descriptions handle the following cases for the current SDK infos:
        /// <list type="bullet">
        /// <item> <description>Its type doesn't exist anymore.</description> </item>
        /// <item> <description>It's a fallback SDK.</description> </item>
        /// <item> <description>It doesn't have its scripting define symbols added.</description> </item>
        /// <item> <description>It's missing its vendor SDK.</description> </item>
        /// </list>
        /// Additionally the current SDK infos are checked whether they use multiple VR Devices.
        /// </remarks>
        /// <returns>An array of all the error descriptions. Returns an empty array if no errors are found.</returns>
        public string[] GetSimplifiedErrorDescriptions()
        {
            List <string> sdkErrorDescriptions = new List <string>();

            ReadOnlyCollection <VRTK_SDKInfo>[] installedSDKInfosList =
            {
                VRTK_SDKManager.InstalledSystemSDKInfos,
                VRTK_SDKManager.InstalledBoundariesSDKInfos,
                VRTK_SDKManager.InstalledHeadsetSDKInfos,
                VRTK_SDKManager.InstalledControllerSDKInfos,
                VRTK_SDKManager.InstalledTrackerSDKInfos,
                VRTK_SDKManager.InstalledHandSDKInfos
            };
            VRTK_SDKInfo[] currentSDKInfos = { systemSDKInfo, boundariesSDKInfo, headsetSDKInfo, controllerSDKInfo, trackerSDKInfo, handSDKInfo };

            for (int index = 0; index < installedSDKInfosList.Length; index++)
            {
                ReadOnlyCollection <VRTK_SDKInfo> installedSDKInfos = installedSDKInfosList[index];
                VRTK_SDKInfo currentSDKInfo = currentSDKInfos[index];

                Type baseType = VRTK_SharedMethods.GetBaseType(currentSDKInfo.type);
                if (baseType == null)
                {
                    continue;
                }

                if (currentSDKInfo.originalTypeNameWhenFallbackIsUsed != null)
                {
                    sdkErrorDescriptions.Add(string.Format("The SDK '{0}' doesn't exist anymore.", currentSDKInfo.originalTypeNameWhenFallbackIsUsed));
                }
                else if (currentSDKInfo.description.describesFallbackSDK)
                {
                    sdkErrorDescriptions.Add("A fallback SDK is used. Make sure to set a real SDK.");
                }
                else if (!installedSDKInfos.Contains(currentSDKInfo))
                {
                    sdkErrorDescriptions.Add(string.Format("The vendor SDK for '{0}' is not installed.", currentSDKInfo.description.prettyName));
                }
            }

            if (usedVRDeviceNames.Except(new[] { "None" }).Count() > 1)
            {
                sdkErrorDescriptions.Add("The current SDK selection uses multiple VR Devices. It's not possible to use more than one VR Device at the same time.");
            }

            return(sdkErrorDescriptions.Distinct().ToArray());
        }
Exemplo n.º 12
0
        // Token: 0x06001B66 RID: 7014 RVA: 0x0008F2DC File Offset: 0x0008D4DC
        public string[] GetSimplifiedErrorDescriptions()
        {
            List <string> list = new List <string>();

            ReadOnlyCollection <VRTK_SDKInfo>[] array = new ReadOnlyCollection <VRTK_SDKInfo>[]
            {
                VRTK_SDKManager.InstalledSystemSDKInfos,
                VRTK_SDKManager.InstalledBoundariesSDKInfos,
                VRTK_SDKManager.InstalledHeadsetSDKInfos,
                VRTK_SDKManager.InstalledControllerSDKInfos
            };
            VRTK_SDKInfo[] array2 = new VRTK_SDKInfo[]
            {
                this.systemSDKInfo,
                this.boundariesSDKInfo,
                this.headsetSDKInfo,
                this.controllerSDKInfo
            };
            for (int i = 0; i < array.Length; i++)
            {
                ReadOnlyCollection <VRTK_SDKInfo> readOnlyCollection = array[i];
                VRTK_SDKInfo vrtk_SDKInfo = array2[i];
                if (!(vrtk_SDKInfo.type.BaseType == null))
                {
                    if (vrtk_SDKInfo.originalTypeNameWhenFallbackIsUsed != null)
                    {
                        list.Add(string.Format("The SDK '{0}' doesn't exist anymore.", vrtk_SDKInfo.originalTypeNameWhenFallbackIsUsed));
                    }
                    else if (vrtk_SDKInfo.description.describesFallbackSDK)
                    {
                        list.Add("A fallback SDK is used. Make sure to set a real SDK.");
                    }
                    else if (!readOnlyCollection.Contains(vrtk_SDKInfo))
                    {
                        list.Add(string.Format("The vendor SDK for '{0}' is not installed.", vrtk_SDKInfo.description.prettyName));
                    }
                }
            }
            if (this.usedVRDeviceNames.Except(new string[]
            {
                "None"
            }).Count <string>() > 1)
            {
                list.Add("The current SDK selection uses multiple VR Devices. It's not possible to use more than one VR Device at the same time.");
            }
            return(list.Distinct <string>().ToArray <string>());
        }
Exemplo n.º 13
0
        private void UndoRedoPerformed()
        {
            //make sure to trigger populating the object references in case an SDK change was undone
            var          sdkManager        = (VRTK_SDKManager)target;
            VRTK_SDKInfo systemSDKInfo     = sdkManager.systemSDKInfo;
            VRTK_SDKInfo boundariesSDKInfo = sdkManager.boundariesSDKInfo;
            VRTK_SDKInfo headsetSDKInfo    = sdkManager.headsetSDKInfo;
            VRTK_SDKInfo controllerSDKInfo = sdkManager.controllerSDKInfo;

            sdkManager.systemSDKInfo     = null;
            sdkManager.boundariesSDKInfo = null;
            sdkManager.headsetSDKInfo    = null;
            sdkManager.controllerSDKInfo = null;

            sdkManager.systemSDKInfo     = systemSDKInfo;
            sdkManager.boundariesSDKInfo = boundariesSDKInfo;
            sdkManager.headsetSDKInfo    = headsetSDKInfo;
            sdkManager.controllerSDKInfo = controllerSDKInfo;
        }
Exemplo n.º 14
0
        public string[] GetSimplifiedSDKErrorDescriptions()
        {
            var sdkErrorDescriptions = new List <string>();

            var installedSDKInfosList = new[] { InstalledSystemSDKInfos, InstalledBoundariesSDKInfos, InstalledHeadsetSDKInfos, InstalledControllerSDKInfos };
            var currentSDKInfos       = new[] { systemSDKInfo, boundariesSDKInfo, headsetSDKInfo, controllerSDKInfo };

            for (var index = 0; index < installedSDKInfosList.Length; index++)
            {
                ReadOnlyCollection <VRTK_SDKInfo> installedSDKInfos = installedSDKInfosList[index];
                VRTK_SDKInfo currentSDKInfo = currentSDKInfos[index];

#if NETFX_CORE
                Type baseType = currentSDKInfo.type.GetTypeInfo().BaseType;
#else
                Type baseType = currentSDKInfo.type.BaseType;
#endif
                if (baseType == null)
                {
                    continue;
                }

                string baseName = baseType.Name.Remove(0, typeof(SDK_Base).Name.Length);

                if (!installedSDKInfos.Contains(currentSDKInfo))
                {
                    sdkErrorDescriptions.Add(string.Format("The vendor SDK '{0}' is not installed.", currentSDKInfo.description.prettyName));
                }
                else if (currentSDKInfo.type == typeof(SDK_FallbackSystem))
                {
                    if (currentSDKInfo.originalTypeNameWhenFallbackIsUsed != null)
                    {
                        sdkErrorDescriptions.Add(string.Format("The SDK '{0}' doesn't exist anymore. The {1} fallback SDK will be used instead.", currentSDKInfo.originalTypeNameWhenFallbackIsUsed, baseName));
                    }
                    else
                    {
                        sdkErrorDescriptions.Add("A fallback SDK is used. Make sure to set a real SDK.");
                    }
                }
            }

            return(sdkErrorDescriptions.Distinct().ToArray());
        }
Exemplo n.º 15
0
        // Token: 0x06001B1F RID: 6943 RVA: 0x0008DF58 File Offset: 0x0008C158
        public static VRTK_SDKInfo[] Create <BaseType, FallbackType>(Type actualType) where BaseType : SDK_Base where FallbackType : BaseType
        {
            string fullName = actualType.FullName;

            SDK_DescriptionAttribute[] descriptions = SDK_DescriptionAttribute.GetDescriptions(actualType);
            if (descriptions.Length == 0)
            {
                VRTK_Logger.Fatal(string.Format("'{0}' doesn't specify any SDK descriptions via '{1}'.", fullName, typeof(SDK_DescriptionAttribute).Name));
                return(new VRTK_SDKInfo[0]);
            }
            List <VRTK_SDKInfo> list = new List <VRTK_SDKInfo>(descriptions.Length);

            foreach (SDK_DescriptionAttribute sdk_DescriptionAttribute in descriptions)
            {
                VRTK_SDKInfo vrtk_SDKInfo = new VRTK_SDKInfo();
                vrtk_SDKInfo.SetUp(typeof(BaseType), typeof(FallbackType), fullName, sdk_DescriptionAttribute.index);
                list.Add(vrtk_SDKInfo);
            }
            return(list.ToArray());
        }
Exemplo n.º 16
0
        /// <summary>
        /// Creates new SDK infos for a type.
        /// </summary>
        /// <typeparam name="BaseType">The SDK base type. Must be a subclass of SDK_Base.</typeparam>
        /// <typeparam name="FallbackType">The SDK type to fall back on if problems occur. Must be a subclass of `BaseType.</typeparam>
        /// <param name="actualType">The SDK type to use. Must be a subclass of `BaseType.</param>
        /// <returns>Multiple newly created instances.</returns>
        public static VRTK_SDKInfo[] Create <BaseType, FallbackType>(Type actualType) where BaseType : SDK_Base where FallbackType : BaseType
        {
            string actualTypeName = actualType.FullName;

            SDK_DescriptionAttribute[] descriptions = SDK_DescriptionAttribute.GetDescriptions(actualType);
            if (descriptions.Length == 0)
            {
                VRTK_Logger.Fatal(string.Format("'{0}' doesn't specify any SDK descriptions via '{1}'.", actualTypeName, typeof(SDK_DescriptionAttribute).Name));
                return(new VRTK_SDKInfo[0]);
            }

            HashSet <VRTK_SDKInfo> sdkInfos = new HashSet <VRTK_SDKInfo>();

            foreach (SDK_DescriptionAttribute description in descriptions)
            {
                VRTK_SDKInfo sdkInfo = new VRTK_SDKInfo();
                sdkInfo.SetUp(typeof(BaseType), typeof(FallbackType), actualTypeName, description.index);
                sdkInfos.Add(sdkInfo);
            }

            return(sdkInfos.ToArray());
        }
Exemplo n.º 17
0
        // Token: 0x06001B51 RID: 6993 RVA: 0x0008ECE8 File Offset: 0x0008CEE8
        private static void PopulateAvailableAndInstalledSDKInfos <BaseType, FallbackType>(List <VRTK_SDKInfo> availableSDKInfos, List <VRTK_SDKInfo> installedSDKInfos, ICollection <string> symbolsOfInstalledSDKs) where BaseType : SDK_Base where FallbackType : BaseType
        {
            Type baseType     = typeof(BaseType);
            Type fallbackType = VRTK_SDKManager.SDKFallbackTypesByBaseType[baseType];

            availableSDKInfos.AddRange(VRTK_SDKInfo.Create <BaseType, FallbackType, FallbackType>());
            availableSDKInfos.AddRange((from type in baseType.Assembly.GetExportedTypes()
                                        where type.IsSubclassOf(baseType) && type != fallbackType && !type.IsAbstract
                                        select type).SelectMany(new Func <Type, IEnumerable <VRTK_SDKInfo> >(VRTK_SDKInfo.Create <BaseType, FallbackType>)));
            availableSDKInfos.Sort(delegate(VRTK_SDKInfo x, VRTK_SDKInfo y)
            {
                if (!x.description.describesFallbackSDK)
                {
                    return(string.Compare(x.description.prettyName, y.description.prettyName, StringComparison.Ordinal));
                }
                return(-1);
            });
            installedSDKInfos.AddRange(availableSDKInfos.Where(delegate(VRTK_SDKInfo info)
            {
                string symbol = info.description.symbol;
                return(string.IsNullOrEmpty(symbol) || symbolsOfInstalledSDKs.Contains(symbol));
            }));
        }
Exemplo n.º 18
0
 public static bool u091Fu0929u091Eu091Bu0926u091Eu0920u091Au0929u0924u0923(VRTK_SDKInfo u091Cu0923u091Du0924u0929u091Cu091Bu091Au0928u0929u091D, VRTK_SDKInfo u0929u0928u091Fu0927u091Du091Eu091Du0924u0921u0928u0927) => default; // 0x00000001816E4090-0x00000001816E40B0
 public static bool u091Du0922u0922u0924u0924u091Au0925u0920u091Au0926u0927(VRTK_SDKInfo u091Cu0923u091Du0924u0929u091Cu091Bu091Au0928u0929u091D, VRTK_SDKInfo u0929u0928u091Fu0927u091Du091Eu091Du0924u0921u0928u0927) => default; // 0x00000001816E3BD0-0x00000001816E3C80
Exemplo n.º 19
0
        }                                                                                                        // 0x0000000180246FE0-0x0000000180246FF0 0x0000000180249080-0x0000000180249090

        // Constructors
        public VRTK_SDKInfo(VRTK_SDKInfo infoToCopy)
        {
        }                                                       // 0x00000001816E72A0-0x00000001816E73A0
        public override void OnInspectorGUI()
        {
            VRTK_SDKSetup setup = (VRTK_SDKSetup)target;

            serializedObject.Update();

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

                Func <VRTK_SDKInfo, ReadOnlyCollection <VRTK_SDKInfo>, string> sdkNameSelector = (info, installedInfos)
                                                                                                 => info.description.prettyName + (installedInfos.Contains(info) ? "" : SDKNotInstalledDescription);
                string[] availableSystemSDKNames     = VRTK_SDKManager.AvailableSystemSDKInfos.Select(info => sdkNameSelector(info, VRTK_SDKManager.InstalledSystemSDKInfos)).ToArray();
                string[] availableBoundariesSDKNames = VRTK_SDKManager.AvailableBoundariesSDKInfos.Select(info => sdkNameSelector(info, VRTK_SDKManager.InstalledBoundariesSDKInfos)).ToArray();
                string[] availableHeadsetSDKNames    = VRTK_SDKManager.AvailableHeadsetSDKInfos.Select(info => sdkNameSelector(info, VRTK_SDKManager.InstalledHeadsetSDKInfos)).ToArray();
                string[] availableControllerSDKNames = VRTK_SDKManager.AvailableControllerSDKInfos.Select(info => sdkNameSelector(info, VRTK_SDKManager.InstalledControllerSDKInfos)).ToArray();
                string[] availableTrackerSDKNames    = VRTK_SDKManager.AvailableTrackerSDKInfos.Select(info => sdkNameSelector(info, VRTK_SDKManager.InstalledTrackerSDKInfos)).ToArray();
                string[] availableHandSDKNames       = VRTK_SDKManager.AvailableHandSDKInfos.Select(info => sdkNameSelector(info, VRTK_SDKManager.InstalledHandSDKInfos)).ToArray();
                string[] allAvailableSDKNames        = availableSystemSDKNames
                                                       .Concat(availableBoundariesSDKNames)
                                                       .Concat(availableHeadsetSDKNames)
                                                       .Concat(availableControllerSDKNames)
                                                       .Concat(availableTrackerSDKNames)
                                                       .Concat(availableHandSDKNames)
                                                       .Distinct()
                                                       .ToArray();

                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUI.BeginChangeCheck();

                    List <GUIContent> quickSelectOptions = allAvailableSDKNames
                                                           .Select(sdkName => new GUIContent(sdkName))
                                                           .ToList();
                    int quicklySelectedSDKIndex = 0;

                    if (AreAllSDKsTheSame())
                    {
                        quicklySelectedSDKIndex = allAvailableSDKNames
                                                  .ToList()
                                                  .FindIndex(availableSDKName => availableSDKName.Replace(SDKNotInstalledDescription, "")
                                                             == setup.systemSDKInfo.description.prettyName);
                    }
                    else
                    {
                        quickSelectOptions.Insert(0, new GUIContent("Mixed..."));
                    }

                    quicklySelectedSDKIndex = EditorGUILayout.Popup(
                        new GUIContent("Quick Select", "Quickly select one of the SDKs into all slots."),
                        quicklySelectedSDKIndex,
                        quickSelectOptions.ToArray());
                    if (!AreAllSDKsTheSame())
                    {
                        quicklySelectedSDKIndex--;
                    }

                    if (EditorGUI.EndChangeCheck() && (AreAllSDKsTheSame() || quicklySelectedSDKIndex != -1))
                    {
                        string quicklySelectedSDKName = allAvailableSDKNames[quicklySelectedSDKIndex].Replace(SDKNotInstalledDescription, "");

                        Func <VRTK_SDKInfo, bool> predicate = info => info.description.prettyName == quicklySelectedSDKName;
                        VRTK_SDKInfo newSystemSDKInfo       = VRTK_SDKManager.AvailableSystemSDKInfos.FirstOrDefault(predicate);
                        VRTK_SDKInfo newBoundariesSDKInfo   = VRTK_SDKManager.AvailableBoundariesSDKInfos.FirstOrDefault(predicate);
                        VRTK_SDKInfo newHeadsetSDKInfo      = VRTK_SDKManager.AvailableHeadsetSDKInfos.FirstOrDefault(predicate);
                        VRTK_SDKInfo newControllerSDKInfo   = VRTK_SDKManager.AvailableControllerSDKInfos.FirstOrDefault(predicate);
                        VRTK_SDKInfo newTrackerSDKInfo      = VRTK_SDKManager.AvailableTrackerSDKInfos.FirstOrDefault(predicate);
                        VRTK_SDKInfo newHandSDKInfo         = VRTK_SDKManager.AvailableHandSDKInfos.FirstOrDefault(predicate);

                        Undo.RecordObject(setup, "SDK Change (Quick Select)");
                        if (newSystemSDKInfo != null)
                        {
                            setup.systemSDKInfo = newSystemSDKInfo;
                        }
                        if (newBoundariesSDKInfo != null)
                        {
                            setup.boundariesSDKInfo = newBoundariesSDKInfo;
                        }
                        if (newHeadsetSDKInfo != null)
                        {
                            setup.headsetSDKInfo = newHeadsetSDKInfo;
                        }
                        if (newControllerSDKInfo != null)
                        {
                            setup.controllerSDKInfo = newControllerSDKInfo;
                        }
                        if (newTrackerSDKInfo != null)
                        {
                            setup.trackerSDKInfo = newTrackerSDKInfo;
                        }
                        if (newHandSDKInfo != null)
                        {
                            setup.handSDKInfo = newHandSDKInfo;
                        }

                        UpdateDetailedSDKSelectionFoldOut();
                    }

                    if (AreAllSDKsTheSame())
                    {
                        VRTK_SDKInfo selectedInfo = new[]
                        {
                            setup.systemSDKInfo,
                            setup.boundariesSDKInfo,
                            setup.headsetSDKInfo,
                            setup.controllerSDKInfo,
                            setup.trackerSDKInfo,
                            setup.handSDKInfo
                        }.First(info => info != null);
                        DrawVRDeviceNameLabel(selectedInfo, "System, Boundaries, Headset, Controller, Trackers, and Hands", 0);
                    }
                }

                EditorGUI.indentLevel++;

                if (!isDetailedSDKSelectionFoldOut.HasValue)
                {
                    UpdateDetailedSDKSelectionFoldOut();
                }
                isDetailedSDKSelectionFoldOut = EditorGUI.Foldout(
                    EditorGUILayout.GetControlRect(),
                    isDetailedSDKSelectionFoldOut.Value,
                    "Detailed Selection",
                    true
                    );
                if (isDetailedSDKSelectionFoldOut.Value)
                {
                    EditorGUI.BeginChangeCheck();

                    DrawAndHandleSDKSelection <SDK_BaseSystem>("The SDK to use to deal with all system actions.", 1);
                    DrawAndHandleSDKSelection <SDK_BaseBoundaries>("The SDK to use to utilize room scale boundaries.", 1);
                    DrawAndHandleSDKSelection <SDK_BaseHeadset>("The SDK to use to utilize the VR headset.", 1);
                    DrawAndHandleSDKSelection <SDK_BaseController>("The SDK to use to utilize the input devices.", 1);
                    DrawAndHandleSDKSelection <SDK_BaseTracker>("The SDK to use for tracked objects.", 1);
                    DrawAndHandleSDKSelection <SDK_BaseHand>("The SDK to use to utilize the hand-style input devices.", 1);

                    if (EditorGUI.EndChangeCheck())
                    {
                        UpdateDetailedSDKSelectionFoldOut();
                    }
                }

                EditorGUI.indentLevel--;

                string errorDescriptions = string.Join("\n", setup.GetSimplifiedErrorDescriptions());
                if (!string.IsNullOrEmpty(errorDescriptions))
                {
                    EditorGUILayout.HelpBox(errorDescriptions, MessageType.Error);
                }

                if (allAvailableSDKNames.Length != availableSystemSDKNames.Length ||
                    allAvailableSDKNames.Length != availableBoundariesSDKNames.Length ||
                    allAvailableSDKNames.Length != availableHeadsetSDKNames.Length ||
                    allAvailableSDKNames.Length != availableControllerSDKNames.Length ||
                    allAvailableSDKNames.Length != availableTrackerSDKNames.Length ||
                    allAvailableSDKNames.Length != availableHandSDKNames.Length)
                {
                    EditorGUILayout.HelpBox("Only endpoints that are supported by the selected SDK are changed by Quick Select, the others are left untouched."
                                            + "\n\nSome of the available SDK implementations are only available for a subset of SDK endpoints. Quick Select"
                                            + " shows SDKs that provide an implementation for *any* of the different SDK endpoints in VRTK"
                                            + " (System, Boundaries, Headset, Controller, Trackers, Hands).", MessageType.Info);
                }
            }

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

                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUI.BeginChangeCheck();
                    bool autoPopulate = EditorGUILayout.Toggle(VRTK_EditorUtilities.BuildGUIContent <VRTK_SDKSetup>("autoPopulateObjectReferences", "Auto Populate"),
                                                               setup.autoPopulateObjectReferences,
                                                               GUILayout.ExpandWidth(false));
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.FindProperty("autoPopulateObjectReferences").boolValue = autoPopulate;
                        serializedObject.ApplyModifiedProperties();
                        setup.PopulateObjectReferences(false);
                    }

                    const string populateNowDescription = "Populate Now";
                    GUIContent   populateNowGUIContent  = new GUIContent(populateNowDescription, "Set the SDK object references to the objects of the selected SDKs.");
                    if (GUILayout.Button(populateNowGUIContent, GUILayout.MaxHeight(GUI.skin.label.CalcSize(populateNowGUIContent).y)))
                    {
                        Undo.RecordObject(setup, populateNowDescription);
                        setup.PopulateObjectReferences(true);
                    }
                }

                if (setup.autoPopulateObjectReferences)
                {
                    EditorGUILayout.HelpBox("The SDK Setup is configured to automatically populate object references so the following fields are disabled."
                                            + " Uncheck `Auto Populate` above to enable customization of the fields below.", MessageType.Info);
                }

                using (new EditorGUI.DisabledGroupScope(setup.autoPopulateObjectReferences))
                {
                    using (new EditorGUILayout.VerticalScope("Box"))
                    {
                        VRTK_EditorUtilities.AddHeader("Actual Objects", false);
                        EditorGUILayout.PropertyField(
                            serializedObject.FindProperty("actualBoundaries"),
                            VRTK_EditorUtilities.BuildGUIContent <VRTK_SDKSetup>("actualBoundaries", "Boundaries")
                            );
                        EditorGUILayout.PropertyField(
                            serializedObject.FindProperty("actualHeadset"),
                            VRTK_EditorUtilities.BuildGUIContent <VRTK_SDKSetup>("actualHeadset", "Headset")
                            );
                        EditorGUILayout.PropertyField(
                            serializedObject.FindProperty("actualLeftController"),
                            VRTK_EditorUtilities.BuildGUIContent <VRTK_SDKSetup>("actualLeftController", "Left Controller")
                            );
                        EditorGUILayout.PropertyField(
                            serializedObject.FindProperty("actualRightController"),
                            VRTK_EditorUtilities.BuildGUIContent <VRTK_SDKSetup>("actualRightController", "Right Controller")
                            );
                        EditorGUILayout.PropertyField(
                            serializedObject.FindProperty("actualTrackers"),
                            VRTK_EditorUtilities.BuildGUIContent <VRTK_SDKSetup>("actualTrackers", "Trackers"),
                            true
                            );
                        EditorGUILayout.PropertyField(
                            serializedObject.FindProperty("actualHand"),
                            VRTK_EditorUtilities.BuildGUIContent <VRTK_SDKSetup>("actualHand", "Hands")
                            );
                    }

                    using (new EditorGUILayout.VerticalScope("Box"))
                    {
                        VRTK_EditorUtilities.AddHeader("Model Aliases", false);
                        EditorGUILayout.PropertyField(
                            serializedObject.FindProperty("modelAliasLeftController"),
                            VRTK_EditorUtilities.BuildGUIContent <VRTK_SDKSetup>("modelAliasLeftController", "Left Controller")
                            );
                        EditorGUILayout.PropertyField(
                            serializedObject.FindProperty("modelAliasRightController"),
                            VRTK_EditorUtilities.BuildGUIContent <VRTK_SDKSetup>("modelAliasRightController", "Right Controller")
                            );
                    }
                }

                EditorGUILayout.HelpBox(
                    "The game object this SDK Setup is attached to will be set inactive automatically to allow for SDK loading and switching.",
                    MessageType.Info
                    );

                IEnumerable <GameObject> referencedObjects = new[]
                {
                    setup.actualBoundaries,
                    setup.actualHeadset,
                    setup.actualLeftController,
                    setup.actualRightController,
                    setup.modelAliasLeftController,
                    setup.modelAliasRightController
                }.Where(referencedObject => referencedObject != null);
                if (referencedObjects.Any(referencedObject => !referencedObject.transform.IsChildOf(setup.transform)))
                {
                    EditorGUILayout.HelpBox(
                        "There is at least one referenced object that is neither a child of, deep child (child of a child) of nor attached to the game object this SDK Setup is attached to.",
                        MessageType.Error
                        );
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 21
0
        }                                                                                                                                                                                                                                  // 0x0000000180246D40-0x0000000180246D50

        public static bool u0929u091Du0928u0923u0922u091Au0920u091Fu091Cu0920u091E(VRTK_SDKInfo u091Cu0923u091Du0924u0929u091Cu091Bu091Au0928u0929u091D, VRTK_SDKInfo u0929u0928u091Fu0927u091Du091Eu091Du0924u0921u0928u0927) => default; // 0x00000001816E7050-0x00000001816E7110
Exemplo n.º 22
0
 public bool Equals(VRTK_SDKInfo other)
 {
     return(this == other);
 }
Exemplo n.º 23
0
 public static bool u091Bu0926u0926u0922u091Du0927u091Cu091Eu091Fu0928u0929(VRTK_SDKInfo u091Cu0923u091Du0924u0929u091Cu091Bu091Au0928u0929u091D, VRTK_SDKInfo u0929u0928u091Fu0927u091Du091Eu091Du0924u0921u0928u0927) => default; // 0x00000001816E1DF0-0x00000001816E1E10
 public bool u091Bu091Eu0927u091Bu0921u091Du0929u091Eu091Au0929u0926(VRTK_SDKInfo u0923u0924u0927u091Au0921u091Au091Bu0920u091Bu0926u0923) => default;                                                                              // 0x00000001816E1DE0-0x00000001816E1DF0
Exemplo n.º 24
0
 public bool u0928u091Au091Du0923u0926u0928u0924u0922u091Au0926u091B(VRTK_SDKInfo u0923u0924u0927u091Au0921u091Au091Bu0920u091Bu0926u0923) => default;                                                                              // 0x00000001816E1DE0-0x00000001816E1DF0
 public static bool u0923u0924u091Du091Au0922u0927u0925u091Fu091Cu0928u0924(VRTK_SDKInfo u091Cu0923u091Du0924u0929u091Cu091Bu091Au0928u0929u091D, VRTK_SDKInfo u0929u0928u091Fu0927u091Du091Eu091Du0924u0921u0928u0927) => default; // 0x00000001816E5A60-0x00000001816E5B20
Exemplo n.º 25
0
 // Token: 0x06001B1E RID: 6942 RVA: 0x0008DF46 File Offset: 0x0008C146
 public static VRTK_SDKInfo[] Create <BaseType, FallbackType, ActualType>() where BaseType : SDK_Base where FallbackType : BaseType where ActualType : BaseType
 {
     return(VRTK_SDKInfo.Create <BaseType, FallbackType>(typeof(ActualType)));
 }
Exemplo n.º 26
0
        // Token: 0x06001B25 RID: 6949 RVA: 0x0008E21C File Offset: 0x0008C41C
        public override bool Equals(object obj)
        {
            VRTK_SDKInfo vrtk_SDKInfo = obj as VRTK_SDKInfo;

            return(vrtk_SDKInfo != null && this == vrtk_SDKInfo);
        }
Exemplo n.º 27
0
 public static bool u0923u0924u091Du091Au0922u0927u0925u091Fu091Cu0928u0924(VRTK_SDKInfo u091Cu0923u091Du0924u0929u091Cu091Bu091Au0928u0929u091D, VRTK_SDKInfo u0929u0928u091Fu0927u091Du091Eu091Du0924u0921u0928u0927) => default; // 0x00000001816E5A60-0x00000001816E5B20
 public static bool u091Bu0926u0926u0922u091Du0927u091Cu091Eu091Fu0928u0929(VRTK_SDKInfo u091Cu0923u091Du0924u0929u091Cu091Bu091Au0928u0929u091D, VRTK_SDKInfo u0929u0928u091Fu0927u091Du091Eu091Du0924u0921u0928u0927) => default; // 0x00000001816E1DF0-0x00000001816E1E10
Exemplo n.º 28
0
        /// <summary>
        /// Handles SDK selection during startup. Must be called before setupping any SDK specific stuff.
        /// </summary>
        private void SetupSDK()
        {
            // Check if we even have to do any SDK selection
            bool needsSDKSetup = automaticSDKSelection || (actualBoundaries == null && actualHeadset == null && actualLeftController == null && actualRightController == null);

            if (!needsSDKSetup)
            {
                return;
            }

            string selectedSDK = "Fallback";

            // Heuristic SDK detection
            if (automaticSDKSelection)
            {
                if (!VRDevice.isPresent)
                {
                    selectedSDK = "Simulator";
                }
                else
                {
                    if (VRDevice.model.Contains("Oculus") || VRDevice.model.Contains("Rift"))
                    {
                        selectedSDK = "OculusVR";
                    }
                    else
                    {
                        // Assume everyone else except Oculus uses SteamVR
                        selectedSDK = "SteamVR";
                    }
                }

                // Check for command line SDKs. These override all the previous selections.
                var args = System.Environment.GetCommandLineArgs();
                foreach (var arg in args)
                {
                    if (arg.Equals("--vr-none"))
                    {
                        selectedSDK = "Fallback";
                    }
                    if (arg.Equals("--vr-oculus"))
                    {
                        selectedSDK = "OculusVR";
                    }
                    if (arg.Equals("--vr-steam"))
                    {
                        selectedSDK = "SteamVR";
                    }
                    if (arg.Equals("--vr-simulator"))
                    {
                        selectedSDK = "Simulator";
                    }
                }

                Debug.Log("Selected VR SDK: " + selectedSDK);

                // Set correct individual SDKs
                systemSDKInfo     = GetSDK(selectedSDK, AvailableSystemSDKInfos);
                boundariesSDKInfo = GetSDK(selectedSDK, AvailableBoundariesSDKInfos);
                headsetSDKInfo    = GetSDK(selectedSDK, AvailableHeadsetSDKInfos);
                controllerSDKInfo = GetSDK(selectedSDK, AvailableControllerSDKInfos);

                // Load the SDK camera rig if one has been assigned
                int sdkIndex  = AvailableSystemSDKInfos.IndexOf(GetSDK(selectedSDK));
                var sdkPrefab = automaticSDKPrefabList[sdkIndex];
                if (sdkPrefab != null)
                {
                    var go = Instantiate(sdkPrefab) as GameObject;
                    if (go != null)
                    {
                        // Remove (Clone) from the name of the instantiated game object, otherwise SDKs don't work properly
                        // as they find the gameobjects by their name.
                        go.name = go.name.Replace("(Clone)", "");
                    }
                }
                // Disable VR if we don't have a true VR SDK
                if (selectedSDK == "Fallback" || selectedSDK == "Simulator")
                {
                    VRSettings.enabled = false;
                    VRSettings.LoadDeviceByName("None");
                }

                // Assign VRTK components to the newly instantiated rig
                var playareaTransform = GetBoundariesSDK().GetPlayArea();
                actualBoundaries = (playareaTransform ? playareaTransform.gameObject : null);

                var headsetTransform = GetHeadsetSDK().GetHeadset();
                actualHeadset = (headsetTransform ? headsetTransform.gameObject : null);

                var controllerLeft = GetControllerSDK().GetControllerLeftHand(true);
                actualLeftController = controllerLeft;

                var controllerRight = GetControllerSDK().GetControllerRightHand(true);
                actualRightController = controllerRight;

                var controllerAliasLeft = GetControllerSDK().GetControllerModel(SDK_BaseController.ControllerHand.Left);
                modelAliasLeftController = controllerAliasLeft;

                var controllerAliasRight = GetControllerSDK().GetControllerModel(SDK_BaseController.ControllerHand.Right);
                modelAliasRightController = controllerAliasRight;
            }
        }
Exemplo n.º 29
0
 /// <summary>
 /// Creates a new SDK info by copying an existing one.
 /// </summary>
 /// <param name="infoToCopy">The SDK info to copy.</param>
 public VRTK_SDKInfo(VRTK_SDKInfo infoToCopy)
 {
     SetUp(Type.GetType(infoToCopy.baseTypeName), Type.GetType(infoToCopy.fallbackTypeName), infoToCopy.typeName);
 }
Exemplo n.º 30
0
 public static bool u0929u091Du0928u0923u0922u091Au0920u091Fu091Cu0920u091E(VRTK_SDKInfo u091Cu0923u091Du0924u0929u091Cu091Bu091Au0928u0929u091D, VRTK_SDKInfo u0929u0928u091Fu0927u091Du091Eu091Du0924u0921u0928u0927) => default; // 0x00000001816E7050-0x00000001816E7110
 public bool u091Cu0927u0927u0928u0926u0925u0928u0921u0921u0929u091C(VRTK_SDKInfo u0923u0924u0927u091Au0921u091Au091Bu0920u091Bu0926u0923) => default;                                                                              // 0x00000001816E2C90-0x00000001816E2CA0