- Home /
how to save a texture in background by looking at it.
I have my script to where I look at something and the texture changes and I want it to turn back to the orginal when I look away. I can just put a new texture on it that was the same as the first one but seeing I have 400 different kind of cubes in my game I don't want to make a bunch of scripts over and over again. Is there a way to remember what the first one was and then save it in the background till I take my view off it in the game?
You need to learn about prefabs. Create one cube with a script that changes its texture. Then duplicate that prefab 400 times. You certainly do NOT need (nor want) 400 scripts or 400 materials.
(Duh) I have that already 400 is a estimate(give or take 200) right now I care about 1 type of block
Answer by barbe63 · May 20, 2015 at 06:48 PM
How about:
Texture originalTexture;
void Awake()
{
originalTexture = GetComponent<Renderer>().material.mainTexture;
}
And then when you need to have it back reverse with:
GetComponent<Renderer>().material.mainTexture = originalTexture;
Answer by AttilaZold · May 20, 2015 at 05:56 PM
Hi Dude!
Do your cubes have different sizes, or are they all the same (geometrically)? -Because you may have to make 400 (same pixel size) copies of a texture and assign them individually on the 400 Materials you will create for every cube.
Your answer
Follow this Question
Related Questions
Insert the texture means the URL 0 Answers
How can I save MouseLook position in this script ? 0 Answers
Assigning UV Map to model at runtime 0 Answers
How do I build A texture from decals? 0 Answers