/// <summary>
        /// Determine the Unity type of the targets.
        /// </summary>
        protected UnityObjectType DetermineTargetType()
        {
            UnityObjectType unityObjectType = UnityObjectType.None;

            foreach (UnityObject targetObject in targets)
            {
                // Null (non-specified) targets don't affect the type
                // If no non-null target is specified, the type will be None
                // as the loop will simply exit.

                if (targetObject == null)
                {
                    continue;
                }

                if (targetObject is GameObject || targetObject is Component)
                {
                    // For GameObjects and Components, the target is either the
                    // GameObject itself, or the one to which the Component belongs.

                    // If a ScriptableObject target was previously found,
                    // return that the targets are of mixed types.

                    if (unityObjectType == UnityObjectType.ScriptableObject)
                    {
                        return(UnityObjectType.Mixed);
                    }

                    unityObjectType = UnityObjectType.GameObject;
                }
                else if (targetObject is ScriptableObject)
                {
                    // For ScriptableObjects, the target is simply the
                    // ScriptableObject itself.

                    // If a GameObject target was previously found,
                    // return that the targets are of mixed types.

                    if (unityObjectType == UnityObjectType.GameObject)
                    {
                        return(UnityObjectType.Mixed);
                    }

                    unityObjectType = UnityObjectType.ScriptableObject;
                }
                else
                {
                    // Other target types

                    return(UnityObjectType.Other);
                }
            }

            return(unityObjectType);
        }
Exemple #2
0
        /// <inheritdoc />
        protected override void Update(SerializedProperty property)
        {
            // Update the targeted drawer
            base.Update(property);

            // Assign the property and sub-properties
            this.property     = property;
            componentProperty = property.FindPropertyRelative("_component");
            nameProperty      = property.FindPropertyRelative("_name");

            // Fetch the filter
            filter = (FilterAttribute)fieldInfo.GetCustomAttributes(typeof(FilterAttribute), true).FirstOrDefault() ?? DefaultFilter();

            // Find the targets
            targets    = FindTargets();
            targetType = DetermineTargetType();
        }
        /// <inheritdoc />
        protected override void Update(SerializedProperty property)
        {
            // Update the targeted drawer
            base.Update(property);

            // Assign the property and sub-properties
            this.property          = property;
            componentProperty      = property.FindPropertyRelative("_component");
            nameProperty           = property.FindPropertyRelative("_name");
            parameterTypesProperty = property.FindPropertyRelative("_parameterTypes");

            // Fetch the filter
            filter = filterOverride ?? (FilterAttribute)fieldInfo.GetCustomAttributes(typeof(FilterAttribute), true).FirstOrDefault() ?? new FilterAttribute();

            // Check for the label type after attribute
            labelTypeAfter = labelTypeAfterOverride ?? fieldInfo.IsDefined(typeof(LabelTypeAfterAttribute), true);

            // Find the targets
            targets    = FindTargets();
            targetType = DetermineTargetType();
        }
        /// <inheritdoc />
        protected override void Update(SerializedProperty property)
        {
            // Update the targeted drawer
            base.Update(property);

            // Assign the property and sub-properties
            this.property = property;
            componentProperty = property.FindPropertyRelative("_component");
            nameProperty = property.FindPropertyRelative("_name");
            parameterTypesProperty = property.FindPropertyRelative("_parameterTypes");

            // Fetch the filter
            filter = filterOverride ?? (FilterAttribute)fieldInfo.GetCustomAttributes(typeof(FilterAttribute), true).FirstOrDefault() ?? new FilterAttribute();

            // Check for the label type after attribute
            labelTypeAfter = labelTypeAfterOverride ?? fieldInfo.IsDefined(typeof(LabelTypeAfterAttribute), true);

            // Find the targets
            targets = FindTargets();
            targetType = DetermineTargetType();
        }