Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,41 +130,36 @@ private static AnimatorController GetAnimatorController(SerializedProperty prope
{
object target = PropertyUtility.GetTargetObjectWithProperty(property);

FieldInfo animatorFieldInfo = ReflectionUtility.GetField(target, animatorName);
if (animatorFieldInfo != null &&
animatorFieldInfo.FieldType == typeof(Animator))
static Animator ResolveAnimator(object obj, string memberName)
{
Animator animator = animatorFieldInfo.GetValue(target) as Animator;
if (animator != null)
{
AnimatorController animatorController = animator.runtimeAnimatorController as AnimatorController;
return animatorController;
}
}
var field = ReflectionUtility.GetField(obj, memberName);
if (field != null && field.FieldType == typeof(Animator))
return field.GetValue(obj) as Animator;

PropertyInfo animatorPropertyInfo = ReflectionUtility.GetProperty(target, animatorName);
if (animatorPropertyInfo != null &&
animatorPropertyInfo.PropertyType == typeof(Animator))
{
Animator animator = animatorPropertyInfo.GetValue(target) as Animator;
if (animator != null)
{
AnimatorController animatorController = animator.runtimeAnimatorController as AnimatorController;
return animatorController;
}
var prop = ReflectionUtility.GetProperty(obj, memberName);
if (prop != null && prop.PropertyType == typeof(Animator))
return prop.GetValue(obj) as Animator;

var getter = ReflectionUtility.GetMethod(obj, memberName);
if (getter != null && getter.ReturnType == typeof(Animator) && getter.GetParameters().Length == 0)
return getter.Invoke(obj, null) as Animator;

return null;
}

MethodInfo animatorGetterMethodInfo = ReflectionUtility.GetMethod(target, animatorName);
if (animatorGetterMethodInfo != null &&
animatorGetterMethodInfo.ReturnType == typeof(Animator) &&
animatorGetterMethodInfo.GetParameters().Length == 0)
var animator = ResolveAnimator(target, animatorName);
if (animator == null) return null;

var rac = animator.runtimeAnimatorController;
// Handle both regular controllers and override controllers
if (rac is AnimatorController ac)
return ac;

if (rac is AnimatorOverrideController aoc)
{
Animator animator = animatorGetterMethodInfo.Invoke(target, null) as Animator;
if (animator != null)
{
AnimatorController animatorController = animator.runtimeAnimatorController as AnimatorController;
return animatorController;
}
// The base controller holds the parameters
var baseCtrl = aoc.runtimeAnimatorController as AnimatorController;
return baseCtrl;
}

return null;
Expand Down