Esempio n. 1
0
        public static bool BehaviourPropertyIsVisible(MonoBehaviour behaviour, string propertyName, DrawIfBaseAttribute 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));
        }
Esempio n. 2
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            Initialize(property);

            toShow = ConditionalFieldUtility.PropertyIsVisible(conditionalToTarget[property], instance.inverse, instance.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));
        }
Esempio n. 3
0
        private void Initialize(SerializedProperty property)
        {
            if (instance == null)
            {
                instance = base.attribute as DrawIfBaseAttribute;
            }
            if (instance == null)
            {
                return;
            }

            if (!conditionalToTarget.ContainsKey(property))
            {
                conditionalToTarget.Add(property, ConditionalFieldUtility.FindRelativeProperty(property, instance.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 (HaveMultipleAttributes())
            {
                multipleAttributes = true;
                GetPropertyDrawerType(property);
            }
            else if (!fieldInfo.FieldType.Module.ScopeName.Equals(typeof(int).Module.ScopeName))
            {
                specialType = true;
                GetTypeDrawerType(property);
            }

            customDrawersCached = true;
        }