- Home /
Convert Int to String?
i wanna make a function that when i click a button set active the next canvas and inactive the current canvas, if just was one of two could be easy but are at least 50....
i try make a var that represent the number of the canvas in the scene and star in 0, so when i press a button the var++ and represent the next scene...and not have to make a lot of functions inactive and active canvas
int nextScene = 0;
public Canvas Canvas1
public void NextFunction ()
{
nextScene++;
nextScene.toString();
Canvas("nextScene").enabled=false;
}
make array of canvases and call them by index in that array
I can't see what int-string conversion has to do with the actual issue. It seems like your trying to do this in a non-optimal way.
Answer by W.Walter · Jul 04, 2015 at 02:16 AM
The idea is to store all the canvases in an array, so you can access them by index. Then, when you want to go to the next one; inactive the current one, increment the index, and activate the canvas at the new index.
int current_scene = 0;
public Canvas[] canvases; // Array of canvases, accessed by index
public void NextFunction ()
{
// Before incrementing the current_scene value, inactivate the last canvas
canvases[current_scene].enabled = false;
// Note; this will eventually create an IndexOutOfBounds error
current_scene++;
canvases[current_scene].enabled = true;
}
Your answer
Follow this Question
Related Questions
Cannot implicitly convert type string to list - Why is this? 1 Answer
Distribute terrain in zones 3 Answers
Converting a string to an int 2 Answers
Particle circle HELP 1 Answer