x


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!

more ▼

asked Apr 08 '11 at 05:35 AM

Bobby Stillz gravatar image

Bobby Stillz
3 4 4 9

Ok... and what exactly is the problem?

Apr 08 '11 at 06:18 AM KeithK

I Can't figure out how to correspond a gameobject with a button click.

Apr 08 '11 at 06:23 AM Bobby Stillz
(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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.

more ▼

answered Apr 08 '11 at 09:27 AM

Meltdown gravatar image

Meltdown
5.6k 18 25 49

(comments are locked)
10|3000 characters needed characters left

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

}

more ▼

answered Apr 08 '11 at 07:08 AM

seyyid gravatar image

seyyid
91 3 3 6

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.

Apr 08 '11 at 07:11 AM Bobby Stillz

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

Apr 08 '11 at 07:33 AM seyyid
(comments are locked)
10|3000 characters needed characters left

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"

more ▼

answered Apr 08 '11 at 10:09 AM

zmar0519 gravatar image

zmar0519
946 59 66 78

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3678
x2083
x1041
x786
x131

asked: Apr 08 '11 at 05:35 AM

Seen: 1667 times

Last Updated: Apr 08 '11 at 05:35 AM