Пример #1
0
        static void RunGetVersion(
            PackageManager.Requests.ListRequest listRequest,
            Action <string> onGetVersionCompleted)
        {
            EditorDispatcher.Dispatch(() =>
            {
                if (!listRequest.IsCompleted)
                {
                    RunGetVersion(listRequest, onGetVersionCompleted);
                    return;
                }

                string pluginVersion = string.Empty;

                if (listRequest.Status == PackageManager.StatusCode.Success &&
                    listRequest.Result != null)
                {
                    PackageManager.PackageInfo collabPackage = listRequest.Result
                                                               .FirstOrDefault(package => package.name == mCollabPackageName);

                    if (collabPackage != null)
                    {
                        pluginVersion = collabPackage.version;
                    }
                }

                onGetVersionCompleted.Invoke(pluginVersion);
            });
        }
        internal static SearchProvider CreateProvider()
        {
            return(new SearchProvider(type, displayName)
            {
                priority = 90,
                filterId = "pkg:",
                isExplicitProvider = true,

                onEnable = () =>
                {
                    s_ListRequest = UnityEditor.PackageManager.Client.List(true);
                    s_SearchRequest = UnityEditor.PackageManager.Client.SearchAll();
                },

                onDisable = () =>
                {
                    s_ListRequest = null;
                    s_SearchRequest = null;
                },

                fetchItems = (context, items, provider) => SearchPackages(context, provider),

                fetchThumbnail = (item, context) => (item.thumbnail = item.score == 0 ? Icons.packageUpdate : Icons.packageInstalled)
            });
        }
        public static void Update()
        {
            if (!SteamVR_Settings.instance.autoEnableVR || Application.isPlaying)
            {
                End();
            }

            if (UnityEditor.PlayerSettings.virtualRealitySupported == false)
            {
                ShowDialog();
                return;
            }

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

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

                    string packageName = unityOpenVRPackageString;

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

                    if (hasPackage == false)
                    {
                        ShowDialog();
                    }
                    else     //if we do have the package, do nothing
                    {
                        End();
                    }
                }
                break;

            case PackageStates.Failed:
                End();

                string failtext = "The Unity Package Manager failed to verify the OpenVR package. If you were trying to install it you may need to open the Package Manager Window and try to install it manually.";
                UnityEditor.EditorUtility.DisplayDialog("SteamVR", failtext, "Ok");
                Debug.Log("<b>[SteamVR Setup]</b> " + failtext);
                break;
            }
        }
Пример #4
0
 public static void LoadPackageDefinitions(bool forceNew = false)
 {
     if (forceNew || !GPUInstancerConstants.gpuiSettings.packagesLoaded)
     {
         _packageListRequest = UnityEditor.PackageManager.Client.List(true);
         GPUInstancerConstants.gpuiSettings.isHDRP = false;
         GPUInstancerConstants.gpuiSettings.isLWRP = false;
         GPUInstancerConstants.gpuiSettings.isShaderGraphPresent = false;
         EditorApplication.update -= PackageListRequestHandler;
         EditorApplication.update += PackageListRequestHandler;
     }
 }
Пример #5
0
 private static void PackageListRequestHandler()
 {
     try
     {
         if (_packageListRequest != null)
         {
             if (!_packageListRequest.IsCompleted)
             {
                 return;
             }
             if (_packageListRequest.Result != null)
             {
                 foreach (var item in _packageListRequest.Result)
                 {
                     if (item.name.Contains("com.unity.render-pipelines.high-definition"))
                     {
                         GPUInstancerConstants.gpuiSettings.isHDRP = true;
                         Debug.Log("GPUI detected HD Render Pipeline.");
                     }
                     else if (item.name.Contains("com.unity.render-pipelines.lightweight"))
                     {
                         GPUInstancerConstants.gpuiSettings.isLWRP = true;
                         Debug.Log("GPUI detected LW Render Pipeline.");
                     }
                     else if (item.name.Contains("com.unity.render-pipelines.universal"))
                     {
                         GPUInstancerConstants.gpuiSettings.isURP = true;
                         Debug.Log("GPUI detected Universal Render Pipeline.");
                     }
                     else if (item.name.Contains("com.unity.shadergraph"))
                     {
                         GPUInstancerConstants.gpuiSettings.isShaderGraphPresent = true;
                         Debug.Log("GPUI detected ShaderGraph package.");
                     }
                 }
                 if (GPUInstancerConstants.gpuiSettings.IsStandardRenderPipeline())
                 {
                     Debug.Log("GPUI detected Standard Render Pipeline.");
                 }
                 EditorUtility.SetDirty(GPUInstancerConstants.gpuiSettings);
             }
         }
     }
     catch (Exception) { }
     _packageListRequest = null;
     GPUInstancerConstants.gpuiSettings.packagesLoaded = true;
     EditorApplication.update -= PackageListRequestHandler;
 }
