playMaker

Author Topic: Set Property/ Target Object - No Variables Appearing in List [SOLVED]  (Read 3844 times)

memetic arts

  • Full Member
  • ***
  • Posts: 141
Hi -

I'm using a prefab to generate NGUI buttons which, when clicked, will pass metadata to a single set of NGUI UI objects to display that metadata (it's the classic list-to-detail pattern).  The buttons are on one panel, while the "detail" view is another.

I know you can't refer to scene objects from a prefab, so, per best practice, I'm finding the GameObjects at runtime and storing references to them in global variables.

To pass the metadata, I'm first performing a Get for each data element, and storing it.  The problem is with the 'Set Property' action, and defining the Target.  When I access the variable list for the Target Object, the global vars aren't there -- just a single option that says "None". 

I actually had it all working a few hours ago, after reading that I could lock the Inspector and drag objects right into the State panel to create prepopulated set/get actions, only to find later that those settings couldn't be saved because of the "No Scene Objects" rule . . .

So now I'm stuck . . . totally baffled as to why the globals aren't showing up, since they appear in the variables list, as well as in other dropdowns where globals are made available.

Thanks for any/all help . . .

« Last Edit: April 21, 2013, 10:31:55 AM by memetic arts »

memetic arts

  • Full Member
  • ***
  • Posts: 141
Re: Set Property/ Target Object - No Variables Appearing in List [SOLVED]
« Reply #1 on: April 21, 2013, 10:30:26 AM »
Well, as often happens, I was finally able to resolve this myself.  Amazing what a few hours of sleep can do!

I found that that the Target dropdown list wouldn't populate with the Globals because I'd originally set them through FindGameObject.  Turns out Target Object doesn't want GameObjects at all, but rather plain Objects.  I also realized that because I was trying to modify NGUI sprites and labels, what I really needed to set were props of the *Components*, not props of the GO.  So, the fix involved two things:

1. Change the Global Variable type to "Object" instead of "GameObject.  Then in the Global Vars "Object Type" dropdown, the default "UnityEngine.Object" had to be changed to the exact type of the respective component.  So in the case of my NGUI sprite, there is actually an option in the list for "UISprite".  Perfect.

2. I had to remove my FindGameObject action and replace it with a GetComponent action.  Since this was placed in my Initialization FSM for the purposes of establishing connection with Scene Objects, I was able to simply drag the relevant Game Object value in from the Scene Hierarchy, no problem.  I then set the "Store Component" field by selecting the Global Var that I'd set up for my UISprite.  Make sure that the "Every Frame" checkbox is UNCHECKED or the FSM will hang there indefinitely, breaking the flow.

Having done that, the object showed up in the Target Object dropdown as expected.

Phew, what a mindbender that was . .  .  Hope this helps someone else down the line.


Gevarre

  • Playmaker Newbie
  • *
  • Posts: 49
Thanks for explaining that :)

It's exactly what I was looking for, and I never would have figured that out myself.

memetic arts

  • Full Member
  • ***
  • Posts: 141
Glad to have helped you avert some pain!