using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UIElements; using UnityEditor.UIElements; namespace UnityEditor.SLZMaterialUI { public class MaterialVectorField : Vector4Field, BaseMaterialField { public int shaderPropertyIdx; public int GetShaderPropIdx() { return shaderPropertyIdx; } public MaterialProperty materialProperty; public void Initialize(MaterialProperty materialProperty, int shaderPropertyIdx) { this.materialProperty = materialProperty; this.shaderPropertyIdx = shaderPropertyIdx; this.RegisterValueChangedCallback(OnChangedEvent); this.SetValueWithoutNotify(materialProperty.vectorValue); style.marginRight = 3; if (materialProperty.hasMixedValue) { //this.SetValueWithoutNotify(Color.gray); this.showMixedValue = true; } label = materialProperty.displayName; SetFullLineStyle(); } public void SetFullLineStyle() { VisualElement label = this.ElementAt(0); label.AddToClassList("materialGUILeftBox"); label.style.overflow = Overflow.Hidden; label.style.minWidth = 0; VisualElement color = this.ElementAt(1); color.AddToClassList("materialGUIRightBox"); style.justifyContent = Justify.FlexStart; } public void OnChangedEvent(ChangeEvent evt) { materialProperty.vectorValue = evt.newValue; this.showMixedValue = false; } public void UpdateMaterialProperty(MaterialProperty boundProp) { materialProperty = boundProp; if (this.value != boundProp.vectorValue) { this.SetValueWithoutNotify(boundProp.vectorValue); } this.showMixedValue = boundProp.hasMixedValue; //MarkDirtyRepaint(); } } }