set standard material

hey,

i’m trying to set the standard material for an object,
after i changed the color in runtime.

the code i’m using:
myObject.renderer.material.color = Color(1,1,1,0.5);

my problem is, after doing this, the function onMouseEnter/onMouseExit/onMouseOver,
don’t work properly anymore.

the documentation on MonoBehaviour.OnMouseOver says the following:
This function is not called on objects that belong to Ignore Raycast layer.

my question, how do i set the standard material properly,
so that the named above functions still work properly?
(tryed a lot of different things…)

greetz and thx

Setting the material’s color doesn’t stop OnMouseEnter etc. functions from working. You’re doing something else in your code that’s causing it.

–Eric

mmh. i don’t think so, 'cause it works fine the whole time!
until i reset the color anyways…

i just wan’t to reset everything to default after a given time or after
my logic has been reached.

here’s the code that works fine till the other code (see underneath) is executed:

function OnMouseEnter () {
	if( onStart.debug == true ) {
		renderer.material.color -= renderer.material.color * 2;
	}
}

here’s the code that resets the cube’s color or material after a given time:

GameObject.Find( "Cube1" ).renderer.material.color  = Color(1,1,1,0.5);

like i said, everything works fine, until i set the materials color back to default.
after that everything behaves differently.
not the way it behaved on programm start.

(on start the color switches from “black” to “gray” - after resetting the color, it just
changes/switches the color for 1 frame or something like that.)

that’s why my question was, how to just reset the whole material/shader to it’s
default the proper way.
maybe i’m missing something…

all i wan’t to reach is, that a cube switches it’s color from gray to black or whatever,
when you hover/enter it with the mouse.
after my logic is reached, i would like to set everything back to default,
so you can start all over again.

greetz thx

Is it causing ‘object is null’ errors? That will often break things that seem unrelated as it interrupts code execution.

sorry. nevermind. gg
it’s like magic. :wink:
problem just ain’t there no more.
thx! :slight_smile: