Search Issue Tracker

Won't Fix

Votes

1

Found in [Package]

1.1.10

Issue ID

ADDR-1293

Regression

No

[Addressables] Overriding Animation Controller fails when used on a Prefab which was instantiated from an Asset Bundle

Package: Build Pipeline - Addressables

-

How to reproduce:
1. Open the attached project
2. Open the repro scene ("MechArmsScene")
3. Build Player Content (using "Existing Build" mode)
4. Enter Play Mode
5. Press keyboard key "1" to load and override the animation
6. Press keyboard key "2" to start the animations

Expected results: The animations are overridden and played successfully
Actual results: The override fails and animations are reset to empty fields

Reproducible with: 2018.4.15f1, 2019.2.17f1, 2019.3.0f4, 2020.1.0a18
Reproducible with package version 1.1.10, 1.5.0

  1. Resolution Note:

    the customer note about equal clips not being recognized as equal is correct. The issue is that the engine code that tracks animation overrides uses actual equality, but in this case, there are two identical animations built into the build. So even though the source asset was the same, the resulting asset is not. The workaround is to change the user code in AnimationClipOverrides.cs

    adding this new method:
    private AnimationClip GetMatchingClip(AnimationClip clip)
    {
    foreach (var clipPair in Controller.clips)
    {
    if (clipPair.originalClip.name == clip.name)
    return clipPair.originalClip;
    }

    return clip;
    }

    provides a way to take a passed in clip, and find the clip on the current object that has a matching name. Then the [] operator in that same file becomes:

    public AnimationClip this[AnimationClip clipKey]
    {
    get
    {
    AnimationClip val;
    var clip = GetMatchingClip(clipKey);
    _overridden.TryGetValue(clip, out val);
    return val;
    }
    set
    {
    if (clipKey == null) {
    Debug.LogError($"Trying to assign clip {value?.name} to null key.", Controller);
    return;
    }

    var clip = GetMatchingClip(clipKey);
    if (value == null) {
    _overridden.Remove(clip);
    } else {
    _overridden[clip] = value;
    }
    }
    }

    With these changes, the game works.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.