Hi,
Currently I’m working on a 2d game that can change between day / night cycle.
At night, all foreground object will be changed to dark silhouette.
I achieve this effect by creating custom material that use Sprite/Default shader
and assign this material to all foreground objects. When the cycle change I just need
to change sharedMaterial color of one of the object.
It works beautifully but I encounter problem when I add ParticleSystem since
it seems that it doesn’t provide a way to fill the texture for my material.
I’ve tried attaching this script to the object:
public Texture tex;
ParticleSystem ps;
void Awake () {
MaterialPropertyBlock mpb = new MaterialPropertyBlock ();
mpb.AddTexture ("_MainTex", tex);
ps = GetComponent< ParticleSystem > ();
ps.renderer.SetPropertyBlock (mpb);
}
But even though the texture of the material is changed, the ParticleSystem
is still emitting a white square.
Is it possible to change the texture this way? Are there any workaround for this?
Thanks.