playMaker

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

Rebooter

  • Playmaker Newbie
  • *
  • Posts: 21
    • View Profile
Object Type Field in Playmaker Action
« on: October 23, 2019, 09:59:05 AM »
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, 01:16:24 PM by Rebooter »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15398
  • Official Playmaker Support
    • View Profile
Re: Object Type Field in Playmaker Action
« Reply #1 on: November 12, 2019, 11:38:57 PM »
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