public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            a = (StyledMask)attribute;

            GUIStyle styleLabel = new GUIStyle(EditorStyles.label)
            {
                richText  = true,
                alignment = TextAnchor.MiddleCenter,
                wordWrap  = true
            };

            string[] enums = a.options.Split(char.Parse("_"));

            GUILayout.Space(a.top);

            int mask = (int)property.intValue;

            mask = EditorGUILayout.MaskField(property.displayName, mask, enums);

            if (Mathf.Abs(mask) > 32000)
            {
                mask = -1;
            }

            // Debug Value
            //EditorGUILayout.LabelField(mask.ToString());

            property.intValue = mask;

            GUI.enabled = true;

            GUILayout.Space(a.down);
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            a = (StyledMask)attribute;

            GUIStyle styleLabel = new GUIStyle(EditorStyles.label)
            {
                richText  = true,
                alignment = TextAnchor.MiddleCenter,
                wordWrap  = true
            };

            string[] masks = new string[] { a.mask0, a.mask1 };

            if (a.index == 3)
            {
                masks = new string[] { a.mask0, a.mask1, a.mask2 };
            }
            else if (a.index == 4)
            {
                masks = new string[] { a.mask0, a.mask1, a.mask2, a.mask3 };
            }
            else if (a.index == 5)
            {
                masks = new string[] { a.mask0, a.mask1, a.mask2, a.mask3, a.mask4 };
            }
            else if (a.index == 6)
            {
                masks = new string[] { a.mask0, a.mask1, a.mask2, a.mask3, a.mask4, a.mask5 };
            }
            else if (a.index == 7)
            {
                masks = new string[] { a.mask0, a.mask1, a.mask2, a.mask3, a.mask4, a.mask5, a.mask6 };
            }
            else if (a.index == 8)
            {
                masks = new string[] { a.mask0, a.mask1, a.mask2, a.mask3, a.mask4, a.mask5, a.mask6, a.mask7 };
            }

            GUILayout.Space(a.top);

            int mask = (int)property.intValue;

            mask = EditorGUILayout.MaskField(property.displayName, mask, masks);

            if (Mathf.Abs(mask) > 32000)
            {
                mask = -1;
            }

            // Debug Value
            //EditorGUILayout.LabelField(mask.ToString());

            property.intValue = mask;

            GUI.enabled = true;

            GUILayout.Space(a.down);
        }
Exemple #3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            a = (StyledMask)attribute;

            GUIStyle styleLabel = new GUIStyle(EditorStyles.label)
            {
                richText  = true,
                alignment = TextAnchor.MiddleCenter,
                wordWrap  = true
            };

            if (Resources.Load <TextAsset>(a.file) != null)
            {
                var layersPath = AssetDatabase.GetAssetPath(Resources.Load <TextAsset>(a.file));

                StreamReader reader = new StreamReader(layersPath);

                a.options = reader.ReadLine();

                reader.Close();
            }

            string[]      enumSplit   = a.options.Split(char.Parse(" "));
            List <string> enumOptions = new List <string>(enumSplit.Length / 2);

            for (int i = 0; i < enumSplit.Length; i++)
            {
                if (i % 2 == 0)
                {
                    enumOptions.Add(enumSplit[i].Replace("_", " "));
                }
            }

            GUILayout.Space(a.top);

            int index = property.intValue;

            if (a.display == "")
            {
                a.display = property.displayName;
            }

            index = EditorGUILayout.MaskField(a.display, index, enumOptions.ToArray());

            if (Mathf.Abs(index) > 32000)
            {
                index = -1;
            }

            //Debug Value
            EditorGUILayout.LabelField(index.ToString());

            property.intValue = index;

            GUILayout.Space(a.down);
        }