A game about forced loneliness, made by TACStudios
at master 1.1 kB view raw
1using System; 2using UnityEditor.Graphing; 3using UnityEngine; 4using Object = UnityEngine.Object; 5using UnityEditor.UIElements; 6using UnityEngine.UIElements; 7 8namespace UnityEditor.ShaderGraph.Drawing.Slots 9{ 10 class Texture3DSlotControlView : VisualElement 11 { 12 Texture3DInputMaterialSlot m_Slot; 13 14 public Texture3DSlotControlView(Texture3DInputMaterialSlot slot) 15 { 16 m_Slot = slot; 17 styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/Texture3DSlotControlView")); 18 var objectField = new ObjectField { objectType = typeof(Texture3D), value = m_Slot.texture }; 19 objectField.RegisterValueChangedCallback(OnValueChanged); 20 Add(objectField); 21 } 22 23 void OnValueChanged(ChangeEvent<Object> evt) 24 { 25 var texture = evt.newValue as Texture3D; 26 if (texture != m_Slot.texture) 27 { 28 m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Change Texture"); 29 m_Slot.texture = texture; 30 m_Slot.owner.Dirty(ModificationScope.Node); 31 } 32 } 33 } 34}