playMaker

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

tcmeric

  • Hero Member
  • *****
  • Posts: 525
    • View Profile
Layer Masks in Custom Actions
« on: June 28, 2017, 01: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: 12660
  • Official Playmaker Support
    • View Profile
Re: Layer Masks in Custom Actions
« Reply #1 on: July 04, 2017, 02: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
    • View Profile
Re: Layer Masks in Custom Actions
« Reply #2 on: January 03, 2018, 03: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: 12660
  • Official Playmaker Support
    • View Profile
Re: Layer Masks in Custom Actions
« Reply #3 on: January 16, 2018, 12: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

  • Playmaker Newbie
  • *
  • Posts: 24
    • View Profile
Re: Layer Masks in Custom Actions
« Reply #4 on: February 06, 2018, 12: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, 12:40:03 PM by Digitom »

jeanfabre

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

 woah nice, thanks for sharing!

 Bye,

 Jean