- Home /
Question by
prateekkp · Jan 13, 2015 at 04:52 PM ·
editor-scriptingenumserializedpropertybitwise
If Check for serialized flag enums in Editor scripting
How do i write this
**if( (spawnPointType & SpawnPointTypes.HiddenSpawn) == SpawnPointTypes.HiddenSpawn)
{
bla... blaa...
}**
for seriazlied property in unity editor's OnInspectorGUI method.
[CustomEditor(typeof(SpawnPoint))]
public class SpawnPointEditor : Editor
{
SerializedObject myObj;
public SerializedProperty spawnPointTypeMask;
void OnEnable ()
{
myObj = new SerializedObject (target);
spawnPointTypeMask = myObj.FindProperty ("spawnPointType");
}
public override void OnInspectorGUI ()
{
serializedObject.Update ();
spawnPointTypeMask.intValue = (int)((SpawnPointTypes)EditorGUILayout.EnumMaskField
("SpawnPointType", (SpawnPointTypes)spawnPointTypeMask.intValue));
//THE SAME IF CHECK FOR SERIALIZED ENUMS
`// WHAT TO WRITE IN IF STATEMENT`
**if( ? ? ? )
{
bla.. blaa..
}**
serializedObject.ApplyModifiedProperties ();
}
}
Comment
The exact same way you check for non-serialized ones? Not really getting the issue here.
Your answer
![](https://koobas.hobune.stream/wayback/20220613180320im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Dynamic serialized fields based on enum 0 Answers
How do I associate my custom object for the serializedProperty objectReferenceValue 1 Answer
Changing isExpanded property from another Editor 0 Answers
Mass component editing through SerializedProperty or Setters 0 Answers
How can I make dynamic gui based off of the variables from a serializable class? 1 Answer