Shader Global Texture#
Rendering / Shader / Shader Global Texture
Can Read
Can Write
Description#
A texture property shared by every shader that reads it and no material overrides
Parameters#
| Name | Description |
|---|---|
| Property | The name of the global shader property |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get, Set]
[Title("Shader Global Texture")]
[Category("Rendering/Shader/Global Texture")]
[Description("A texture property shared by every shader that reads it and no material overrides")]
[Image(typeof(IconShader), ColorTheme.Type.Yellow)]
[Parameter("Property", "The name of the global shader property")]
[Keywords("Shader", "Global", "Material", "Property", "Map")]
[Serializable]
public class TypeTextureShaderGlobalTexture : TypeTexture
{
[SerializeField] private GetString m_Property = new GetString();
public override Texture Get(Args args)
{
string property = this.m_Property.Get(args);
return string.IsNullOrEmpty(property) ? null : Shader.GetGlobalTexture(property);
}
public override void Set(Texture value, Args args)
{
string property = this.m_Property.Get(args);
if (string.IsNullOrEmpty(property)) return;
Shader.SetGlobalTexture(property, value);
}
public override string ToString()
{
return $"Shader Global {this.m_Property}";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}