Пример #6
0
        /** 作成。
         *
         *      a_offlinemode					: オフラインモード
         *      a_includeindirectdependencies	: 間接的機な依存関係も含める。
         *
         */
        public static System.Collections.Generic.List <UnityEditor.PackageManager.PackageInfo> Create(bool a_offlinemode, bool a_includeindirectdependencies)
        {
                        #pragma warning disable 0162
            UnityEditor.PackageManager.Requests.ListRequest t_request = UnityEditor.PackageManager.Client.List(a_offlinemode, a_includeindirectdependencies);
            while (true)
            {
                System.Threading.Thread.Sleep(1);
                if (t_request.Status != UnityEditor.PackageManager.StatusCode.InProgress)
                {
                    switch (t_request.Status)
                    {
                    case UnityEditor.PackageManager.StatusCode.InProgress:
                    {
                    } break;

                    case UnityEditor.PackageManager.StatusCode.Failure:
                    {
                                                        #if (DEF_BLUEBACK_ASSETLIB_ASSERT)
                        DebugTool.Assert(false, t_request.Error.message);
                                                        #endif
                        return(null);
                    } break;

                    case UnityEditor.PackageManager.StatusCode.Success:
                    {
                        System.Collections.Generic.List <UnityEditor.PackageManager.PackageInfo> t_list = new System.Collections.Generic.List <UnityEditor.PackageManager.PackageInfo>();
                        foreach (UnityEditor.PackageManager.PackageInfo t_item in t_request.Result)
                        {
                            t_list.Add(t_item);
                        }
                        return(t_list);
                    } break;;

                    default:
                    {
                                                        #if (DEF_BLUEBACK_ASSETLIB_ASSERT)
                        DebugTool.Assert(false, "error");
                                                        #endif
                        return(null);
                    } break;
                    }
                }
            }
                        #pragma warning restore
        }
Пример #7
0
        public static void RetreivePackageList()
        {
            UnityEditor.PackageManager.Requests.ListRequest listRequest = Client.List(true);

            while (listRequest.Status == StatusCode.InProgress)
            {
                //Waiting...
            }

            if (listRequest.Status == StatusCode.Failure)
            {
                Debug.LogError("Failed to retreived packages from Package Manager...");
            }

            PackageCollection packageInfos = listRequest.Result;

            packages = listRequest.Result.ToList();
        }
Пример #8
0
        private void OnEnable()
        {
#if UNITY_EDITOR
#if UNITY_2019_4_OR_NEWER
            // Check for unity XR management package
            packmanRequest            = UnityEditor.PackageManager.Client.List(); // List packages installed for the project
            EditorApplication.update += VRManagerPackmanCheck;
#else
            SymbolDefineUtils.RemoveDefine("SSAA_XR");
#endif
            if (!EditorApplication.isPlaying)
            {
                return;
            }
#endif

            // Handle original scaling
            // Handle the resolution multiplier
            if (!VRDeviceAnyActive())
            {
                throw new Exception("VRDevice not present or not detected");
            }

            // Cache old resolution before using SSAA .This solves issues with more exotic
            // headsets that use non 1x scaling by default such as Playstation VR
            VRDeviceCacheRes();

            // Decide if we initialize or just re-enable
            if (!Initialized)
            {
                Start();
            }
            else if (Pipeline == RenderPipelineUtils.PipelineType.BuiltInPipeline)
            {
                SetupDownsamplerCommandBuffer();
            }

            // Adaptive res startup
            StartCoroutine(UpdateAdaptiveRes());
        }
