WuhuIslandTesting/Library/PackageCache/com.unity.render-pipelines.universal@8148.0.7-4/Editor/ShaderGUI/UIClasses/MaterialDummyIntField.cs

48 lines
1.4 KiB
C#
Raw Normal View History

2025-01-07 02:06:59 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace UnityEditor.SLZMaterialUI
{
public class MaterialDummyField : INotifyValueChanged<float>, BaseMaterialField
{
public int shaderPropertyIdx;
public int GetShaderPropIdx() { return shaderPropertyIdx; }
public MaterialProperty materialProperty;
float m_value;
public float value
{
get { return m_value; }
set {
if (m_value != value)
{
m_value = value;
materialProperty.floatValue = m_value;
}
}
}
public MaterialDummyField(MaterialProperty materialProperty, int shaderPropertyIdx)
{
this.materialProperty = materialProperty;
this.shaderPropertyIdx = shaderPropertyIdx;
SetValueWithoutNotify(materialProperty.floatValue);
}
public void UpdateMaterialProperty(MaterialProperty boundProp)
{
materialProperty = boundProp;
if (value != boundProp.floatValue)
{
this.SetValueWithoutNotify(boundProp.floatValue);
}
}
public void SetValueWithoutNotify(float value)
{
m_value = value;
}
}
}