Scripting
Every effect property is a normal shader property, so you drive them with Unity’s own material API. No asset-specific code is involved, and the component that helps you set materials up in the editor plays no part at runtime.
Finding the property name
Section titled “Finding the property name”Three ways, in order of convenience:
- Hover over any property in the Material Inspector. The tooltip is the property name.
- Look it up on Effects and Properties Breakdown, which lists every one.
- Read the
Propertiesblock at the top ofAssets\Plugins\AllIn1Assets\AllIn1SpriteShader\Shaders\AllIn1SpriteShader.shader.

Setting a property
Section titled “Setting a property”Material mat = GetComponent<Renderer>().material;
mat.SetFloat("_FadeAmount", 0.5f);mat.SetColor("_OutlineColor", Color.red);mat.SetTexture("_FadeTex", dissolveTexture);SetFloat, SetColor and SetTexture cover almost everything the shader exposes. Sliders and toggles are floats, colours are colours, textures are textures.
material or sharedMaterial
Section titled “material or sharedMaterial”renderer.material creates an instance the first time you touch it, so changes affect this object alone and you own a material that Unity will not clean up until the object dies. renderer.sharedMaterial edits the asset itself, so every object using it changes, and in the editor that change is written to disk.
Use material for per-object effects like a damage flash. Use sharedMaterial when you deliberately want everything to change at once.
A worked example: the damage flash
Section titled “A worked example: the damage flash”HITEFFECT_ON is the effect people reach for most from script. Enable it in the inspector, leave _HitEffectBlend at 0, and drive the blend when something gets hit:
using System.Collections;using UnityEngine;
public class HitFlash : MonoBehaviour{ private static readonly int HitBlend = Shader.PropertyToID("_HitEffectBlend");
[SerializeField] private float duration = 0.15f;
private Material mat;
private void Awake() { mat = GetComponent<Renderer>().material; }
public void Flash() { StopAllCoroutines(); StartCoroutine(FlashRoutine()); }
private IEnumerator FlashRoutine() { mat.SetFloat(HitBlend, 1f);
for (float t = duration; t > 0f; t -= Time.deltaTime) { mat.SetFloat(HitBlend, t / duration); yield return null; }
mat.SetFloat(HitBlend, 0f); }}Two things worth copying from that. The property ID is cached with Shader.PropertyToID in a static readonly field, which is how you should address any property you set every frame, since the string version hashes the name on each call. And the effect stays enabled the whole time, with only its blend moving. That is the recommended pattern, explained on How to Enable/Disable Effects at Runtime.
UI Images
Section titled “UI Images”Two rules that catch everyone.
Masked images need materialForRendering. An Image inside a Mask or a Scroll View renders through a different material than the one in its slot, so writing to Image.material does nothing visible:
image.materialForRendering.SetFloat("_FadeAmount", t);UI materials are shared. Every Image using the same material asset shares the same instance, so a change to one changes all of them. If you want per-image control, make a copy on Awake:
private void Awake(){ Image uiImage = GetComponent<Image>(); uiImage.material = new Material(uiImage.material);}Per-renderer values without instancing a material
Section titled “Per-renderer values without instancing a material”MaterialPropertyBlock also works with this shader and does not create a material instance, which keeps sprites batching. The asset uses one itself: SpritePropertiesSync pushes _SpriteFlip that way.
private MaterialPropertyBlock block;
private void Start(){ block = new MaterialPropertyBlock();}
private void SetFade(float amount){ spriteRenderer.GetPropertyBlock(block); block.SetFloat("_FadeAmount", amount); spriteRenderer.SetPropertyBlock(block);}This does not work for UI, where Image has no property block, and it cannot toggle keywords. It is for values only.
The component is not a runtime API
Section titled “The component is not a runtime API”The AllIn1Shader component exists to set materials up in the editor, and nearly all of it is inside editor-only guards. Do not call it from gameplay code. Once your material is set up you can remove the component, and leaving it costs nothing either way.
