Can a texture grow on mouse click?

Hey,

I’ve made a texture with a gradient in After Effects, imported it into Unity and applied it on a plane as a Transparent/Cutout/Diffuse texture which allows me to move the Alpha Cutoff handle in the inspector and that makes my texture “grow” or appear from left to right, for example. It’s a glowing light rod that I want to grow on mouse click, when I click another object for a little mini game.

My question is how can I, via scripting, make the alpha cutoff change by clicking another object in game?

The game is simply this: When you click a square plane it rotates and allows a “stream” to pass through and connect to another square. its a simple puzzle game. If anyone knows of a better way to achieve the growing effect I’m all ears. Thanks!

You can adjust the cutoff value with

property name seems to be “_Cutoff”

or, could just make those as an sprite animations? (like 8 frames of growing…)

Sprite animations!! Of course! I’ll try that because I think that they would be easier to control ;-D Thanks for the quick reply.

It works, but its not a smooth transition and the more frames i put in the slower the grow effect. Ill try your link and play around with the settings. Thanks again!

I used the Link you gave me @mgear and replaced the “_Shininess” with “_Cutoff” since that is what the alpha cutoff is called but it doesn’t change the alpha. When I press play it still makes shininess handle appear in the inspector.

This is the code I have:

    void Start() {
        renderer.material.shader = Shader.Find("glowtest");
    }
    void Update() {
        float Cutoff = Mathf.PingPong(Time.time, 1.0F);
        renderer.material.SetFloat("_Cutoff", Cutoff);
    }
}

in your glowtest.shader, do you have that _CutOff parameter?

Does it work when using the default shader Transparent/Cutout/Diffuse ?

Yes it works when I do it manually with the default shader Transparent/Cutout/Diffuse. I only need to activate it from a script and to be able to define its parameters. When I do it manually its just a matter of scrolling the handle from left to right in the inspector.