Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Rebooter on October 23, 2019, 12:59:05 PM

Title: Object Type Field in Playmaker Action
Post by: Rebooter 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.
Title: Re: Object Type Field in Playmaker Action
Post by: jeanfabre 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