Пример #1
0
        void ShowKeyId()
        {
            int offset = _spOffset.intValue;
            int keyId  = 0;

            if (DataId.EqualsUpper(offset, KeyIdOffset.UI))
            {
                EUIKeyId keyIdEnum = (EUIKeyId)_spKeyId.intValue;
                keyIdEnum = (EUIKeyId)EditorGUILayout.EnumPopup(
                    _spKeyId.displayName, keyIdEnum);
                keyId = (int)keyIdEnum;
            }
            else if (DataId.EqualsUpper(offset, KeyIdOffset.P1))
            {
                EPKeyId keyIdEnum = (EPKeyId)_spKeyId.intValue;
                keyIdEnum = (EPKeyId)EditorGUILayout.EnumPopup(
                    _spKeyId.displayName, keyIdEnum);
                keyId = (int)keyIdEnum;
            }

            _spKeyId.intValue = keyId;
        }
Пример #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            KeyIdAttribute keyIdAttr = (KeyIdAttribute)attribute;

            if (property.propertyType != SerializedPropertyType.Integer)
            {
                Debug.LogError("キーIDにint型以外は使用できません");
                return;
            }

            if (keyIdAttr.KeyIdOffset == KeyIdOffset.P1)
            {
                if (property.intValue != 0 &&
                    !Enum.IsDefined(typeof(EPKeyId), property.intValue))
                {
                    Debug.LogWarning("プロパティはPKeyId型のメンバーではありません");
                }

                EPKeyId curId = (EPKeyId)property.intValue;
                EPKeyId newId = (EPKeyId)EditorGUI.EnumPopup(position, label, curId);

                property.intValue = (int)newId;
            }
            else if (keyIdAttr.KeyIdOffset == KeyIdOffset.UI)
            {
                if (property.intValue != 0 &&
                    !Enum.IsDefined(typeof(EUIKeyId), property.intValue))
                {
                    Debug.LogWarning("プロパティはUIKeyId型のメンバーではありません");
                }

                EUIKeyId curId = (EUIKeyId)property.intValue;
                EUIKeyId newId = (EUIKeyId)EditorGUI.EnumPopup(position, label, curId);

                property.intValue = (int)newId;
            }
        }