2 using System.Collections.Generic;
3 using UnityEditor.Graphing;
4 using UnityEditor.ShaderGraph.Drawing.Slots;
6 using UnityEngine.UIElements;
8 namespace UnityEditor.ShaderGraph
11 class Texture2DArrayInputMaterialSlot : Texture2DArrayMaterialSlot
14 private SerializableTextureArray m_TextureArray = new SerializableTextureArray();
16 public Texture2DArray textureArray
18 get { return m_TextureArray.textureArray; }
19 set { m_TextureArray.textureArray = value; }
22 public Texture2DArrayInputMaterialSlot()
25 public Texture2DArrayInputMaterialSlot(
28 string shaderOutputName,
29 ShaderStageCapability shaderStageCapability = ShaderStageCapability.All,
31 : base(slotId, displayName, shaderOutputName, SlotType.Input, shaderStageCapability, hidden)
34 public override VisualElement InstantiateControl()
36 return new TextureArraySlotControlView(this);
39 public override string GetDefaultValue(GenerationMode generationMode)
41 var matOwner = owner as AbstractMaterialNode;
43 throw new Exception(string.Format("Slot {0} either has no owner, or the owner is not a {1}", this, typeof(AbstractMaterialNode)));
45 return matOwner.GetVariableNameForSlot(id);
48 public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode)
50 var matOwner = owner as AbstractMaterialNode;
52 throw new Exception(string.Format("Slot {0} either has no owner, or the owner is not a {1}", this, typeof(AbstractMaterialNode)));
54 var prop = new Texture2DArrayShaderProperty();
55 prop.overrideReferenceName = matOwner.GetVariableNameForSlot(id);
56 prop.modifiable = false;
57 prop.generatePropertyBlock = true;
58 prop.value.textureArray = textureArray;
59 properties.AddShaderProperty(prop);
62 public override void GetPreviewProperties(List<PreviewProperty> properties, string name)
64 var pp = new PreviewProperty(PropertyType.Texture2DArray)
67 textureValue = textureArray,
72 public override void CopyValuesFrom(MaterialSlot foundSlot)
74 var slot = foundSlot as Texture2DArrayInputMaterialSlot;
76 m_TextureArray = slot.m_TextureArray;