Added GetEnumValue;

Added EnumFlagsDrawer;
Added custom keywordName option to KeywordTexturePropertySingleLine;
This commit is contained in:
2025-02-03 15:44:46 +09:00
parent 4723c9833a
commit dc1f1fb4e7
6 changed files with 162 additions and 16 deletions

View File

@@ -28,5 +28,28 @@ namespace Misaki.ShaderGUI
throw new NotSupportedException("Property type is not supported.");
}
public static T GetEnumValue<T>(this MaterialProperty materialProperty) where T : Enum
{
#if UNITY_6000_1_OR_NEWER
if (materialProperty.propertyType == UnityEngine.Rendering.ShaderPropertyType.Float || materialProperty.propertyType == UnityEngine.Rendering.ShaderPropertyType.Range)
#else
if (materialProperty.type == MaterialProperty.PropType.Float || materialProperty.type == MaterialProperty.PropType.Range)
#endif
{
return (T)Enum.ToObject(typeof(T), (int)materialProperty.floatValue);
}
#if UNITY_6000_1_OR_NEWER
if (materialProperty.propertyType == UnityEngine.Rendering.ShaderPropertyType.Int)
#else
if (materialProperty.type == MaterialProperty.PropType.Int)
#endif
{
return (T)Enum.ToObject(typeof(T), materialProperty.intValue);
}
throw new NotSupportedException("Property type is not supported.");
}
}
}