Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: MrAdventure on January 16, 2014, 06:37:27 PM

Title: Setting Label on NGUI button from Prefab [SOLVED]
Post by: MrAdventure 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.

Title: Re: Same problem every time, can't drag without Get/Set Property menu
Post by: escpodgames 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?!
Title: Re: Same problem every time, can't drag without Get/Set Property menu
Post by: MrAdventure 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?
Title: Re: Same problem every time, can't drag without Get/Set Property menu
Post by: redikann 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.
Title: Re: Same problem every time, can't drag without Get/Set Property menu
Post by: MrAdventure 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!
Title: Re: Same problem every time, can't drag without Get/Set Property menu
Post by: MrAdventure 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.
Title: Re: Same problem every time, can't drag without Get/Set Property menu
Post by: MrAdventure 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