您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
28 行
1.2 KiB
28 行
1.2 KiB
using System;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using UnityEngine;
|
|
using UnityEngine.Experimental.UIElements;
|
|
using Object = UnityEngine.Object;
|
|
|
|
namespace UnityEditor.ShaderGraph.Drawing.Controls
|
|
{
|
|
[AttributeUsage(AttributeTargets.Property)]
|
|
public class DefaultControlAttribute : Attribute, IControlAttribute
|
|
{
|
|
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo)
|
|
{
|
|
if (propertyInfo.PropertyType == typeof(Color))
|
|
return new ColorControlView(null, node, propertyInfo);
|
|
if (typeof(Enum).IsAssignableFrom(propertyInfo.PropertyType))
|
|
return new EnumControlView(null, node, propertyInfo);
|
|
if (propertyInfo.PropertyType == typeof(Texture2D))
|
|
return new TextureControlView(null, node, propertyInfo);
|
|
if (MultiFloatControlView.validTypes.Contains(propertyInfo.PropertyType))
|
|
return new MultiFloatControlView(null, "X", "Y", "Z", "W", node, propertyInfo);
|
|
if (typeof(Object).IsAssignableFrom(propertyInfo.PropertyType))
|
|
return new ObjectControlView(null, node, propertyInfo);
|
|
return null;
|
|
}
|
|
}
|
|
}
|