コード例 #1
0
        public override void OnInitialize(InitializeConverterContext context, Action callback)
        {
            m_SettingsItems  = new List <SettingsItem>();
            m_RenderingModes = new List <RenderingMode>();

            // check graphics tiers
            GatherGraphicsTiers();

            // check quality levels
            GatherQualityLevels(ref context);

            callback?.Invoke();
        }
コード例 #2
0
        /// <summary>
        /// Iterates over all Quality Settings and saves relevant settings to a RenderSettingsItem.
        /// This will also create the required information for the Render Pipeline Converter UI.
        /// </summary>
        /// <param name="context">Converter context to add elements to.</param>
        private void GatherQualityLevels(ref InitializeConverterContext context)
        {
            var currentQuality = QualitySettings.GetQualityLevel();
            var id             = 0;

            foreach (var levelName in QualitySettings.names)
            {
                QualitySettings.SetQualityLevel(id);

                var projectSettings = new RenderSettingItem
                {
                    Index              = id,
                    LevelName          = levelName,
                    PixelLightCount    = QualitySettings.pixelLightCount,
                    MSAA               = QualitySettings.antiAliasing,
                    Shadows            = QualitySettings.shadows,
                    ShadowResolution   = QualitySettings.shadowResolution,
                    ShadowDistance     = QualitySettings.shadowDistance,
                    ShadowCascadeCount = QualitySettings.shadowCascades,
                    CascadeSplit2      = QualitySettings.shadowCascade2Split,
                    CascadeSplit4      = QualitySettings.shadowCascade4Split,
                    SoftParticles      = QualitySettings.softParticles,
                };
                m_SettingsItems.Add(projectSettings);

                var setting = QualitySettings.GetRenderPipelineAssetAt(id);
                var item    = new ConverterItemDescriptor {
                    name = $"Quality Level {id}: {levelName}"
                };

                if (setting != null)
                {
                    item.warningMessage = setting.GetType() == typeof(UniversalRenderPipelineAsset)
                        ? "Contains URP Asset, will override existing asset."
                        : "Contains SRP Asset, will override existing asset with URP asset.";
                }

                context.AddAssetToConvert(item);
                id++;
            }

            QualitySettings.SetQualityLevel(currentQuality);
        }
コード例 #3
0
ファイル: PPv2Converter.cs プロジェクト: neelbedekar/Graphics
        private void AddSearchItemsAsConverterAssetEntries(ISearchList searchItems, InitializeConverterContext context)
        {
            foreach (var searchItem in searchItems)
            {
                if (searchItem == null || !GlobalObjectId.TryParse(searchItem.id, out var globalId))
                {
                    continue;
                }

                var description = searchItem.provider.fetchDescription(searchItem, searchItem.context);

                var item = new ConverterItemDescriptor()
                {
                    name = description.Split('/').Last().Split('.').First(),
                    info = $"{ReturnType(globalId)}",
                };

                guids.Add(globalId.ToString());
                context.AddAssetToConvert(item);
            }
        }
コード例 #4
0
        public override void OnInitialize(InitializeConverterContext ctx, Action callback)
        {
            var context = Search.SearchService.CreateContext("asset", "urp:convert-readonly");

            Search.SearchService.Request(context, (c, items) =>
            {
                // we're going to do this step twice in order to get them ordered, but it should be fast
                var orderedRequest = items.OrderBy(req =>
                {
                    GlobalObjectId.TryParse(req.id, out var gid);
                    return(gid.assetGUID);
                });

                foreach (var r in orderedRequest)
                {
                    if (r == null || !GlobalObjectId.TryParse(r.id, out var gid))
                    {
                        continue;
                    }

                    var label       = r.provider.fetchLabel(r, r.context);
                    var description = r.provider.fetchDescription(r, r.context);

                    var item = new ConverterItemDescriptor()
                    {
                        name = description.Split('/').Last().Split('.').First(),
                        info = $"{label}",
                    };
                    guids.Add(gid.ToString());

                    ctx.AddAssetToConvert(item);
                }

                callback.Invoke();
            });
            context?.Dispose();
        }
