// OnPreprocessBuild() is called right before the build process begins. If it
        // detects that the first enabled scene in the build arrays is the PermissionsDemo,
        // and Daydream is in the VR SDKs, it will add Cardboard to the VR SDKs. Because
        // the PermissionsDemo needs a perm statement in the Manifest while other demos don't.
        // Adding Cardboard to VR SDKs will merge in the Manifest-Cardboard which has perm
        // statement in it.
        public void OnPreprocessBuild(BuildTarget target, string path)
        {
            m_cardboardAddedFromCode = false;

            string[] androidVrSDKs = VREditor.GetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Android);

            EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes;

            // See if PermissionsDemo is the first enabled scene in the array of scenes to build.
            for (int i = 0; i < scenes.Length; i++)
            {
                if (scenes[i].path.Contains(SCENE_NAME_PERMISSIONS_DEMO))
                {
                    if (!scenes[i].enabled)
                    {
                        return;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    if (scenes[i].enabled)
                    {
                        return;
                    }
                }
            }

            bool hasCardboard = Array.Exists <string>(androidVrSDKs,
                                                      element => element.Equals(GvrSettings.VR_SDK_CARDBOARD));

            if (hasCardboard)
            {
                return;
            }

            bool hasDaydream = Array.Exists <string>(androidVrSDKs,
                                                     element => element.Equals(GvrSettings.VR_SDK_DAYDREAM));

            if (!hasDaydream)
            {
                return;
            }

            string[] androidVrSDKsAppended = new string[androidVrSDKs.Length + 1];

            for (int i = 0; i < androidVrSDKs.Length; i++)
            {
                androidVrSDKsAppended[i] = androidVrSDKs[i];
            }

            androidVrSDKsAppended[androidVrSDKsAppended.Length - 1] = GvrSettings.VR_SDK_CARDBOARD;

            VREditor.SetVREnabledOnTargetGroup(
                BuildTargetGroup.Android, true);
            VREditor.SetVREnabledDevicesOnTargetGroup(
                BuildTargetGroup.Android,
                androidVrSDKsAppended);

            m_cardboardAddedFromCode = true;
        }
Example #2
0
    private static void Update()
    {
        bool show = (!EditorPrefs.HasKey(ignore + buildTarget) &&
                     EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget) ||
                    (!EditorPrefs.HasKey(ignore + showUnitySplashScreen) &&
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
                     PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen) ||
#else
                     PlayerSettings.SplashScreen.show != recommended_ShowUnitySplashScreen) ||
#endif
                    (!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
                     PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen) ||
                    (!EditorPrefs.HasKey(ignore + defaultScreenSize) &&
                     (PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
                      PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight)) ||
                    (!EditorPrefs.HasKey(ignore + runInBackground) &&
                     PlayerSettings.runInBackground != recommended_RunInBackground) ||
                    (!EditorPrefs.HasKey(ignore + displayResolutionDialog) &&
                     PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog) ||
                    (!EditorPrefs.HasKey(ignore + resizableWindow) &&
                     PlayerSettings.resizableWindow != recommended_ResizableWindow) ||
                    (!EditorPrefs.HasKey(ignore + fullscreenMode) &&
                     PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode) ||
                    (!EditorPrefs.HasKey(ignore + visibleInBackground) &&
                     PlayerSettings.visibleInBackground != recommended_VisibleInBackground) ||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
                    (!EditorPrefs.HasKey(ignore + renderingPath) &&
                     PlayerSettings.renderingPath != recommended_RenderPath) ||
#endif
                    (!EditorPrefs.HasKey(ignore + colorSpace) && PlayerSettings.colorSpace != recommended_ColorSpace) ||
                    (!EditorPrefs.HasKey(ignore + gpuSkinning) && PlayerSettings.gpuSkinning != recommended_GpuSkinning) ||
#if false
                    (!EditorPrefs.HasKey(ignore + singlePassStereoRendering) &&
                     PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering) ||
#endif
                    forceShow;

        if (show)
        {
            window         = GetWindow <SteamVR_Settings>(true);
            window.minSize = new Vector2(320, 440);
            //window.title = "SteamVR";
        }

        if (SteamVR_Preferences.AutoEnableVR)
        {
            // Switch to native OpenVR support.
            var updated = false;

            if (!PlayerSettings.virtualRealitySupported)
            {
                PlayerSettings.virtualRealitySupported = true;
                updated = true;
            }

#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
            var devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevices(BuildTargetGroup.Standalone);
#else
            var devices = VREditor.GetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Standalone);
