Playmaker Forum
PlayMaker News => General Discussion => Topic started by: tcmeric on June 28, 2017, 04:41:16 AM
-
I am trying to get layer masks working in a custom action. I see that the raycast action just uses a layer mask int. Is there any way to get the correct editor enum for layers working in a playmaker action?
Any example actions of this working?
-
Hi,
this is tricky, can you tell me which layer mask you want to access exactly, I'll check it out, else, you have to come up with your own custom property drawer, I did it for PathFinding Actions, it's a pain, but code sample is available.
Bye,
Jean
-
Curious if there was anything that came out of this? I too am attempting to get the layer masks to work in a custom action.
-
Hi,
Which layerMask do you want to support? I'll give you a working action so you can get up and running, it basicallly needs a custom editor for this... Unity doesn't provide with one.
Bye,
Jean
-
Managed to get this working. You can use a fsmInt in your regular FSMscript for the layerMask. You can then use Unity's built in InternalEditor to access the engine's LayerMask stuff and convert it to the regular script's layerMask fsmInt.Value .. should work the same as a regular unity layermask.
using HutongGames.PlayMaker.Actions;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
namespace HutongGames.PlayMakerEditor
{
[CustomActionEditor(typeof(FSMscript))]
public class FSMscriptEditor : CustomActionEditor
{
public override bool OnGUI()
{
var action = target as FSMscript;
GUILayout.Label("Filter:", EditorStyles.boldLabel);
int temp = EditorGUILayout.MaskField("Mask",InternalEditorUtility.LayerMaskToConcatenatedLayersMask(action.layerMask.Value), InternalEditorUtility.layers);
action.layerMask.Value = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(temp);
return GUI.changed;
}
-
Hi,
woah nice, thanks for sharing!
Bye,
Jean
-
Does this still work? I really need a layermask type in an action (it's an action to perform a circlecast and do some stuff after it), but when I use this customeditor script in Unity 2020.3 I get this compile error:
CS1061: 'LayerMask' does not contain a definition for 'Value' and no accessible extension method 'Value' accepting a first argument of type 'LayerMask' could be found (are you missing a using directive or an assembly reference?)
Which is weird, because layerMask is an FsmInt which obviously has a "Value" member.
ff
-
Hi,
What action are you using that needs layermask?
the way it's supposed to work in playmaker action is by using a FsmInt array and then internaly, the action turn that list into a layer mask.
like here:
https://hutonggames.com/playmakerforum/index.php?topic=2922.msg13353#msg13353
Bye,
Jean