PlayMaker News > General Discussion

Layer Masks in Custom Actions

(1/2) > >>

tcmeric:
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:
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:
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:
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:
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: ---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;

        }
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version