- Home /
Question by
PaxStyle · Feb 08, 2014 at 02:03 PM ·
materialchangekey pressed
Material on/off
How can I do to pass from "material1" to "material2" when I press a key? I would like to change material when I press a key :) Thank you in advance, paolo
Comment
Answer by getyour411 · Feb 08, 2014 at 06:23 PM
pseudo:
public Material material1;
public Material material2;
if(inputkeypress)
gameobject.renderer.material = material2;
if(input.otherkeypss)
gameobjet.renderer.material = material1;
This gave me an arror (the name"gameobject" does not exist in the current context)
using UnityEngine;
using System.Collections;
public class Luci4 : $$anonymous$$onoBehaviour {
public $$anonymous$$aterial material1;
public $$anonymous$$aterial material2;
void Update () {
if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.Alpha4))
gameobject.renderer.material = material2;
if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.Alpha4))
gameobjet.renderer.material = material1;
}
}
Your answer
Follow this Question
Related Questions
How to change material of gameobject using C# to a material asset. 2 Answers
How do i change default material ? 1 Answer
Change the material on an Object in a script? 2 Answers
Hair Color 1 Answer