Files
Cielonos/Assets/OtherPlugins/GraphicsCat/Modules/MarkupShaderGUI/Editor/Utils/PropertyUtils.cs
SoulliesOfficial d15957c719 更新
2025-12-17 04:19:38 -05:00

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