コード例 #5
0
ファイル: PPv2Converter.cs プロジェクト: neelbedekar/Graphics
        public override void OnInitialize(InitializeConverterContext context, Action callback)
        {
            // Converters should already be set to null on domain reload,
            // but we're doing it here just in case anything somehow lingers.
            effectConverters = null;

            postConversionDestroyables = new List <Object>();

            // We are using separate searchContexts here and Adding them in this order:
            //      - Components from Prefabs & Scenes (Volumes & Layers)
            //      - ScriptableObjects (Profiles)
            //
            // This allows the old objects to be both re-referenced and deleted safely as they are converted in OnRun.
            // The process of converting Volumes will convert Profiles as-needed, and then the explicit followup Profile
            // conversion step will convert any non-referenced assets and delete all old Profiles.
            Debug.Log("Running here");
            // Components First
            using var componentContext =
                      Search.SearchService.CreateContext("asset", "urp:convert-ppv2component");
            using var componentItems = Search.SearchService.Request(componentContext);
            {
                Debug.Log("First Search");
                AddSearchItemsAsConverterAssetEntries(componentItems, context);
            }

            // Then ScriptableObjects
            using var scriptableObjectContext =
                      Search.SearchService.CreateContext("asset", "urp:convert-ppv2scriptableobject");
            using var scriptableObjectItems = Search.SearchService.Request(scriptableObjectContext);
            {
                Debug.Log("Second Search");
                AddSearchItemsAsConverterAssetEntries(scriptableObjectItems, context);
            }

            callback.Invoke();
        }
コード例 #6
0
        void GetAndSetData(int i, Action onAllConvertersCompleted = null)
        {
            // This need to be in Init method
            // Need to get the assets that this converter is converting.
            // Need to return Name, Path, Initial info, Help link.
            // New empty list of ConverterItemInfos
            List <ConverterItemDescriptor> converterItemInfos = new List <ConverterItemDescriptor>();
            var initCtx = new InitializeConverterContext {
                items = converterItemInfos
            };

            var conv = m_CoreConvertersList[i];

            m_ConverterStates[i].isLoading = true;

            // This should also go to the init method
            // This will fill out the converter item infos list
            int id = i;

            conv.OnInitialize(initCtx, OnConverterCompleteDataCollection);

            void OnConverterCompleteDataCollection()
            {
                // Set the item infos list to to the right index
                m_ItemsToConvert[id] = new ConverterItems {
                    itemDescriptors = converterItemInfos
                };
                m_ConverterStates[id].items = new List <ConverterItemState>(converterItemInfos.Count);

                // Default all the entries to true
                for (var j = 0; j < converterItemInfos.Count; j++)
                {
                    string message = string.Empty;
                    Status status;
                    bool   active = true;
                    // If this data hasn't been filled in from the init phase then we can assume that there are no issues / warnings
                    if (string.IsNullOrEmpty(converterItemInfos[j].warningMessage))
                    {
                        status = Status.Pending;
                    }
                    else
                    {
                        status  = Status.Warning;
                        message = converterItemInfos[j].warningMessage;
                        active  = false;
                        m_ConverterStates[id].warnings++;
                    }

                    m_ConverterStates[id].items.Add(new ConverterItemState
                    {
                        isActive     = active,
                        message      = message,
                        status       = status,
                        hasConverted = false,
                    });
                }

                m_ConverterStates[id].isLoading     = false;
                m_ConverterStates[id].isInitialized = true;

                // Making sure that the pending amount is set to the amount of items needs converting
                m_ConverterStates[id].pending = m_ConverterStates[id].items.Count;

                EditorUtility.SetDirty(this);
                m_SerializedObject.ApplyModifiedProperties();

                CheckAllConvertersCompleted();
                convertButtonActive = true;
                // Make sure that the Convert Button is turned back on
                var button = rootVisualElement.Q <Button>("convertButton");

                button.SetEnabled(convertButtonActive);
            }

            void CheckAllConvertersCompleted()
            {
                int convertersToInitialize = 0;
                int convertersInitialized  = 0;

                for (var j = 0; j < m_ConverterStates.Count; j++)
                {
                    var converter = m_ConverterStates[j];

                    // Skip inactive converters
                    if (!converter.isActiveAndEnabled)
                    {
                        continue;
                    }

                    if (converter.isInitialized)
                    {
                        convertersInitialized++;
                    }
                    else
                    {
                        convertersToInitialize++;
                    }
                }

                var sum = convertersToInitialize + convertersInitialized;

                Assert.IsFalse(sum == 0);

                // Show our progress so far
                EditorUtility.ClearProgressBar();
                EditorUtility.DisplayProgressBar($"Initializing converters", $"Initializing converters ({convertersInitialized}/{sum})...", (float)convertersInitialized / sum);

                // If all converters are initialized call the complete callback
                if (convertersToInitialize == 0)
                {
                    onAllConvertersCompleted?.Invoke();
                }
            }
        }
コード例 #7
0
 /// <summary>
 /// This runs when initializing the converter. To gather data for the UI and also for the converter if needed.
 /// </summary>
 /// <param name="context">The context that will be used to initialize data for the converter.</param>
 public abstract void OnInitialize(InitializeConverterContext context, Action callback);