Пример #9
0
        public static void Update()
        {
            if (SteamVR_Settings.instance.autoEnableVR)
            {
                bool enabledVR = false;

                if (UnityEditor.PlayerSettings.virtualRealitySupported == false)
                {
                    UnityEditor.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)");
                }

                UnityEditor.BuildTargetGroup currentTarget = UnityEditor.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 = UnityEditorInternal.VR.VREditor.GetVREnabledDevicesOnTargetGroup(currentTarget);
#endif

                bool hasOpenVR = devices.Any(device => string.Equals(device, openVRString, System.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
                    UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(currentTarget, newDevices);
#endif
                    Debug.Log("<b>[SteamVR Setup]</b> Added OpenVR to supported VR SDKs list.");
                }

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

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

                case PackageStates.WaitingForList:
                    if (listRequest.IsCompleted)
                    {
                        if (listRequest.Error != null || listRequest.Status == UnityEditor.PackageManager.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   = UnityEditor.PackageManager.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 == UnityEditor.PackageManager.StatusCode.Failure)
                        {
                            packageState = PackageStates.Failed;
                            break;
                        }
                        else
                        {
                            //if the package manager says we added it then confirm that with the list
                            listRequest  = UnityEditor.PackageManager.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 = UnityEditor.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   = UnityEditor.PackageManager.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();
                    UnityEditor.EditorUtility.ClearProgressBar();
                    UnityEditor.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.";
                        UnityEditor.EditorUtility.DisplayDialog("SteamVR", failtext, "Ok");
                        Debug.Log("<b>[SteamVR Setup]</b> " + failtext);
                    }
                }
#else
                UnityEditor.EditorApplication.update -= Update;
#endif
            }
        }
