Unity HUD / GUI Scripting

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  05 May 2014
Unity HUD / GUI Scripting

Hello All,

So I'm about to hit my head against the wall a few times because I am simply going nowhere with my project.

I currently have to create a simple HUD in Unity and implement 2 things into this HUD.

1) Make all of my buttons Clickable. They only need to change the way they look when the mouse presses down on them.

2) Implement a Hotkey for my Health and Mana bars to where I can make each one go down by a set amount when I press the key.

Here is my problem. I dragged a Maya Scene with all my objects over, and Unity is treating all of my individual objects, as one game object because they are all children of the Scene. Because of this I can't select any of them when it comes to scripting.

My images were saved as a .png file, and then put as a Lambert texture in Maya onto a plane. (all were set to have transparent backgrounds.)

As for my Buttons, I have two Planes for each button. One with an "Off" texture, and one with an "On" Texture.

Like I Said these are all Children of the "Scene parent" so None of them are actual Game objects.

Here is my code to have my Health Bar change when I press my Hotkey.
__________________________________________________ ___


  vartheHealthBar: GameObject;
   functionUpdate () {
   if(Input.GetKeyDown ("a")){
   	    theHealthBar.transform.localScale += Vector3(0.1, 0.0);
   theHealthBar.transform.localPosition += Vector2(0.05, 0.0);

and if I could get the children to become GameObject's I assume a script such as this could work.

varability: GameObject;
   varButtonUp: GUITexture;
   varButtonDown: GUITexture;
   functionOnMouseDown ()
   ability.transform.GUITexture = ButtonDown;
   functionOnMouseUp ()
   ability.transform.GUITexture = ButtonUp;	

__________________________________________________ __

If you can help please do. This is a class Final and due to the fact that I had to drive 5 hours home to work this weekend I'm unable to actually go in and get help. =/

Thank you
reply share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 05:19 AM.

Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.