更新
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GraphicsCat.MarkupShaderGUIInternal
|
||||
{
|
||||
public static class PropertyUtils
|
||||
{
|
||||
public static int GetAsInt(MaterialProperty prop)
|
||||
{
|
||||
return prop.propertyType switch
|
||||
{
|
||||
UnityEngine.Rendering.ShaderPropertyType.Int => prop.intValue,
|
||||
UnityEngine.Rendering.ShaderPropertyType.Float => Mathf.RoundToInt(prop.floatValue),
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
public static void SetAsInt(MaterialProperty prop, int value)
|
||||
{
|
||||
switch (prop.propertyType)
|
||||
{
|
||||
case UnityEngine.Rendering.ShaderPropertyType.Int:
|
||||
prop.intValue = value;
|
||||
break;
|
||||
case UnityEngine.Rendering.ShaderPropertyType.Float:
|
||||
prop.floatValue = value;
|
||||
break;
|
||||
default:
|
||||
// Unsupported type, do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user