#endif
            var hasOpenVR = false;
            foreach (var device in devices)
            {
                if (device.ToLower() == "openvr")
                {
                    hasOpenVR = true;
                }
            }

            if (!hasOpenVR)
            {
                string[] newDevices;
                if (updated)
                {
                    newDevices = new[] { "OpenVR" };
                }
                else
                {
                    newDevices = new string[devices.Length + 1];
                    for (int i = 0; i < devices.Length; i++)
                    {
                        newDevices[i] = devices[i];
                    }
                    newDevices[devices.Length] = "OpenVR";
                    updated = true;
                }
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
                UnityEditorInternal.VR.VREditor.SetVREnabledDevices(BuildTargetGroup.Standalone, newDevices);
#else
                VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Standalone, newDevices);
#endif
            }

            if (updated)
            {
                Debug.Log("Switching to native OpenVR support.");
            }
        }

        var dlls = new[] { "Plugins/x86/openvr_api.dll", "Plugins/x86_64/openvr_api.dll" };

        foreach (var path in dlls)
        {
            if (!File.Exists(Application.dataPath + "/" + path))
            {
                continue;
            }

            if (AssetDatabase.DeleteAsset("Assets/" + path))
            {
                Debug.Log("Deleting " + path);
            }
            else
            {
                Debug.Log(path + " in use; cannot delete.  Please restart Unity to complete upgrade.");
            }
        }

        EditorApplication.update -= Update;
    }
