- Home /
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!
I Can't figure out how to correspond a gameobject with a button click.
Answer by Meltdown · Apr 08, 2011 at 09:27 AM
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.
Answer by seyyid · Apr 08, 2011 at 07:08 AM
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
}
Thanks for responding!
I would like for each button to correspond with a unique gameobject. So when you click that button, your controllable character is who you picked.
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
Answer by zmar0519 · Apr 08, 2011 at 10:09 AM
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"
Your answer
Follow this Question
Related Questions
Using GUI and check what button was pressed 1 Answer
Searching for gameobjects with a tag and creating a button for each one? 1 Answer
Problem with texture to reset and re-enter the same texture 0 Answers
Is it possible to link a UI element to a gameobject? 1 Answer
GUI Button follow GameObject, like floating button how to on C++? 2 Answers