Skip to content

Commit b417b5b

Browse files
authored
Merge pull request #1751 from thestonefox/refactor/enum-mask-deprecation
refactor(PolicyList): provide alternative for deprecated EnumMaskField
2 parents 8c5021d + 4454d25 commit b417b5b

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

Assets/VRTK/Source/Editor/VRTK_PolicyListEditor.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
11
namespace VRTK
22
{
3-
using UnityEngine;
43
using UnityEditor;
4+
using System;
55

66
[CustomEditor(typeof(VRTK_PolicyList))]
77
public class VRTK_PolicyListEditor : Editor
88
{
99
SerializedProperty staticFlagMask;
1010
SerializedProperty identifiers;
1111

12-
private void OnEnable()
13-
{
14-
staticFlagMask = serializedObject.FindProperty("checkType");
15-
identifiers = serializedObject.FindProperty("identifiers");
16-
}
17-
1812
public override void OnInspectorGUI()
1913
{
2014
serializedObject.Update();
21-
2215
EditorGUILayout.PropertyField(serializedObject.FindProperty("operation"));
23-
staticFlagMask.intValue = (int)((VRTK_PolicyList.CheckTypes)EditorGUILayout.EnumMaskField("Check Types", (VRTK_PolicyList.CheckTypes)staticFlagMask.intValue));
16+
staticFlagMask.intValue = (int)((VRTK_PolicyList.CheckTypes)EnumField("Check Types", (VRTK_PolicyList.CheckTypes)staticFlagMask.intValue));
2417
ArrayGUI(identifiers);
2518

2619
serializedObject.ApplyModifiedProperties();
2720
}
2821

29-
void ArrayGUI(SerializedProperty property)
22+
private void OnEnable()
23+
{
24+
staticFlagMask = serializedObject.FindProperty("checkType");
25+
identifiers = serializedObject.FindProperty("identifiers");
26+
}
27+
28+
private Enum EnumField(string label, Enum enumValue)
29+
{
30+
#if UNITY_2017_3_OR_NEWER
31+
return EditorGUILayout.EnumFlagsField(label, enumValue);
32+
#else
33+
return EditorGUILayout.EnumMaskField(label, enumValue);
34+
#endif
35+
}
36+
37+
private void ArrayGUI(SerializedProperty property)
3038
{
3139
SerializedProperty arraySizeProp = property.FindPropertyRelative("Array.size");
3240
EditorGUILayout.PropertyField(arraySizeProp);

Assets/VRTK/Source/Editor/VRTK_SDKManagerEditor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System;
77
using System.Collections.Generic;
88
using System.Linq;
9-
using System.Reflection;
109

1110
[CustomEditor(typeof(VRTK_SDKManager))]
1211
public class VRTK_SDKManagerEditor : Editor

0 commit comments

Comments
 (0)