Example #3
0
        protected virtual void OnGUI()
        {
            GUILayout.BeginVertical();

            //Draw the Title
            GUILayout.Space(10);
            GUILayout.Label("<color=red>Lenovo MirageAR Settings</color>", m_TitleStyle);
            //Image Title
            //var resourcePath = GetResourcePath();
            //var logo = AssetDatabase.LoadAssetAtPath<Texture2D>(resourcePath + "lenovo_logo_red.png");
            //var rect = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box);
            //if (logo)
            //    GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit);

            //Draw help text
            EditorGUILayout.HelpBox("Recommended project settings for LenovoMirageAR!", MessageType.Warning);
#if !UNITY_2017_2
            EditorGUILayout.HelpBox("Recommended Use Unity 2017.2.0f3!", MessageType.Error);
#endif

            DrawSeparator();

            m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);

            //1,Check Build Target
            #region Build Target Setting

            EditorGUILayout.LabelField("Build Target Setting", m_HeaderStyle);

            GUILayout.Space(10);

            BeginGroup();

            EditorGUILayout.BeginHorizontal();

            if (s_BuildTargetNames == null)
            {
                BuildTargetTypes();
            }

            buildTargetPopupIndex = EditorGUILayout.Popup("Build Target", buildTargetPopupIndex, s_BuildTargetNames);

            switch (buildTargetPopupIndex)
            {
            case 0:
                if (EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget_Android)
                {
                    if (GUILayout.Button("Switch", GUILayout.Width(80)))
                    {
                        EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Android, recommended_BuildTarget_Android);
                    }
                }
                break;

            case 1:
                if (EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget_iOS)
                {
                    if (GUILayout.Button("Switch", GUILayout.Width(80)))
                    {
                        EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.iOS, recommended_BuildTarget_iOS);
                    }
                }
                break;

            default:
                break;
            }

            GUILayout.Space(10);

            GUILayout.EndHorizontal();

            EndGroup();

            if (EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget_Android && EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget_iOS)
            {
                //Draw help text
                EditorGUILayout.HelpBox("LenovoMirageAR Only Support Anndroid&iOS,Please Switch To Target Platform First!", MessageType.Error);

                EditorGUILayout.EndScrollView();
                GUILayout.EndVertical();
                return;
            }

            #endregion Build Target Setting

            int numItems = 0;

            DrawSeparator();

            EditorGUILayout.LabelField("Build Settings", m_HeaderStyle);

            GUILayout.Space(10);

            BeginGroup();

            //2,Check Build Setting for Android
            if (EditorUserBuildSettings.activeBuildTarget == recommended_BuildTarget_Android)
            {
                //Orientation Right
                if (!CheckOrientation())
                {
                    ++numItems;

                    GUILayout.Label(defaultOrientation + string.Format(currentValue, PlayerSettings.defaultInterfaceOrientation));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_defaultOrientation)))
                    {
                        SetOrientation();
                    }

                    GUILayout.EndHorizontal();
                }

                //Show SplashScreen
                if (!CheckShowSplashScreen())
                {
                    ++numItems;

                    GUILayout.Label(showSplashScreen + string.Format(currentValue, PlayerSettings.SplashScreen.show));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_showSplashScreen)))
                    {
                        SetShowSplashScreen();
                    }

                    GUILayout.EndHorizontal();
                }

                //Android min SDK
                if (!CheckAndroidMinSDK())
                {
                    ++numItems;

                    GUILayout.Label(AndroidMinSDK + string.Format(currentValue, PlayerSettings.Android.minSdkVersion));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_AndroidMinSDK)))
                    {
                        SetAndroidMinSDK();
                    }

                    GUILayout.EndHorizontal();
                }

                //Andrid Target SDK
                if (!CheckAndroidTargetSDK())
                {
                    ++numItems;

                    GUILayout.Label(AndroidTargetSDK + string.Format(currentValue, PlayerSettings.Android.targetSdkVersion));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_AndroidTargetSDK)))
                    {
                        SetAndroidTargetSDK();
                    }

                    GUILayout.EndHorizontal();
                }

                //XR Setting
                if (!CheckXRSettings(BuildTargetGroup.Android))
                {
                    ++numItems;

                    string value = string.Empty;
                    if (VREditor.GetVREnabledOnTargetGroup(BuildTargetGroup.Android))
                    {
                        value = "VR Enalbe;Devices=";
                        string[] currentSupportDevices = VREditor.GetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Android);
                        if (currentSupportDevices.Length == 0)
                        {
                            value += "Empty";
                        }
                        else
                        {
                            value += string.Join(",", currentSupportDevices);
                        }
                    }
                    else
                    {
                        value = "VR Disable";
                    }

                    GUILayout.Label(XRSettings + string.Format(currentValue, value));

                    GUILayout.BeginHorizontal();

                    string recommend = recommended_VirtualRealitySDKs_First + "," + recommended_VirtualRealitySDKs_Second;
                    if (GUILayout.Button(string.Format(useRecommended, recommend)))
                    {
                        SetXRSettings(BuildTargetGroup.Android);
                    }

                    GUILayout.EndHorizontal();
                }

                //Scrip DefineSymbols
                if (!CheckScriptingDefineSymbols(BuildTargetGroup.Android))
                {
                    ++numItems;

                    GUILayout.Label(string.Format("{0} miss {1}", ScriptingDefineSymbols, recommended_VRTKMirageScriptingDefineSymbols));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_VRTKMirageScriptingDefineSymbols)))
                    {
                        SetScriptingDefineSymbols(BuildTargetGroup.Android);
                    }

                    GUILayout.EndHorizontal();
                }

                //Start Scene
                if (!CheckStartScene())
                {
                    ++numItems;

                    string labelText = "";
                    if (EditorBuildSettings.scenes.Length == 0)
                    {
                        labelText = string.Format(currentValue, "null");
                    }
                    else if (EditorBuildSettings.scenes[0].path != recommended_StartScene)
                    {
                        labelText = string.Format(currentValue, EditorBuildSettings.scenes[0].path);
                    }
                    else if (!EditorBuildSettings.scenes[0].enabled)
                    {
                        labelText = string.Format(currentValue, EditorBuildSettings.scenes[0].path + " disable");
                    }

                    GUILayout.Label(StartScene + labelText);

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_StartScene)))
                    {
                        SetStartScene();
                    }

                    GUILayout.EndHorizontal();
                }
            }
            else if (EditorUserBuildSettings.activeBuildTarget == recommended_BuildTarget_iOS) //2,Check Build Setting for iOS
            {
                //Orientation Right
                if (PlayerSettings.defaultInterfaceOrientation != recommended_defaultOrientation)
                {
                    ++numItems;

                    GUILayout.Label(defaultOrientation + string.Format(currentValue, PlayerSettings.defaultInterfaceOrientation));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_defaultOrientation)))
                    {
                        PlayerSettings.defaultInterfaceOrientation = recommended_defaultOrientation;
                    }

                    GUILayout.EndHorizontal();
                }

                //Show SplashScreen
                if (!CheckShowSplashScreen())
                {
                    ++numItems;

                    GUILayout.Label(showSplashScreen + string.Format(currentValue, PlayerSettings.SplashScreen.show));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_showSplashScreen)))
                    {
                        SetShowSplashScreen();
                    }

                    GUILayout.EndHorizontal();
                }

                //XR Setting
                if (!(CheckXRSettings(BuildTargetGroup.iOS)))
                {
                    ++numItems;

                    string value = string.Empty;
                    if (VREditor.GetVREnabledOnTargetGroup(BuildTargetGroup.iOS))
                    {
                        value = "VR Enalbe;Devices=";
                        string[] currentSupportDevices = VREditor.GetVREnabledDevicesOnTargetGroup(BuildTargetGroup.iOS);
                        if (currentSupportDevices.Length == 0)
                        {
                            value += "Empty";
                        }
                        else
                        {
                            value += string.Join(",", currentSupportDevices);
                        }
                    }
                    else
                    {
                        value = "VR Disable";
                    }

                    GUILayout.Label(XRSettings + string.Format(currentValue, value));

                    GUILayout.BeginHorizontal();

                    string recommend = recommended_VirtualRealitySDKs_First + "," + recommended_VirtualRealitySDKs_Second;
                    if (GUILayout.Button(string.Format(useRecommended, recommend)))
                    {
                        VREditor.SetVREnabledOnTargetGroup(BuildTargetGroup.iOS, true);

                        VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.iOS, VRDevice);
                    }

                    GUILayout.EndHorizontal();
                }

                //Scrip DefineSymbols
                if (!CheckScriptingDefineSymbols(BuildTargetGroup.iOS))
                {
                    ++numItems;

                    GUILayout.Label(string.Format("{0} miss {1}", ScriptingDefineSymbols, recommended_VRTKMirageScriptingDefineSymbols));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_VRTKMirageScriptingDefineSymbols)))
                    {
                        SetScriptingDefineSymbols(BuildTargetGroup.iOS);
                    }

                    GUILayout.EndHorizontal();
                }

                //Start Scene
                if (!CheckStartScene())
                {
                    ++numItems;

                    string labelText = "";
                    if (EditorBuildSettings.scenes.Length == 0)
                    {
                        labelText = string.Format(currentValue, "null");
                    }
                    else if (EditorBuildSettings.scenes[0].path != recommended_StartScene)
                    {
                        labelText = string.Format(currentValue, EditorBuildSettings.scenes[0].path);
                    }
                    else if (!EditorBuildSettings.scenes[0].enabled)
                    {
                        labelText = string.Format(currentValue, EditorBuildSettings.scenes[0].path + " disable");
                    }

                    GUILayout.Label(StartScene + labelText);

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_StartScene)))
                    {
                        SetStartScene();
                    }

                    GUILayout.EndHorizontal();
                }
            }

            EndGroup();

            if (numItems > 0)
            {
                EditorGUILayout.EndScrollView();

                GUILayout.EndVertical();

                GUILayout.FlexibleSpace();

                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Accept All"))
                {
                    SetBuildSettings();
                }

                GUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.Label("<color=green>Set Correctly!</color>", m_TitleStyle);

                EditorGUILayout.EndScrollView();

                GUILayout.EndVertical();

                GUILayout.FlexibleSpace();

                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Close"))
                {
                    Close();
                }

                GUILayout.EndHorizontal();
            }
        }
