playMaker

Author Topic: How do I know which event has been sent by that specific clone?  (Read 1371 times)

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
How do I know which event has been sent by that specific clone?
« on: October 03, 2016, 09:34:01 AM »
Let's say that each of the prefabs have a text component in, and when the prefab is clicked, I want to know about this, so maybe send an event or something then I want to know which ones have been clicked and then add up those two text components values to one string value.. It might be an easy thing to do, I've not used playmaker for a while though and I don't remember how it actually works.

ransomink

  • Playmaker Newbie
  • *
  • Posts: 44
Re: How do I know which event has been sent by that specific clone?
« Reply #1 on: October 03, 2016, 10:40:04 PM »
Let's say that each of the prefabs have a text component in, and when the prefab is clicked, I want to know about this...

What exactly do you want to know? Do you want to know what their text component says or when a prefab is clicked?

If you want to know when a prefab is clicked, use the Mouse Pick or Mouse Pick Event. You can use Mouse Pick Event to send an event to a state with a Debug Log action that writes to the console. This will give you feedback if the prefab was clicked.

then I want to know which ones have been clicked...

Method 1
You can create an array or list and add each clicked prefab to that array/list. Then, if you need to check which ones are clicked, iterate through the array/list. (Each prefab in the array/list has been clicked.)

Method 2
Create a boolean, let's say it's named "Clicked?" on the prefab. When that prefab is clicked, either flip or set the boolean to true. You can check if a prefab has been clicked by comparing that prefab's "Clicked?" boolean variable. (This allows you to check a single prefab without the use of iteration.)

Or search for all gameobjects with a tag (prefab MUST have a tag); this will place them into an array. Then you can iterate through the array and check the "Clicked?" boolean variable on each prefab.

There may be other suggestions people can give you on here. Hope this helps...