Пример #10
0
        internal static void GetVersion(Action <string> onGetVersionCompleted)
        {
            PackageManager.Requests.ListRequest listRequest = PackageManager.Client.List(true);

            RunGetVersion(listRequest, onGetVersionCompleted);
        }
        public static void Update()
        {
            if (!SteamVR_Settings.instance.autoEnableVR || Application.isPlaying)
            {
                End();
            }

            if (UnityEditor.PlayerSettings.virtualRealitySupported == false)
            {
                if (forceInstall == false)
                {
                    int shouldInstall = UnityEditor.EditorUtility.DisplayDialogComplex("SteamVR", "Would you like to enable Virtual Reality mode?\n\nThis will install the OpenVR for Desktop package and enable it in Player Settings.", "Yes", "No, and don't ask again", "No");

                    switch (shouldInstall)
                    {
                    case 0:     //yes
                        UnityEditor.PlayerSettings.virtualRealitySupported = true;
                        break;

                    case 1:     //no
                        End();
                        return;

                    case 2:     //no, don't ask
                        SteamVR_Settings.instance.autoEnableVR = false;
                        SteamVR_Settings.Save();
                        End();
                        return;
                    }
                }

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

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

            case PackageStates.WaitingForList:
                if (listRequest == null)
                {
                    listRequest = UnityEditor.PackageManager.Client.List(true);
                    updateState = PackageStates.WaitingForList;
                }
                else if (listRequest.IsCompleted)
                {
                    if (listRequest.Error != null || listRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
                    {
                        updateState = PackageStates.Failed;
                        break;
                    }

                    string packageName = unityOpenVRPackageString;

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

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

                        Debug.Log("<b>[SteamVR Setup]</b> Installing OpenVR package...");
                        addingPackageTime.Start();
                        addingPackageTimeTotal.Start();
                    }
                    else
                    {
                        //if we do have the package, make sure it's enabled.
                        updateState = PackageStates.Installed;     //already installed
                    }
                }
                break;

            case PackageStates.WaitingForAdd:
                if (addRequest.IsCompleted)
                {
                    if (addRequest.Error != null || addRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
                    {
                        updateState = PackageStates.Failed;
                        break;
                    }
                    else
                    {
                        //if the package manager says we added it then confirm that with the list
                        listRequest = UnityEditor.PackageManager.Client.List(true);
                        updateState = PackageStates.WaitingForAddConfirm;
                    }
                }
                else
                {
                    if (addingPackageTimeTotal.Elapsed.TotalSeconds > estimatedTimeToInstall)
                    {
                        if (addTryCount == 1)
                        {
                            estimatedTimeToInstall *= 2;     //give us more time to retry
                        }
                        else
                        {
                            updateState = PackageStates.Failed;
                        }
                    }

                    string dialogText;
                    if (addTryCount == 1)
                    {
                        dialogText = "Installing OpenVR from Unity Package Manager...";
                    }
                    else
                    {
                        dialogText = "Retrying OpenVR install from Unity Package Manager...";
                    }

                    bool cancel = UnityEditor.EditorUtility.DisplayCancelableProgressBar("SteamVR", dialogText, (float)addingPackageTimeTotal.Elapsed.TotalSeconds / estimatedTimeToInstall);
                    if (cancel)
                    {
                        updateState = 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)
                    {
                        updateState = PackageStates.Failed;
                        break;
                    }
                    string packageName = unityOpenVRPackageString;

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

                    if (hasPackage == false)
                    {
                        if (addTryCount == 1)
                        {
                            addRequest  = UnityEditor.PackageManager.Client.Add(packageName);
                            updateState = PackageStates.WaitingForAdd;
                            addTryCount++;

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

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

            case PackageStates.Installed:
                UnityEditor.BuildTargetGroup currentTarget = UnityEditor.EditorUserBuildSettings.selectedBuildTargetGroup;

                string[] devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevicesOnTargetGroup(currentTarget);

                bool hasOpenVR = false;
                bool isFirst   = false;

                if (devices.Length != 0)
                {
                    int index = Array.FindIndex(devices, device => string.Equals(device, openVRString, System.StringComparison.CurrentCultureIgnoreCase));
                    hasOpenVR = index != -1;
                    isFirst   = index == 0;
                }

                //list openvr as the first option if it was in the list already
                List <string> devicesList = new List <string>(devices);
                if (isFirst == false)
                {
                    if (hasOpenVR == true)
                    {
                        devicesList.Remove(openVRString);
                    }

                    devicesList.Insert(0, openVRString);
                    string[] newDevices = devicesList.ToArray();

                    UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(currentTarget, newDevices);
                    Debug.Log("<b>[SteamVR Setup]</b> Added OpenVR to supported VR SDKs list.");
                }

                End();
                break;

            case PackageStates.Failed:
                End();

                string failtext = "The Unity Package Manager failed to automatically install the OpenVR Desktop package. Please open the Package Manager Window and try to install it manually.";
                UnityEditor.EditorUtility.DisplayDialog("SteamVR", failtext, "Ok");
                Debug.Log("<b>[SteamVR Setup]</b> " + failtext);
                break;
            }
        }
Пример #12
0
 private static void Load()
 {
     listRequest = UnityEditor.PackageManager.Client.List(true);
     EditorApplication.update += Update;
 }
Пример #13
0
        private static void MenuITem_Tool_ComparePackagWithLocal()
        {
            UnityEditor.PackageManager.Requests.ListRequest t_request = UnityEditor.PackageManager.Client.List(true, true);
            while (t_request.Status == UnityEditor.PackageManager.StatusCode.InProgress)
            {
                System.Threading.Thread.Sleep(1);
            }
            if (t_request.Status == UnityEditor.PackageManager.StatusCode.Failure)
            {
                UnityEngine.Debug.LogError(t_request.Error.message);
                return;
            }
            else
            {
                foreach (UnityEditor.PackageManager.PackageInfo t_packageinfo in t_request.Result)
                {
                    if (System.Text.RegularExpressions.Regex.IsMatch(t_packageinfo.name, "^blueback\\.[a-zA-Z0-9_\\.]*$", System.Text.RegularExpressions.RegexOptions.Multiline) == true)
                    {
                        string t_local_path = null;
                        {
                            switch (t_packageinfo.name)
                            {
                            case "blueback.assetlib":                       t_local_path += "..\\..\\..\\" + "UpmAssetLib" + "\\" + "BlueBackAssetLib" + "\\Assets\\UPM"; break;

                            case "blueback.audio":                          t_local_path += "..\\..\\..\\" + "UpmAudio" + "\\" + "BlueBackAudio" + "\\Assets\\UPM"; break;

                            case "blueback.code":                           t_local_path += "..\\..\\..\\" + "UpmCode" + "\\" + "BlueBackCode" + "\\Assets\\UPM"; break;

                            case "blueback.excel":                          t_local_path += "..\\..\\..\\" + "UpmExcel" + "\\" + "BlueBackExcel" + "\\Assets\\UPM"; break;

                            case "blueback.jsonitem":                       t_local_path += "..\\..\\..\\" + "UpmJsonItem" + "\\" + "BlueBackJsonItem" + "\\Assets\\UPM"; break;

                            case "blueback.mouse":                          t_local_path += "..\\..\\..\\" + "UpmMouse" + "\\" + "BlueBackMouse" + "\\Assets\\UPM"; break;

                            case "blueback.pad":                            t_local_path += "..\\..\\..\\" + "UpmPad" + "\\" + "BlueBackPad" + "\\Assets\\UPM"; break;

                            case "blueback.scene":                          t_local_path += "..\\..\\..\\" + "UpmScene" + "\\" + "BlueBackScene" + "\\Assets\\UPM"; break;

                            case "blueback.slackwebapi":            t_local_path += "..\\..\\..\\" + "UpmSlackWebApi" + "\\" + "BlueBackSlackWebApi" + "\\Assets\\UPM"; break;

                            case "blueback.testlib":                        t_local_path += "..\\..\\..\\" + "UpmTestLib" + "\\" + "BlueBackTestLib" + "\\Assets\\UPM"; break;

                            case "blueback.timescale":                      t_local_path += "..\\..\\..\\" + "UpmTimeScale" + "\\" + "BlueBackTimeScale" + "\\Assets\\UPM"; break;

                            case "blueback.unityplayerloop":        t_local_path += "..\\..\\..\\" + "UpmUnityPlayerLoop" + "\\" + "BlueBackUnityPlayerLoop" + "\\Assets\\UPM"; break;

                            case "blueback.versionmanager":         t_local_path += "..\\..\\..\\" + "UpmVersionManager" + "\\" + "BlueBackVersionManager" + "\\Assets\\UPM"; break;
                            }
                        }

                        if (t_local_path != null)
                        {
                            UnityEngine.Debug.Log(t_packageinfo.name + " : " + t_packageinfo.displayName);

                            System.Collections.Generic.Dictionary <string, CompareItem> t_structure_list = new System.Collections.Generic.Dictionary <string, CompareItem>();

                            {
                                System.Collections.Generic.List <string> t_filelist_package = BlueBack.AssetLib.Editor.CreateFileNameListWithFullPath.CreateAll(t_packageinfo.resolvedPath);
                                foreach (string t_path_package in t_filelist_package)
                                {
                                    string t_key = t_path_package.Substring(t_packageinfo.resolvedPath.Length + 1);
                                    t_structure_list.Add(t_key, new CompareItem()
                                    {
                                        path_local   = null,
                                        path_package = t_path_package
                                    });
                                }
                            }

                            {
                                System.Collections.Generic.List <string> t_filelist_local = BlueBack.AssetLib.Editor.CreateFileNameListWithAssetsPath.CreateAll(t_local_path);
                                foreach (string t_path_local in t_filelist_local)
                                {
                                    string t_key = t_path_local.Substring(t_local_path.Length + 1);
                                    if (t_structure_list.TryGetValue(t_key, out CompareItem t_compareitem) == true)
                                    {
                                        t_compareitem.path_local = t_path_local;
                                    }
                                    else
                                    {
                                        t_structure_list.Add(t_key, new CompareItem()
                                        {
                                            path_local   = t_path_local,
                                            path_package = null
                                        });
                                    }
                                }
                            }

                            foreach (System.Collections.Generic.KeyValuePair <string, CompareItem> t_item in t_structure_list)
                            {
                                switch (t_item.Key)
                                {
                                case "package-lock.json":
                                case "package-lock.json.meta":
                                {
                                } continue;
                                }

                                if ((t_item.Value.path_local == null) || (t_item.Value.path_package == null))
                                {
                                    //ファイル構成に違い。
                                    UnityEngine.Debug.LogError(t_packageinfo.displayName + " : different structure : " + t_item.Key + "\n" + t_item.Value.path_local + "\n" + t_item.Value.path_package);
                                }
                                else
                                {
                                    {
                                        switch (System.IO.Path.GetExtension(t_item.Key))
                                        {
                                        case ".meta":
                                        case ".json":
                                        case ".asmdef":
                                        case ".unity":
                                        case ".prefab":
                                        case ".mesh":
                                        case ".mat":
                                        case ".mixer":
                                        {
                                            string t_text_package = BlueBack.AssetLib.Editor.LoadTextWithFullPath.Load(t_item.Value.path_package).Replace("\r\n", "\n");
                                            string t_text_local   = BlueBack.AssetLib.Editor.LoadTextWithAssetsPath.Load(t_item.Value.path_local).Replace("\r\n", "\n");
                                            if (t_text_package != t_text_local)
                                            {
                                                for (int ii = 0; ii < t_text_package.Length; ii++)
                                                {
                                                    if (t_text_package[ii] != t_text_local[ii])
                                                    {
                                                        UnityEngine.Debug.LogError(ii.ToString() + " : " + t_text_package.Substring(UnityEngine.Mathf.Max(0, ii - 5), 10));
                                                        break;
                                                    }
                                                }

                                                //テキストに差異。
                                                UnityEngine.Debug.LogError(t_packageinfo.displayName + " : different text : " + t_item.Key + "\n" + t_item.Value.path_local + "\n" + t_item.Value.path_package + "\n" + t_text_package + "\n" + t_text_local);
                                            }
                                        } break;

                                        default:
                                        {
                                            byte[] t_binary_package = BlueBack.AssetLib.Editor.LoadBinaryWithFullPath.Load(t_item.Value.path_package);
                                            byte[] t_binary_local   = BlueBack.AssetLib.Editor.LoadBinaryWithAssetsPath.Load(t_item.Value.path_local);

                                            if ((t_binary_package != null) && (t_binary_local != null))
                                            {
                                                if (t_binary_package.Length == t_binary_local.Length)
                                                {
                                                    bool t_different = false;
                                                    for (long ii = 0; ii < t_binary_package.Length; ii++)
                                                    {
                                                        if (t_binary_package[ii] != t_binary_local[ii])
                                                        {
                                                            t_different = true;
                                                        }
                                                    }
                                                    if (t_different == true)
                                                    {
                                                        //バイナリに差異。
                                                        UnityEngine.Debug.LogError(t_packageinfo.displayName + " : different : " + t_item.Key + "\n" + t_item.Value.path_local + "\n" + t_item.Value.path_package);
                                                    }
                                                }
                                                else
                                                {
                                                    //サイズに差異。
                                                    UnityEngine.Debug.LogError(t_packageinfo.displayName + " : different size : " + t_item.Key + "\n" + t_item.Value.path_local + "\n" + t_item.Value.path_package);
                                                }
                                            }
                                            else
                                            {
                                                //読み込みエラー。
                                                UnityEngine.Debug.LogError(t_packageinfo.displayName + " : read error : " + t_item.Key + "\n" + t_item.Value.path_local + "\n" + t_item.Value.path_package);
                                            }
                                        } break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #14
0
 private static void CheckPackageInstall()
 {
     EditorApplication.update -= CheckPackageInstall;
     listResponse              = UnityEditor.PackageManager.Client.List(true);
     EditorApplication.update += PackageListResponse;
 }
Пример #15
0
        public static void Update()
        {
            if (SteamVR_Settings.instance.autoEnableVR)
            {
                bool enabledVR = false;

#if UNITY_2020_1_OR_NEWER || OPENVR_XR_API
#if !UNITY_2020_2_OR_NEWER
                if (UnityEditor.PlayerSettings.virtualRealitySupported == true)
                {
                    UnityEditor.PlayerSettings.virtualRealitySupported = false;
                    enabledVR = true;
                    Debug.Log("<b>[SteamVR Setup]</b> Disabled virtual reality support in Player Settings. <b>Because you're using XR Manager. Make sure OpenVR Loader is enabled in XR Manager UI.</b> (you can disable this by unchecking Assets/SteamVR/SteamVR_Settings.autoEnableVR)");
                }
#endif

#if OPENVR_XR_API
                //little hacky, but the public methods weren't working.

                if (isLoaderAssignedMethodParameters == null)
                {
                    isLoaderAssignedMethodParameters = new Type[] { typeof(string), typeof(BuildTargetGroup) }
                }
                ;
                if (isLoaderAssignedCallParameters == null)
                {
                    isLoaderAssignedCallParameters = new object[] { valveOpenVRLoaderType, BuildTargetGroup.Standalone }
                }
                ;
                if (isLoaderAssigned == null)
                {
                    isLoaderAssigned = GetMethod("IsLoaderAssigned", isLoaderAssignedMethodParameters);
                }

                if (installPackageAndAssignLoaderForBuildTarget == null)
                {
                    installPackageAndAssignLoaderForBuildTarget = GetMethod("InstallPackageAndAssignLoaderForBuildTarget");
                }

                if (isLoaderAssigned != null && installPackageAndAssignLoaderForBuildTarget != null)
                {
                    bool isAssigned = (bool)isLoaderAssigned.Invoke(null, isLoaderAssignedCallParameters);

                    if (isAssigned == false)
                    {
                        if (enabledLoaderKey == null)
                        {
                            enabledLoaderKey = string.Format(valveEnabledLoaderKeyTemplate, SteamVR_Settings.instance.editorAppKey);
                        }

                        if (EditorPrefs.HasKey(enabledLoaderKey) == false)
                        {
                            installPackageAndAssignLoaderForBuildTarget.Invoke(null, new object[] { valveOpenVRPackageString, valveOpenVRLoaderType, BuildTargetGroup.Standalone });

                            isAssigned = (bool)isLoaderAssigned.Invoke(null, isLoaderAssignedCallParameters);
                            if (isAssigned)
                            {
                                EditorPrefs.SetBool(enabledLoaderKey, true);

                                Debug.Log("<b>[SteamVR Setup]</b> Enabled OpenVR Loader in XR Management");
                                UnityEditor.EditorApplication.update -= Update;
                            }
                        }
                        else
                        {
                            UnityEditor.EditorApplication.update -= Update;
                        }
                    }
                    else
                    {
                        UnityEditor.EditorApplication.update -= Update;
                    }
                }
#elif UNITY_2020_1_OR_NEWER
                StartAutoUpdater();
#endif
#else
                if (UnityEditor.PlayerSettings.virtualRealitySupported == false)
                {
                    UnityEditor.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)");
                }

                UnityEditor.BuildTargetGroup currentTarget = UnityEditor.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 = UnityEditorInternal.VR.VREditor.GetVREnabledDevicesOnTargetGroup(currentTarget);
#endif

                bool hasOpenVR = devices.Any(device => string.Equals(device, openVRString, System.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
                    UnityEditorInternal.VR.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
                //2020.1+ has a separate script that does installs

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

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

                        string packageName = null;

                        packageName = unityOpenVRPackageString;

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

                        if (hasPackage == false)
                        {
                            //if we don't have the package - then install it
                            addRequest   = UnityEditor.PackageManager.Client.Add(packageName);
                            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 == UnityEditor.PackageManager.StatusCode.Failure)
                        {
                            packageState = PackageStates.Failed;
                            break;
                        }
                        else
                        {
                            //if the package manager says we added it then confirm that with the list
                            listRequest  = UnityEditor.PackageManager.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 = UnityEditor.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;
                        }
                        string packageName = unityOpenVRPackageString;

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

                        if (hasPackage == false)
                        {
                            if (addTryCount == 1)
                            {
                                addRequest   = UnityEditor.PackageManager.Client.Add(packageName);
                                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();
                    UnityEditor.EditorUtility.ClearProgressBar();
                    UnityEditor.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.";
                        UnityEditor.EditorUtility.DisplayDialog("SteamVR", failtext, "Ok");
                        Debug.Log("<b>[SteamVR Setup]</b> " + failtext);
                    }
                }
#else
                UnityEditor.EditorApplication.update -= Update;
#endif
#endif
            }
        }