using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using UnityEditor.Rendering.Converter;
using UnityEngine;
namespace UnityEditor.Rendering.Universal
{
///
/// Editor script for a ForwardRendererData class.
///
[Obsolete("ForwardRendererDataEditor has been deprecated. Use UniversalRendererDataEditor instead #from(2021.2) #breakingFrom(2021.2) (UnityUpgradable) -> UniversalRendererDataEditor", true)]
public class ForwardRendererDataEditor : ScriptableRendererDataEditor
{
///
public override void OnInspectorGUI()
{
throw new NotSupportedException("ForwardRendererDataEditor has been deprecated. Use UniversalRendererDataEditor instead");
}
}
static partial class EditorUtils
{
}
///
/// Filter for the list of converters used in batch mode.
///
///
[Obsolete("ConverterFilter has been deprecated.", false)]
public enum ConverterFilter
{
///
/// Use this to include converters matching the filter.
///
Inclusive,
///
/// Use this to exclude converters matching the filter.
///
Exclusive
}
///
/// The container to run in batch mode.
///
///
[Obsolete("ConverterContainerId has been deprecated.", false)]
public enum ConverterContainerId
{
///
/// Use this for Built-in to URP converter.
///
BuiltInToURP,
///
/// Use this for Built-in to 2D (URP) converter.
///
BuiltInToURP2D,
///
/// Use this for Built-in and 3D URP to 2D (URP) converter.
///
BuiltInAndURPToURP2D,
///
/// Use this to upgrade 2D (URP) assets.
///
UpgradeURP2DAssets,
}
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
[Obsolete("BatchModeConverterInfo has been deprecated. Please use BatchModeConverterClassInfo or upgrade using UnityEditor.Rendering.Universal.Converters.RunInBatchModeCmdLine instead.", false)]
internal class BatchModeConverterInfo : Attribute
{
public Type converterType { get; }
public ConverterContainerId containerName { get; }
public BatchModeConverterInfo(ConverterContainerId containerName, Type converterType)
{
this.converterType = converterType;
this.containerName = containerName;
}
}
///
/// The converter to run in batch mode.
///
///
[Obsolete("ConverterId has been deprecated. Please upgrade using UnityEditor.Rendering.Universal.Converters.RunInBatchModeCmdLine instead.", false)]
public enum ConverterId
{
///
/// Use this for the material converters.
///
[BatchModeConverterInfo(ConverterContainerId.BuiltInToURP, typeof(BuiltInToURP3DMaterialUpgrader))]
Material,
///
/// Use this for the render settings converters.
///
[BatchModeConverterInfo(ConverterContainerId.BuiltInToURP, typeof(BuiltInToURP3DRenderSettingsConverter))]
RenderSettings,
///
/// Use this for the animation clip converters.
///
[BatchModeConverterInfo(ConverterContainerId.BuiltInToURP, typeof(AnimationClipConverter))]
AnimationClip,
///
/// Use this for readonly material converters.
///
[BatchModeConverterInfo(ConverterContainerId.BuiltInToURP, typeof(BuiltInToURP3DReadonlyMaterialConverter))]
ReadonlyMaterial,
///
/// Use this for 2D material conversion
///
[BatchModeConverterInfo(ConverterContainerId.BuiltInToURP2D,
typeof(BuiltInToURP2DReadonlyMaterialConverter))]
ReadonlyMaterial2D,
///
/// Use this for 2D material conversion
///
[BatchModeConverterInfo(ConverterContainerId.BuiltInToURP2D, typeof(BuiltInToURP2DRenderSettingsConverter))]
RenderSettings2D,
///
/// Use this for 3D URP material conversion
///
[BatchModeConverterInfo(ConverterContainerId.UpgradeURP2DAssets,
typeof(URP3DToURP2DReadonlyMaterialConverter))]
URPToReadonlyMaterial2D,
#if PPV2_EXISTS
///
/// Use this for post processing V2 converters.
///
[BatchModeConverterInfo(ConverterContainerId.BuiltInToURP, typeof(PPv2Converter))]
PPv2,
#endif
///
/// Use this for parametric to freeform light converters.
///
[BatchModeConverterInfo(ConverterContainerId.UpgradeURP2DAssets, typeof(ParametricToFreeformLightUpgrader))]
ParametricToFreeformLight,
}
public static partial class Converters
{
///
/// Call this method to run all the converters in a specific container in batch mode.
///
/// The name of the container which will be batched. All Converters in this Container will run if prerequisites are met.
[Obsolete("RunInBatchMode(ConverterContainerId) has been deprecated. Please use RunInBatchMode(string) or upgrade using UnityEditor.Rendering.Universal.Converters.RunInBatchModeCmdLine instead.", false)]
public static void RunInBatchMode(ConverterContainerId containerName)
{
RunInBatchMode(containerName, new List() { }, ConverterFilter.Exclusive);
}
[Obsolete("TryGetTypeInContainer has been deprecated. Please upgrade using UnityEditor.Rendering.Universal.Converters.RunInBatchModeCmdLine instead.", false)]
static bool TryGetTypeInContainer(ConverterId value, ConverterContainerId containerName, out Type type)
{
type = null;
var memberInfo = typeof(ConverterId).GetMember(value.ToString());
if (memberInfo.Length > 0)
{
var attr = memberInfo[0].GetCustomAttribute();
if (attr != null)
{
if(attr.containerName == containerName)
type = attr.converterType;
}
}
return type != null;
}
///
/// Call this method to run a specific list of converters in a specific container in batch mode.
///
/// The name of the container which will be batched.
/// The list of converters that will be either included or excluded from batching. These converters need to be part of the passed in container for them to run.
/// The enum that decide if the list of converters will be included or excluded when batching.
[Obsolete("RunInBatchMode(ConverterContainerId, List, ConverterFilter) has been deprecated. Please use RunInBatchMode(string, List, bool) or upgrade using UnityEditor.Rendering.Universal.Converters.RunInBatchModeCmdLine instead.", false)]
public static void RunInBatchMode(ConverterContainerId containerName, List converterList, ConverterFilter converterFilter)
{
var types = FilterConverters(containerName, converterList, converterFilter);
SuggestUpdatedCommand(containerName.ToString(), converterList.ConvertAll(id => id.ToString()), converterFilter == ConverterFilter.Inclusive);
RunInBatchMode(types);
}
[Obsolete("FilterConverters(ConverterContainerId, List, ConverterFilter) has been deprecated. Please use FilterConverters(string, List, bool) instead.", false)]
internal static List FilterConverters(ConverterContainerId containerName, List converterList, ConverterFilter converterFilter)
{
Array converters = Enum.GetValues(typeof(ConverterId));
List converterTypes = new();
foreach (object value in converters)
{
var converterEnum = (ConverterId)value;
if (TryGetTypeInContainer(converterEnum, containerName, out var type))
{
bool inFilter = converterList.Contains(converterEnum);
if ((converterFilter == ConverterFilter.Inclusive) ^ !inFilter)
converterTypes.Add(type);
}
}
return converterTypes;
}
}
}