2 using UnityEditor.Graphing;
4 using Object = UnityEngine.Object;
5 using UnityEditor.UIElements;
6 using UnityEngine.UIElements;
8 namespace UnityEditor.ShaderGraph.Drawing.Slots
10 class TextureSlotControlView : VisualElement
12 Texture2DInputMaterialSlot m_Slot;
14 public TextureSlotControlView(Texture2DInputMaterialSlot slot)
17 styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/TextureSlotControlView"));
18 var objectField = new ObjectField { objectType = typeof(Texture), value = m_Slot.texture };
19 objectField.RegisterValueChangedCallback(OnValueChanged);
23 void OnValueChanged(ChangeEvent<Object> evt)
25 var texture = evt.newValue as Texture;
26 if (texture != m_Slot.texture)
28 m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Change Texture");
29 m_Slot.texture = texture;
30 m_Slot.owner.Dirty(ModificationScope.Node);