Char select / GUI button question.

Hey guys,

I've created a screen of character picture buttons

I want these buttons to correspond with a gameobject. Then I want said gameobject to be taken into the next scene on click.

I'm in a pretty big rush to get this finished, any help would be highly appreciated.

thanks!

Ok... and what exactly is the problem?

3 Answers

3

as i understand u basically have gui buttons with texture of character pictures and when you click on these pictures you want it to load next scene? if yes control of your gui button is as follows;


public Texture picturetexture;

void OnGUI(){

if(GUI.Button(new Rect(10, 10, 50, 50), picturetexture))
Application.LoadLevel(1); // in bracket you type your scene name or level number

}

hmm if you dont have too many character the simplest way to do it may be setting separate scene for each character and use the code above to load scenes for each character but if you have too many characters it is silly way to do this method because once you want to build it ll be hard for unityengine to build each scene one by one you can dig this thread if you like http://answers.unity3d.com/questions/47753/choosing-from-multiple-characters

Take a look at GameObject.Active

When you are showing your GUI buttons, deativate all your characters, and when you click on the relevant GUI button, simply activate the character/camera in your scene you want to play with.

I suggest that you look into key binders, like the one in the bootcamp demo for the gun manager. That way you could make a spot for the icon, and the gameObject. After that, use don't destroy on load. Recap: there is a key binder that has spots for a gameobject and an icon, and when the player presses the gui button, it adds a dontdestroyonload script. Good Luck :)

ps: when you are done with your immediate problem, you should edit you question so that it doesn't say "Urgent"