Example #4
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--;
        }
Example #5
0
    public static string GetVSProjTemplate(string version, Dictionary <WSABuildType, bool> enableDotNetNative)
    {
        bool   flag  = enableDotNetNative[WSABuildType.Debug];
        bool   flag2 = enableDotNetNative[WSABuildType.Release];
        bool   flag3 = enableDotNetNative[WSABuildType.Master];
        string str   = "TRACE;NETFX_CORE;WINDOWS_UWP;UNITY_METRO;UNITY_WSA;UNITY_UWP;UNITY_WSA_10_0";

        if (VREditor.GetVREnabledOnTargetGroup(BuildTargetGroup.WSA) && (Array.IndexOf <string>(VREditor.GetVREnabledDevicesOnTargetGroup(BuildTargetGroup.WSA), "HoloLens") > -1))
        {
            str = str + ";UNITY_HOLOGRAPHIC";
        }
        object[] objArray1 = new object[] {
            "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"14.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\n  <Import Project=\"{4}\" />\n  <PropertyGroup>\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\n    <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>\n    <ProjectGuid>{{13a45c13-3265-47b8-bc48-a553b569df55}}</ProjectGuid>\n    <OutputType>AppContainerExe</OutputType>\n    <AppDesignerFolder>Properties</AppDesignerFolder>\n    <RootNamespace>{6}</RootNamespace>\n    <AssemblyName>{7}</AssemblyName>\n    <DefaultLanguage>en-US</DefaultLanguage>\n    <TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>\n    <TargetPlatformVersion>", version, "</TargetPlatformVersion>\n    <TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>\n    <MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>\n    <EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>\n    <FileAlignment>512</FileAlignment>\n    <ProjectTypeGuids>{{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A}};{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}</ProjectTypeGuids>\n    <PackageCertificateKeyFile>{0}</PackageCertificateKeyFile>\n    <AppxPackageSigningEnabled>true</AppxPackageSigningEnabled>\n    <PlatformShortName>$(Platform)</PlatformShortName>\n{2}    <AllowedReferenceRelatedFileExtensions>\n      $(AllowedReferenceRelatedFileExtensions);\n      _UAP_$(Platform)_$(Configuration)_dotnet.pdb;\n      .pdb;\n    </AllowedReferenceRelatedFileExtensions>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|ARM'\">\n    <DebugSymbols>true</DebugSymbols>\n    <OutputPath>bin\\ARM\\Debug\\</OutputPath>\n    <DefineConstants>DEBUG;", str, "</DefineConstants>\n    <NoWarn>;2008</NoWarn>\n    <DebugType>full</DebugType>\n    <PlatformTarget>ARM</PlatformTarget>\n    <UseVSHostingProcess>false</UseVSHostingProcess>\n    <ErrorReport>prompt</ErrorReport>\n    <Prefer32Bit>true</Prefer32Bit>\n    <UseDotNetNativeToolchain>", flag, "</UseDotNetNativeToolchain>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|ARM'\">\n    <OutputPath>bin\\ARM\\Release\\</OutputPath>\n    <DefineConstants>", str, "</DefineConstants>\n    <Optimize>true</Optimize>\n    <NoWarn>;2008</NoWarn>\n    <DebugType>pdbonly</DebugType>\n    <PlatformTarget>ARM</PlatformTarget>\n    <UseVSHostingProcess>false</UseVSHostingProcess>\n    <ErrorReport>prompt</ErrorReport>\n    <Prefer32Bit>true</Prefer32Bit>\n    <UseDotNetNativeToolchain>", flag2, "</UseDotNetNativeToolchain>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Master|ARM'\">\n    <OutputPath>bin\\ARM\\Master\\</OutputPath>\n    <DefineConstants>", str, "</DefineConstants>\n    <Optimize>true</Optimize>\n    <NoWarn>;2008</NoWarn>\n    <DebugType>pdbonly</DebugType>\n    <PlatformTarget>ARM</PlatformTarget>\n    <UseVSHostingProcess>false</UseVSHostingProcess>\n    <ErrorReport>prompt</ErrorReport>\n    <Prefer32Bit>true</Prefer32Bit>\n    <UseDotNetNativeToolchain>", flag3, "</UseDotNetNativeToolchain>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x64'\">\n    <DebugSymbols>true</DebugSymbols>\n    <OutputPath>bin\\x64\\Debug\\</OutputPath>\n    <DefineConstants>DEBUG;", str,
            "</DefineConstants>\n    <NoWarn>;2008</NoWarn>\n    <DebugType>full</DebugType>\n    <PlatformTarget>x64</PlatformTarget>\n    <UseVSHostingProcess>false</UseVSHostingProcess>\n    <ErrorReport>prompt</ErrorReport>\n    <Prefer32Bit>true</Prefer32Bit>\n    <UseDotNetNativeToolchain>", flag, "</UseDotNetNativeToolchain>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|x64'\">\n    <OutputPath>bin\\x64\\Release\\</OutputPath>\n    <DefineConstants>", str, "</DefineConstants>\n    <Optimize>true</Optimize>\n    <NoWarn>;2008</NoWarn>\n    <DebugType>pdbonly</DebugType>\n    <PlatformTarget>x64</PlatformTarget>\n    <UseVSHostingProcess>false</UseVSHostingProcess>\n    <ErrorReport>prompt</ErrorReport>\n    <Prefer32Bit>true</Prefer32Bit>\n    <UseDotNetNativeToolchain>", flag2, "</UseDotNetNativeToolchain>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Master|x64'\">\n    <OutputPath>bin\\x64\\Master\\</OutputPath>\n    <DefineConstants>", str, "</DefineConstants>\n    <Optimize>true</Optimize>\n    <NoWarn>;2008</NoWarn>\n    <DebugType>pdbonly</DebugType>\n    <PlatformTarget>x64</PlatformTarget>\n    <UseVSHostingProcess>false</UseVSHostingProcess>\n    <ErrorReport>prompt</ErrorReport>\n    <Prefer32Bit>true</Prefer32Bit>\n    <UseDotNetNativeToolchain>", flag3, "</UseDotNetNativeToolchain>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|x86'\">\n    <DebugSymbols>true</DebugSymbols>\n    <OutputPath>bin\\x86\\Debug\\</OutputPath>\n    <DefineConstants>DEBUG;", str, "</DefineConstants>\n    <NoWarn>;2008</NoWarn>\n    <DebugType>full</DebugType>\n    <PlatformTarget>x86</PlatformTarget>\n    <UseVSHostingProcess>false</UseVSHostingProcess>\n    <ErrorReport>prompt</ErrorReport>\n    <Prefer32Bit>true</Prefer32Bit>\n    <UseDotNetNativeToolchain>", flag, "</UseDotNetNativeToolchain>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|x86'\">\n    <OutputPath>bin\\x86\\Release\\</OutputPath>\n    <DefineConstants>", str,
            "</DefineConstants>\n    <Optimize>true</Optimize>\n    <NoWarn>;2008</NoWarn>\n    <DebugType>pdbonly</DebugType>\n    <PlatformTarget>x86</PlatformTarget>\n    <UseVSHostingProcess>false</UseVSHostingProcess>\n    <ErrorReport>prompt</ErrorReport>\n    <Prefer32Bit>true</Prefer32Bit>\n    <UseDotNetNativeToolchain>", flag2, "</UseDotNetNativeToolchain>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Master|x86'\">\n    <OutputPath>bin\\x86\\Master\\</OutputPath>\n    <DefineConstants>", str, "</DefineConstants>\n    <Optimize>true</Optimize>\n    <NoWarn>;2008</NoWarn>\n    <DebugType>pdbonly</DebugType>\n    <PlatformTarget>x86</PlatformTarget>\n    <UseVSHostingProcess>false</UseVSHostingProcess>\n    <ErrorReport>prompt</ErrorReport>\n    <Prefer32Bit>true</Prefer32Bit>\n    <UseDotNetNativeToolchain>", flag3, "</UseDotNetNativeToolchain>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Platform)' == 'x64'\">\n    <UnityBits>64</UnityBits>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Platform)' != 'x64'\">\n    <UnityBits>32</UnityBits>\n  </PropertyGroup>\n  <ItemGroup>\n    <!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->\n    <None Include=\"project.json\" />\n    <SDKReference Include=\"Microsoft.VCLibs, Version=14.0\">\n      <Name>Visual C++ 2015 Runtime for Universal Windows Platform Apps</Name>\n    </SDKReference>\n    <SDKReference Include=\"WindowsMobile, Version=", version, "\">\n      <Name>Windows Mobile Extensions for the UWP</Name>\n    </SDKReference>\n  </ItemGroup>\n  <ItemGroup>\n{1}    <Content Include=\"Data\\**\" />\n  </ItemGroup>\n  <ItemGroup>\n    <AppxManifest Include=\"Package.appxmanifest\">\n      <SubType>Designer</SubType>\n    </AppxManifest>\n    <None Include=\"{0}\" />\n  </ItemGroup>\n{5}  <ItemGroup>\n    <Reference Include=\"UnityPlayer\">\n      <SpecificVersion>False</SpecificVersion>\n      <HintPath>..\\Players\\$(PlatformTarget)\\$(Configuration)\\UnityPlayer.winmd</HintPath>\n    </Reference>\n    <Reference Include=\"WinRTBridge\">\n      <SpecificVersion>False</SpecificVersion>\n      <HintPath>..\\Players\\$(PlatformTarget)\\$(Configuration)\\WinRTBridge.winmd</HintPath>\n    </Reference>\n    <Reference Include=\"BridgeInterface\">\n      <SpecificVersion>False</SpecificVersion>\n      <HintPath>..\\Players\\$(PlatformTarget)\\$(Configuration)\\BridgeInterface.winmd</HintPath>\n    </Reference>\n    <Reference Include=\"UnityEngineDelegates\">\n      <SpecificVersion>False</SpecificVersion>\n      <HintPath>..\\Players\\$(PlatformTarget)\\$(Configuration)\\UnityEngineDelegates.winmd</HintPath>\n    </Reference>\n    <Reference Include=\"UnityEngineProxy\">\n      <SpecificVersion>False</SpecificVersion>\n      <HintPath>..\\Players\\$(PlatformTarget)\\$(Configuration)\\UnityEngineProxy.dll</HintPath>\n    </Reference>\n  </ItemGroup>\n  <PropertyGroup Condition=\" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' \">\n    <VisualStudioVersion>14.0</VisualStudioVersion>\n  </PropertyGroup>\n{3}  <Import Project=\"$(MSBuildExtensionsPath)\\Microsoft\\WindowsXaml\\v$(VisualStudioVersion)\\Microsoft.Windows.UI.Xaml.CSharp.targets\" />\n  <ItemGroup>\n    <UnprocessedFile Include=\"$(ProjectDir)Unprocessed\\*\" />\n  </ItemGroup>\n  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.\n       Other similar extension points exist, see Microsoft.Common.targets.\n  <Target Name=\"BeforeBuild\">\n  </Target>\n\n  -->\n  {8}\n</Project>\n"
        };
        return(string.Concat(objArray1).FixLineEndings());
    }
