Пример #1
0
        public static bool BehaviourPropertyIsVisible(MonoBehaviour behaviour, string propertyName, ConditionalFieldAttribute appliedAttribute)
        {
            if (string.IsNullOrEmpty(appliedAttribute.FieldToCheck))
            {
                return(true);
            }

            var so             = new SerializedObject(behaviour);
            var property       = so.FindProperty(propertyName);
            var targetProperty = ConditionalFieldUtility.FindRelativeProperty(property, appliedAttribute.FieldToCheck);

            return(ConditionalFieldUtility.PropertyIsVisible(targetProperty, appliedAttribute.Inverse, appliedAttribute.CompareValues));
        }
Пример #2
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            Initialize(property);

            _toShow = ConditionalFieldUtility.PropertyIsVisible(_conditionalToTarget[property], _attribute.Inverse, _attribute.CompareValues);
            if (!_toShow)
            {
                return(0);
            }

            if (_genericDrawerInstance != null)
            {
                return(_genericDrawerInstance.GetPropertyHeight(property, label));
            }
            if (_genericTypeDrawerInstance != null)
            {
                return(_genericTypeDrawerInstance.GetPropertyHeight(property, label));
            }
            return(EditorGUI.GetPropertyHeight(property));
        }
Пример #3
0
        private void Initialize(SerializedProperty property)
        {
            if (_attribute == null)
            {
                _attribute = attribute as ConditionalFieldAttribute;
            }
            if (_attribute == null)
            {
                return;
            }

            if (!_conditionalToTarget.ContainsKey(property))
            {
                _conditionalToTarget.Add(property, ConditionalFieldUtility.FindRelativeProperty(property, _attribute.FieldToCheck));
            }


            if (_customDrawersCached)
            {
                return;
            }
            if (_typesCache == null)
            {
                _typesCache = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes())
                              .Where(x => typeof(PropertyDrawer).IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract);
            }

            if (fieldInfo.GetCustomAttributes(typeof(PropertyAttribute), false).Count() > 1)
            {
                _multipleAttributes = true;
                GetPropertyDrawerType(property);
            }
            else if (!fieldInfo.FieldType.Module.ScopeName.Equals(typeof(int).Module.ScopeName))
            {
                _specialType = true;
                GetTypeDrawerType(property);
            }

            _customDrawersCached = true;
        }