playMaker

Author Topic: Object Type Field in Playmaker Action  (Read 1239 times)

Rebooter

  • Playmaker Newbie
  • *
  • Posts: 21
Object Type Field in Playmaker Action
« on: October 23, 2019, 12:59:05 PM »
Is there some way to have a public field in an action that lets the user select a type, similar to the 'Variables' tab's 'Object Type' field? I want to be able to select an Object Type then feed that to 'GetComponentsInChildren' something like this:

gameObject.GetComponentsInChildren<ObjectType>()

Edit:

Ok, I found this in an action:

Code: [Select]
[RequiredField]
[UIHint(UIHint.ScriptComponent)]
[Title("Component Type"), Tooltip("The type of Component to add to the Game Object.")]
public FsmString component;

***

ReflectionUtils.GetGlobalType(component.Value);

But this uses reflection (which I gather is slow), so I will probably just make an action for the specific type.
« Last Edit: October 23, 2019, 04:16:24 PM by Rebooter »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Object Type Field in Playmaker Action
« Reply #1 on: November 13, 2019, 01:38:57 AM »
Hi,

 you won't be able to propose a list of objects without using reflections as it has to be serialized, and then the only way to retrieve that object is via reflection...

making action for the specific type is the way to go if you know how to create actions. make sure you use the caching system for actions ( check AddExplosionForce to see how componentAction<> is used)


Bye,

 Jean