playMaker

Author Topic: Layer Masks in Custom Actions  (Read 6163 times)

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Layer Masks in Custom Actions
« 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?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Layer Masks in Custom Actions
« Reply #1 on: July 04, 2017, 05:56:56 AM »
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

KellyRay

  • Full Member
  • ***
  • Posts: 170
Re: Layer Masks in Custom Actions
« Reply #2 on: January 03, 2018, 05:36:20 PM »
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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Layer Masks in Custom Actions
« Reply #3 on: January 16, 2018, 02:43:12 AM »
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

Digitom

  • Junior Playmaker
  • **
  • Posts: 61
Re: Layer Masks in Custom Actions
« Reply #4 on: February 06, 2018, 02:34:28 PM »
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.

Code: [Select]
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;

        }
« Last Edit: February 06, 2018, 02:40:03 PM by Digitom »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Layer Masks in Custom Actions
« Reply #5 on: February 07, 2018, 03:45:49 AM »
Hi,

 woah nice, thanks for sharing!

 Bye,

 Jean

acknickulous

  • Playmaker Newbie
  • *
  • Posts: 19
Re: Layer Masks in Custom Actions
« Reply #6 on: May 03, 2021, 01:08:39 PM »
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:

Code: [Select]
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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Layer Masks in Custom Actions
« Reply #7 on: May 12, 2021, 06:02:55 AM »
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