x


Disable a Shader in a material on a certain GameObject?

I'm using the Toon-BasicOutline on a GameObject right now, and I'd like to be able to disable just the outline effect (not the GoodDirt material).

Does anyone know a way to do this with code?

more ▼

asked Nov 19 '09 at 01:42 AM

Atled gravatar image

Atled
11 1 1 2

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Drop this script on your object, run the game and press spacebar to see the outline appear/disappear:

private var shaderNoOutline = Shader.Find( "Toon/Basic" );
private var shaderOutline = Shader.Find( "Toon/Basic Outline" );

function Update() {
    if( Input.GetButtonDown("Jump") ) {
    	if( renderer.material.shader == shaderNoOutline )
    		renderer.material.shader = shaderOutline;
    	else
    		renderer.material.shader = shaderNoOutline;
    }
}
more ▼

answered Nov 19 '09 at 08:50 AM

robert gravatar image

robert ♦
1.1k 3 7 27

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5066
x1650

asked: Nov 19 '09 at 01:42 AM

Seen: 1937 times

Last Updated: Nov 19 '09 at 01:42 AM