switching Models/Objects (textures) during playing?

Hi Forum :slight_smile:

this is my first Day with Unity and my first Project is nearly completed :wink: What i wont is during playing to switch (with a key or Button) a Model texture. Is this possible without many scripting?
Or it is perhaps simpler to replace the object with a new texture?
I would like to run in a room and show 4 alternativ textures of my Models / Objects by pressing for example the keys 1-4. How can i do this?

Thank you very much for Answares and sorry for my english :sweat_smile:

best regards
Wojtek

var material1 : Material;
var material2 : Material;
var Changetime= 60.0;

function Updatet() {
if(Input.GetKeyDown("1"))

	
		renderer.sharedMaterial = material1;
				print("changedMaterial");
	
}
if(Input.GetKeyDown("2")){

	
		renderer.sharedMaterial = material2;
				print("changedMaterialagain");
	
}
Untested Should work ok though.
AC

Thank You for the quick respons, but :sweat_smile: this is my 1 DAY WITH UNITY :slight_smile: if you know what i mean :wink:
What i must do in Unity to getthis Effekt to my Objects?
What i need is a smart tutorial (step by step) :slight_smile:

Thanks for your understanding :slight_smile:

best regards
Wojtek

Assets.Create>Javascript

Locate new script in Project Window
Double click it

Paste the code in above
Save

Drag the script onto you model with the meshrenderer.

Look in Inspector Tab
Assign materials from project window to empty slots.

Press play.

Later on:

Applications/Unity/Tutorials/ScriptingTutorial.pdf

HTH
AC

Hi,

i have make all the steps that you have write me but nothin happens! But also no error.
I have my two extra material slot on my object i have two exta materials but during playing and pressin the keys nothing happens. Can you help me please?

Thank you for answares :slight_smile:

Best reagards
Wojtek

Hi,

i have made it :slight_smile: It works!
It was a simple script error :slight_smile:

Thank you Targos:)

best regards

Yeah only one T in update 8)

Also that varible of changetime doesnt need to be there.

Amazing what a good nights sleep can do…

Pleased its working
AC