Beispiel #1
0
        protected override float GetPropertyHeight_Internal(SerializedProperty property, GUIContent label)
        {
            AnimatorParamAttribute animatorParamAttribute = PropertyUtility.GetAttribute <AnimatorParamAttribute>(property);
            bool validAnimatorController = GetAnimatorController(property, animatorParamAttribute.AnimatorName) != null;
            bool validPropertyType       = property.propertyType == SerializedPropertyType.Integer || property.propertyType == SerializedPropertyType.String;

            return((validAnimatorController && validPropertyType)
                                ? GetPropertyHeight(property)
                                : GetPropertyHeight(property) + GetHelpBoxHeight());
        }
Beispiel #2
0
        protected override void OnGUI_Internal(Rect rect, SerializedProperty property, GUIContent label)
        {
            AnimatorParamAttribute animatorParamAttribute = PropertyUtility.GetAttribute <AnimatorParamAttribute>(property);

            AnimatorController animatorController = GetAnimatorController(property, animatorParamAttribute.AnimatorName);

            if (animatorController == null)
            {
                DrawDefaultPropertyAndHelpBox(rect, property, InvalidAnimatorControllerWarningMessage, MessageType.Warning);
                return;
            }

            int parametersCount = animatorController.parameters.Length;
            List <AnimatorControllerParameter> animatorParameters = new List <AnimatorControllerParameter>(parametersCount);

            for (int i = 0; i < parametersCount; i++)
            {
                AnimatorControllerParameter parameter = animatorController.parameters[i];
                if (animatorParamAttribute.AnimatorParamType == null || parameter.type == animatorParamAttribute.AnimatorParamType)
                {
                    animatorParameters.Add(parameter);
                }
            }

            switch (property.propertyType)
            {
            case SerializedPropertyType.Integer:
                DrawPropertyForInt(rect, property, label, animatorParameters);
                break;

            case SerializedPropertyType.String:
                DrawPropertyForString(rect, property, label, animatorParameters);
                break;

            default:
                DrawDefaultPropertyAndHelpBox(rect, property, string.Format(InvalidTypeWarningMessage, property.name), MessageType.Warning);
                break;
            }
        }