playMaker

Author Topic: Setting Label on NGUI button from Prefab [SOLVED]  (Read 4649 times)

MrAdventure

  • Playmaker Newbie
  • *
  • Posts: 24
Setting Label on NGUI button from Prefab [SOLVED]
« on: January 16, 2014, 06:37:27 PM »
Hello. I seem to be stuck in some kind of circular hell. Every time I approach this problem from a different direction, I get stuck in the same spot. It makes me think I'm missing something basic, so please help out.

I followed these instructions

http://hutonggames.com/playmakerforum/index.php?topic=3706.0

step by step in order to be able to access an NGUI button. The problem happens right at the end, when dragging the component UILabel into the Get Component slot. It won't go in, instead I get the dreaded Get / Set Property context menu.

Thanks for the help. I feel like it's been a long slog through the marsh, but one day I'll find the other end.

« Last Edit: January 16, 2014, 09:04:40 PM by MrAdventure »

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Same problem every time, can't drag without Get/Set Property menu
« Reply #1 on: January 16, 2014, 06:55:17 PM »
A script component can't be used as a gameobject (that's why you get the get/set dialog) Do you need to put the gameobject the script is on into the slot rather than the script?!

MrAdventure

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Same problem every time, can't drag without Get/Set Property menu
« Reply #2 on: January 16, 2014, 07:48:10 PM »
Yes, I understand what you are saying. But why then, when I specify the GameObject (in this case, an NGUI Label,) and set the variable type to fill as UILabel, instead of getting the component, it resets that field to None every time I run it?

redikann

  • Full Member
  • ***
  • Posts: 174
Re: Same problem every time, can't drag without Get/Set Property menu
« Reply #3 on: January 16, 2014, 08:10:43 PM »
This is a longshot but when I look at your pic at the top of the inspector it says missing. I usually get that when I have a pre fab in the scene but I deleted the pre fab in the asset folders.

MrAdventure

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Same problem every time, can't drag without Get/Set Property menu
« Reply #4 on: January 16, 2014, 08:17:02 PM »
Thank you both for your help! It turned out an error in another FSM was causing this, when I deactivated those Actions the value stayed.

Thanks again!

MrAdventure

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Same problem every time, can't drag without Get/Set Property menu
« Reply #5 on: January 16, 2014, 08:34:06 PM »
Is this even the right way to do this? I'm just trying to access the NGUI label and change it. Doing it this way I have it as an Object, not GameObject, and don't see any way to manipulate it's value.

MrAdventure

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Same problem every time, can't drag without Get/Set Property menu
« Reply #6 on: January 16, 2014, 09:02:12 PM »
Yes! Finally done!

For posterity, in my Initializer GameObject, in the scene (so it doesn't lose its values on startup) I used Get Component to store UILabel of my NGUI label. This had to be in an Object -> UILabel.

Then in the Prefab, which was always losing its values on Startup, I now use the initialized global variable and set it's Text value to my desired amount.

Seriously, I must have done different versions of this 1000 times in the last two weeks. Finally I gave up and watched this: . When I was feeling more relaxed, it finally started to flow. Thanks for the help!

Victor