38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
#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 |