using System;
using System.Reflection;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UIElements;
namespace UnityEditor.Rendering
{
///
/// Render Pipeline Settings provider
///
///
///
[Obsolete("This is obsolete. GlobalSettingsAsset content are transformed in IRenderPipelineGraphicsSettings and they are directly embedded in Projectsettings > Graphics #from(2023.3)")]
public abstract class RenderPipelineGlobalSettingsProvider : SettingsProvider
where TRenderPipeline : RenderPipeline
where TGlobalSettings : RenderPipelineGlobalSettings
{
static class Styles
{
public static readonly string warningGlobalSettingsMissing = "Select a valid {0} asset.";
public static readonly string warningSRPNotActive = "Current Render Pipeline is {0}. Check the settings: Graphics > Scriptable Render Pipeline Settings, Quality > Render Pipeline Asset.";
public static readonly string settingNullRPSettings = "Invalid Global Settings asset. Rollback to the previous value";
public static readonly GUIContent newAssetButtonLabel = EditorGUIUtility.TrTextContent("New", "Create a Global Settings asset in the Assets folder.");
public static readonly GUIContent cloneAssetButtonLabel = EditorGUIUtility.TrTextContent("Clone", "Clone a Global Settings asset in the Assets folder.");
public static readonly GUILayoutOption[] buttonOptions = new GUILayoutOption[] { GUILayout.Width(45), GUILayout.Height(18) };
}
private const string k_TemplatePath = "Packages/com.unity.render-pipelines.core/Editor/UXML/RenderPipelineGlobalSettings.uxml";
Editor m_Editor;
SupportedOnRenderPipelineAttribute m_SupportedOnRenderPipeline;
RenderPipelineGlobalSettings renderPipelineSettings => GraphicsSettings.GetSettingsForRenderPipeline();
///
/// Constructor
///
/// The path of the settings
public RenderPipelineGlobalSettingsProvider(string v)
: base(v, SettingsScope.Project)
{
m_SupportedOnRenderPipeline = GetType().GetCustomAttribute();
}
///
/// Method called when the title bar is being rendered
///
public override void OnTitleBarGUI()
{
if (GUILayout.Button(CoreEditorStyles.iconHelp, CoreEditorStyles.iconHelpStyle))
Help.BrowseURL(Help.GetHelpURLForObject(renderPipelineSettings));
}
void DestroyEditor()
{
CoreUtils.Destroy(m_Editor);
m_Editor = null;
}
///
/// This method is being called when the provider is activated
///
/// The context with the search
/// The with the root
public override void OnActivate(string searchContext, VisualElement rootElement)
{
DestroyEditor();
base.OnActivate(searchContext, rootElement);
var template = AssetDatabase.LoadAssetAtPath(k_TemplatePath);
var settingsRoot = template.Instantiate();
settingsRoot.Q