Example #6
0
        public static void Update()
        {
            if (SteamVR_Settings.instance.autoEnableVR)
            {
                bool enabledVR = false;

                if (PlayerSettings.virtualRealitySupported == false)
                {
                    PlayerSettings.virtualRealitySupported = true;
                    enabledVR = true;
                    Debug.Log("<b>[SteamVR Setup]</b> Enabled virtual reality support in Player Settings. (you can disable this by unchecking Assets/SteamVR/SteamVR_Settings.autoEnableVR)");
                }

                BuildTargetGroup currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup;

#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
                string[] devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevices(currentTarget);
#else
                string[] devices = VREditor.GetVREnabledDevicesOnTargetGroup(currentTarget);
#endif

                bool hasOpenVR = devices.Any(device => string.Equals(device, openVRString, StringComparison.CurrentCultureIgnoreCase));

                if (hasOpenVR == false || enabledVR)
                {
                    string[] newDevices;
                    if (enabledVR && hasOpenVR == false)
                    {
                        newDevices = new string[] { openVRString }; //only list openvr if we enabled it
                    }
                    else
                    {
                        List <string> devicesList = new List <string>(devices); //list openvr as the first option if it wasn't in the list.
                        if (hasOpenVR)
                        {
                            devicesList.Remove(openVRString);
                        }

                        devicesList.Insert(0, openVRString);
                        newDevices = devicesList.ToArray();
                    }

#if (UNITY_5_6 || UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
                    UnityEditorInternal.VR.VREditor.SetVREnabledDevices(currentTarget, newDevices);
#else
                    VREditor.SetVREnabledDevicesOnTargetGroup(currentTarget, newDevices);
#endif
                    Debug.Log("<b>[SteamVR Setup]</b> Added OpenVR to supported VR SDKs list.");
                }

#if UNITY_2018_2_OR_NEWER
                //2018+ requires us to manually add the OpenVR package

                switch (packageState)
                {
                case PackageStates.None:
                    //see if we have the package
                    listRequest  = Client.List(true);
                    packageState = PackageStates.WaitingForList;
                    break;

                case PackageStates.WaitingForList:
                    if (listRequest.IsCompleted)
                    {
                        if (listRequest.Error != null || listRequest.Status == StatusCode.Failure)
                        {
                            packageState = PackageStates.Failed;
                            break;
                        }

                        bool hasPackage = listRequest.Result.Any(package => package.name == openVRPackageString);

                        if (hasPackage == false)
                        {
                            //if we don't have the package - then install it
                            addRequest   = Client.Add(openVRPackageString);
                            packageState = PackageStates.WaitingForAdd;
                            addTryCount++;

                            Debug.Log("<b>[SteamVR Setup]</b> Installing OpenVR package...");
                            addingPackageTime.Start();
                            addingPackageTimeTotal.Start();
                        }
                        else
                        {
                            //if we do have the package do nothing
                            packageState = PackageStates.Installed;     //already installed
                        }
                    }
                    break;

                case PackageStates.WaitingForAdd:
                    if (addRequest.IsCompleted)
                    {
                        if (addRequest.Error != null || addRequest.Status == StatusCode.Failure)
                        {
                            packageState = PackageStates.Failed;
                            break;
                        }
                        else
                        {
                            //if the package manager says we added it then confirm that with the list
                            listRequest  = Client.List(true);
                            packageState = PackageStates.WaitingForAddConfirm;
                        }
                    }
                    else
                    {
                        if (addingPackageTimeTotal.Elapsed.TotalSeconds > estimatedTimeToInstall)
                        {
                            estimatedTimeToInstall *= 2;     // :)
                        }
                        string dialogText;
                        if (addTryCount == 1)
                        {
                            dialogText = "Installing OpenVR from Unity Package Manager...";
                        }
                        else
                        {
                            dialogText = "Retrying OpenVR install from Unity Package Manager...";
                        }

                        bool cancel = EditorUtility.DisplayCancelableProgressBar("SteamVR", dialogText, (float)addingPackageTimeTotal.Elapsed.TotalSeconds / estimatedTimeToInstall);
                        if (cancel)
                        {
                            packageState = PackageStates.Failed;
                        }

                        if (addingPackageTime.Elapsed.TotalSeconds > 10)
                        {
                            Debug.Log("<b>[SteamVR Setup]</b> Waiting for package manager to install OpenVR package...");
                            addingPackageTime.Stop();
                            addingPackageTime.Reset();
                            addingPackageTime.Start();
                        }
                    }
                    break;

                case PackageStates.WaitingForAddConfirm:
                    if (listRequest.IsCompleted)
                    {
                        if (listRequest.Error != null)
                        {
                            packageState = PackageStates.Failed;
                            break;
                        }

                        bool hasPackage = listRequest.Result.Any(package => package.name == openVRPackageString);

                        if (hasPackage == false)
                        {
                            if (addTryCount == 1)
                            {
                                addRequest   = Client.Add(openVRPackageString);
                                packageState = PackageStates.WaitingForAdd;
                                addTryCount++;

                                Debug.Log("<b>[SteamVR Setup]</b> Retrying OpenVR package install...");
                            }
                            else
                            {
                                packageState = PackageStates.Failed;
                            }
                        }
                        else
                        {
                            packageState = PackageStates.Installed;     //installed successfully

                            Debug.Log("<b>[SteamVR Setup]</b> Successfully installed OpenVR package.");
                        }
                    }
                    break;
                }

                if (packageState == PackageStates.Failed || packageState == PackageStates.Installed)
                {
                    addingPackageTime.Stop();
                    addingPackageTimeTotal.Stop();
                    EditorUtility.ClearProgressBar();
                    EditorApplication.update -= Update; //we're done trying to auto-enable vr

                    if (packageState == PackageStates.Failed)
                    {
                        string failtext = "The Unity Package Manager failed to automatically install the OpenVR package. Please open the Package Manager Window and try to install it manually.";
                        EditorUtility.DisplayDialog("SteamVR", failtext, "Ok");
                        Debug.Log("<b>[SteamVR Setup]</b> " + failtext);
                    }
                }
#else
                UnityEditor.EditorApplication.update -= Update;
#endif
            }
        }