Example #1
0
        void UpdatePackageInstallationQuery()
        {
            Repaint();
            EditorApplication.update -= UpdatePackageInstallationQuery;

            if (m_InstallingPackage == null)
            {
                return;
            }

            if (!m_InstallingPackage.IsCompleted)
            {
                EditorApplication.update += UpdatePackageInstallationQuery;
                return;
            }

            if (m_InstallingPackage.Status != StatusCode.Success)
            {
                // TODO Track installation error...
                m_InstallingPackage     = null;
                m_InstallingPackageName = "";
                return;
            }

            try
            {
                PackageManager.PackageInfo pinfo = m_InstallingPackage.Result;

                XRPackageInformation xrpinfo;
                bool addPackage = false;

                if (!m_XRPackages.TryGetValue(pinfo.name, out xrpinfo))
                {
                    xrpinfo.uninstalledPackageInfo = pinfo;
                    xrpinfo.isInstalled            = false;
                    addPackage = true;
                }

                string tempPath    = $"Packages/{pinfo.name}/package.json";
                var    packagePath = Path.GetFullPath(tempPath);

                if (File.Exists(packagePath))
                {
                    xrpinfo.isInstalled     = true;
                    m_HasInstalledProviders = true;
                }

                if (addPackage)
                {
                    m_XRPackages.Add(pinfo.name, xrpinfo);
                }
            }
            catch (Exception)
            {
                // TODO Track creation error...
            }

            m_InstallingPackage     = null;
            m_InstallingPackageName = "";
        }
 public override void OnGUI(string searchContext)
 {
     GUILayout.Space(15);
     if (m_AddManagementRequest != null)
     {
         if (m_AddManagementRequest.IsCompleted)
         {
             EditorGUILayout.LabelField(Content.s_DownloadingText);
         }
         else
         {
             EditorGUILayout.LabelField(Content.s_InstallingText);
         }
     }
     else
     {
         HelpBox(L10n.Tr(Content.s_InstallationHelpText), L10n.Tr("Read more"), () =>
         {
             System.Diagnostics.Process.Start(Content.s_DocUri.AbsoluteUri);
         });
         GUILayout.Space(15);
         if (GUILayout.Button(Content.s_AddAdaptivePerformance))
         {
             m_AddManagementRequest = PackageManager.Client.Add(s_ManagementPackageId);
         }
     }
 }
Example #3
0
        void DownloadLoaderMenuSelected(object data)
        {
            var info = (CuratedInfo)data;

            m_CurrentDownloadRequest = PackageManager.Client.Add(info.PackageName);
            EditorPrefs.SetString(s_DownloadingPackageKey, info.PackageName);
            AssetDatabase.Refresh();
        }
        private void DisplayProviderSelectionUI()
        {
            EditorGUI.BeginDisabledGroup(!m_HasProviders);
            EditorGUILayout.BeginVertical();
            EditorGUILayout.LabelField(Content.s_ProvidersToInstall, GetStyle("BoldLabel"));
            EditorGUILayout.Space();

            using (new EditorGUILayout.VerticalScope(GUI.skin.box, GUILayout.ExpandWidth(true)))
            {
                if (!m_HasCompletedRequest)
                {
                    EditorGUILayout.LabelField(Content.s_LookingForProviders);
                }
                else
                {
                    if (m_XRPackages.Any())
                    {
                        bool isInstalling = !String.IsNullOrEmpty(m_InstallingPackageName);

                        EditorGUI.BeginDisabledGroup(isInstalling);
                        foreach (var kv in m_XRPackages)
                        {
                            var isInstalled = kv.Value.isInstalled;
                            var pinfo       = kv.Value.uninstalledPackageInfo;
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField(pinfo.displayName, GetStyle("label"));
                            if (isInstalling && String.Compare(m_InstallingPackageName, pinfo.name) == 0)
                            {
                                EditorGUILayout.LabelField(Content.s_InstallingPackage, GUILayout.Width(100));
                            }
                            else if (isInstalled)
                            {
                                EditorGUILayout.LabelField(Content.s_InstalledPackage, GUILayout.Width(100));
                            }
                            else
                            {
                                if (GUILayout.Button(Content.s_InstallPackage, GUILayout.Width(100)))
                                {
                                    m_InstallingPackageName   = pinfo.name;
                                    m_InstallingPackage       = PackageManager.Client.Add(pinfo.name);
                                    EditorApplication.update += UpdatePackageInstallationQuery;
                                }
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                        EditorGUI.EndDisabledGroup();
                    }
                    else
                    {
                        EditorGUILayout.LabelField(Content.s_NoInstallablePackages);
                    }
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.Space();
        }
Example #5
0
 void RequestUpdate()
 {
     if (s_AddRequest != null)
     {
         if (s_AddRequest.Status == PackageManager.StatusCode.Success || s_AddRequest.Status == PackageManager.StatusCode.Failure)
         {
             if (s_AddRequest.Status == PackageManager.StatusCode.Failure)
             {
                 Debug.LogError("Failed to update HDRP Config Package");
                 Debug.LogError(s_AddRequest.Error.message);
             }
             s_AddRequest              = null;
             EditorApplication.update -= RequestUpdate;
         }
     }
 }
Example #6
0
        void FixDXRShaderConfig()
        {
            // Make sure to delete the previous local package (if any)
            if (Directory.Exists("LocalPackages/com.unity.render-pipelines.high-definition-config"))
            {
                Directory.Delete("LocalPackages/com.unity.render-pipelines.high-definition-config", true);
            }

            // First let's try to grab the cached version of pack-man
            bool   found        = false;
            string packageCache = Environment.ExpandEnvironmentVariables("%LOCALAPPDATA%");
            var    directories  = Directory.GetDirectories(packageCache + "/Unity/cache/packages/packages.unity.com");

            for (int dirIdx = 0; dirIdx < directories.Length; ++dirIdx)
            {
                if (directories[dirIdx].Contains("com.unity.render-pipelines.high-definition-config"))
                {
                    CopyFolder(directories[dirIdx], "LocalPackages/com.unity.render-pipelines.high-definition-config");
                    found = true;
                    break;
                }
            }

            // If we were not able to find it, we can't solve it
            if (!found)
            {
                return;
            }

            // Then we want to make sure that the shader config value is set to 1
            string[] lines = System.IO.File.ReadAllLines("LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl");
            for (int lineIdx = 0; lineIdx < lines.Length; ++lineIdx)
            {
                if (lines[lineIdx].Contains("SHADEROPTIONS_RAYTRACING"))
                {
                    lines[lineIdx] = "#define SHADEROPTIONS_RAYTRACING (1)";
                    break;
                }
            }
            File.WriteAllLines("LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl", lines);

            // Replace the path of this package using the packman API
            s_AddRequest              = PackageManager.Client.Add("file:../LocalPackages/com.unity.render-pipelines.high-definition-config");
            EditorApplication.update += RequestUpdate;
        }
Example #7
0
 public override void OnGUI(string searchContext)
 {
     if (m_AddManagementRequest != null)
     {
         if (m_AddManagementRequest.IsCompleted)
         {
             EditorGUILayout.LabelField(Content.s_DownloadingText);
         }
         else
         {
             EditorGUILayout.LabelField(Content.s_InstallingText);
         }
     }
     else
     {
         EditorGUILayout.HelpBox(Content.s_InstallationHelpText, MessageType.Info);
         if (GUILayout.Button(Content.s_AddXrManagement))
         {
             m_AddManagementRequest = PackageManager.Client.Add(s_ManagementPackageId);
         }
     }
 }