You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.8 KiB
87 lines
2.8 KiB
using System; |
|
using UnityEngine; |
|
|
|
namespace UnityEditor.ShaderGraph.Internal |
|
{ |
|
[Serializable] |
|
[FormerName("UnityEditor.ShaderGraph.Texture2DArrayShaderProperty")] |
|
[BlackboardInputInfo(51)] |
|
public class Texture2DArrayShaderProperty : AbstractShaderProperty<SerializableTextureArray> |
|
{ |
|
internal Texture2DArrayShaderProperty() |
|
{ |
|
displayName = "Texture2D Array"; |
|
value = new SerializableTextureArray(); |
|
} |
|
|
|
public override PropertyType propertyType => PropertyType.Texture2DArray; |
|
|
|
internal override bool isExposable => true; |
|
internal override bool isRenamable => true; |
|
|
|
internal string modifiableTagString => modifiable ? "" : "[NonModifiableTextureData]"; |
|
|
|
internal override string GetPropertyBlockString() |
|
{ |
|
return $"{hideTagString}{modifiableTagString}[NoScaleOffset]{referenceName}(\"{displayName}\", 2DArray) = \"\" {{}}"; |
|
} |
|
|
|
internal override bool AllowHLSLDeclaration(HLSLDeclaration decl) => false; // disable UI, nothing to choose |
|
|
|
internal override void ForeachHLSLProperty(Action<HLSLProperty> action) |
|
{ |
|
action(new HLSLProperty(HLSLType._Texture2DArray, referenceName, HLSLDeclaration.Global)); |
|
action(new HLSLProperty(HLSLType._SamplerState, "sampler" + referenceName, HLSLDeclaration.Global)); |
|
} |
|
|
|
internal override string GetPropertyAsArgumentString(string precisionString) |
|
{ |
|
return "UnityTexture2DArray " + referenceName; |
|
} |
|
|
|
internal override string GetPropertyAsArgumentStringForVFX(string precisionString) |
|
{ |
|
return "TEXTURE2D_ARRAY(" + referenceName + ")"; |
|
} |
|
|
|
internal override string GetHLSLVariableName(bool isSubgraphProperty, GenerationMode mode) |
|
{ |
|
if (isSubgraphProperty) |
|
return referenceName; |
|
else |
|
return $"UnityBuildTexture2DArrayStruct({referenceName})"; |
|
} |
|
|
|
[SerializeField] |
|
bool m_Modifiable = true; |
|
|
|
internal bool modifiable |
|
{ |
|
get => m_Modifiable; |
|
set => m_Modifiable = value; |
|
} |
|
|
|
internal override AbstractMaterialNode ToConcreteNode() |
|
{ |
|
return new Texture2DArrayAssetNode { texture = value.textureArray }; |
|
} |
|
|
|
internal override PreviewProperty GetPreviewMaterialProperty() |
|
{ |
|
return new PreviewProperty(propertyType) |
|
{ |
|
name = referenceName, |
|
textureValue = value.textureArray |
|
}; |
|
} |
|
|
|
internal override ShaderInput Copy() |
|
{ |
|
return new Texture2DArrayShaderProperty() |
|
{ |
|
displayName = displayName, |
|
value = value, |
|
}; |
|
} |
|
} |
|
}
|
|
|