A game about forced loneliness, made by TACStudios
at master 1.2 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 TextureArraySlotControlView : VisualElement 11 { 12 Texture2DArrayInputMaterialSlot m_Slot; 13 14 public TextureArraySlotControlView(Texture2DArrayInputMaterialSlot slot) 15 { 16 m_Slot = slot; 17 styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/TextureArraySlotControlView")); 18 var objectField = new ObjectField { objectType = typeof(Texture2DArray), value = m_Slot.textureArray }; 19 objectField.RegisterValueChangedCallback(OnValueChanged); 20 Add(objectField); 21 } 22 23 void OnValueChanged(ChangeEvent<Object> evt) 24 { 25 var textureArray = evt.newValue as Texture2DArray; 26 if (textureArray != m_Slot.textureArray) 27 { 28 m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Change Texture Array"); 29 m_Slot.textureArray = textureArray; 30 m_Slot.owner.Dirty(ModificationScope.Node); 31 } 32 } 33 } 34}