A game about forced loneliness, made by TACStudios
at master 87 lines 2.9 kB view raw
1using System; 2using UnityEngine; 3 4namespace UnityEditor.ShaderGraph.Internal 5{ 6 [Serializable] 7 [FormerName("UnityEditor.ShaderGraph.Texture2DArrayShaderProperty")] 8 [BlackboardInputInfo(51)] 9 public class Texture2DArrayShaderProperty : AbstractShaderProperty<SerializableTextureArray> 10 { 11 internal Texture2DArrayShaderProperty() 12 { 13 displayName = "Texture2D Array"; 14 value = new SerializableTextureArray(); 15 } 16 17 public override PropertyType propertyType => PropertyType.Texture2DArray; 18 19 internal override bool isExposable => true; 20 internal override bool isRenamable => true; 21 22 internal string modifiableTagString => modifiable ? "" : "[NonModifiableTextureData]"; 23 24 internal override string GetPropertyBlockString() 25 { 26 return $"{hideTagString}{modifiableTagString}[NoScaleOffset]{referenceName}(\"{displayName}\", 2DArray) = \"\" {{}}"; 27 } 28 29 internal override bool AllowHLSLDeclaration(HLSLDeclaration decl) => (decl != HLSLDeclaration.HybridPerInstance) && (decl != HLSLDeclaration.DoNotDeclare); 30 31 internal override void ForeachHLSLProperty(Action<HLSLProperty> action) 32 { 33 action(new HLSLProperty(HLSLType._Texture2DArray, referenceName, HLSLDeclaration.Global)); 34 action(new HLSLProperty(HLSLType._SamplerState, "sampler" + referenceName, HLSLDeclaration.Global)); 35 } 36 37 internal override string GetPropertyAsArgumentString(string precisionString) 38 { 39 return "UnityTexture2DArray " + referenceName; 40 } 41 42 internal override string GetPropertyAsArgumentStringForVFX(string precisionString) 43 { 44 return "TEXTURE2D_ARRAY(" + referenceName + ")"; 45 } 46 47 internal override string GetHLSLVariableName(bool isSubgraphProperty, GenerationMode mode) 48 { 49 if (isSubgraphProperty) 50 return referenceName; 51 else 52 return $"UnityBuildTexture2DArrayStruct({referenceName})"; 53 } 54 55 [SerializeField] 56 bool m_Modifiable = true; 57 58 internal bool modifiable 59 { 60 get => m_Modifiable; 61 set => m_Modifiable = value; 62 } 63 64 internal override AbstractMaterialNode ToConcreteNode() 65 { 66 return new Texture2DArrayAssetNode { texture = value.textureArray }; 67 } 68 69 internal override PreviewProperty GetPreviewMaterialProperty() 70 { 71 return new PreviewProperty(propertyType) 72 { 73 name = referenceName, 74 textureValue = value.textureArray 75 }; 76 } 77 78 internal override ShaderInput Copy() 79 { 80 return new Texture2DArrayShaderProperty() 81 { 82 displayName = displayName, 83 value = value, 84 }; 85 } 86 } 87}