Author Topic: complete beginner question - transfer values from ugui to ngui  (Read 3291 times)

mrpeaks

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Hey everyone! my sorry for asking you guys, but i'm completely lost with ngui :/ my goal is to create a hud for a spaceship game. I have an standard unity text-gui running and would like to know how i can "transfer" the "data" from unity gui to ngui text label.  ( For example Ammo and it's value.) here's a code snipped:

  1. void OnGUI(){
  2.                 GUI.skin = Holographic;
  3.                 if(!weaponManager || currentWeapon>weaponManager.WeaponLists.Length)
  4.                         return;
  5.                
  6.                 GUI.skin.label.fontSize = 15;
  7.                 if(!weaponManager.WeaponLists[currentWeapon].InfinityAmmo){
  8.                         GUI.Label(new Rect(10,70,300,50),"Ammo"+weaponManager.WeaponLists[currentWeapon].Ammo+" / "+weaponManager.WeaponLists[currentWeapon].AmmoMax);
  9.                 }else{
  10.                         GUI.Label(new Rect(20,70,300,50),"Infinity ammo");
  11.                 }
  12.                 GUI.skin.label.fontSize = 15;
  13.                 GUI.Label(new Rect(20,40,300,50),""+weaponManager.WeaponLists[currentWeapon].name);
  14.                
  15.        
  16.         }

any help is welcome  :'(

r.pedra

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 20
  • Posts: 131
    • View Profile
Re: complete beginner question - transfer values from ugui to ngui
« Reply #1 on: July 24, 2014, 09:23:39 AM »
They are both working a totally different way, it's pretty hard to do it. I think you will be faster by doing it all again in NGUI trying to reproduce the same UI

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: complete beginner question - transfer values from ugui to ngui
« Reply #2 on: July 25, 2014, 01:27:09 AM »
Yeah forget what you learned about OnGUI, it will only harm you when using NGUI. In NGUI you need to create a layout for what your UI should look like -- in your case a pair of labels. One label will be for your ammo, another for your weapon name. Attach a script to each label that will update its label.text with the appropriate value in the Update() function.