- Home /
Question by
dartlinggun · May 21, 2020 at 10:07 PM ·
editor-scriptinglayermaskserializedproperty
How to get the layer mask value of a SerializedProperty?
For example, my MonoBehaviour class has a LayerMask instance and I need access it from a custom editor class. So I'm using serializedObject.FindProperty("myProperty"). But how can I access the layerMask value inside this property?
class MyClass { LayerMask myLayerMask; }
class EditorClass { layerMaskprop = serializedObject.FindProperty("myLayerMask"); Debug.Log($"LayerMask value is {layerMaskProp.somethingIDontKnow}"); // I don't know what to call
}
Comment
Answer by ggetic · Dec 22, 2021 at 04:59 PM
@dartlinggun I hope you already found the answer. But those who are coming here in future this may help them. Layermask values are basically Int values. So in the above example you can get the layer mask value like -
SerializedProperty layermaskSP = serializedObject.FindProperty("myLayerMask");
Debug.Log( "LayerMask value is " + layermaskSP.intValue);