Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null Exception - MixerTransition has destroyed clip #342

Open
wrymn opened this issue May 3, 2024 · 1 comment
Open

Null Exception - MixerTransition has destroyed clip #342

wrymn opened this issue May 3, 2024 · 1 comment
Labels
Bug Something isn't working Solved A solution is available here (but may not yet be included in the latest release)

Comments

@wrymn
Copy link

wrymn commented May 3, 2024

When I have defined LinearMixerTransition field, add new clips, assign a clip, and then I delete one of those clip assets from project, the asset (in my case scriptable object with LinearMixerTransition field) is broken after selection and inspector for it will no longer work, thus, I cannot even change the destroyed clip or remove it.

Please note, this appears to be issue only when using Odin Inspector, so not sure if it will be possible to still fix this, event though odin is not part of animancer package, it would be nice if we could support it and avoid this issue :)

image
image

@wrymn wrymn added the Bug Something isn't working label May 3, 2024
@KybernetikGames
Copy link
Owner

KybernetikGames commented May 3, 2024

Replace the TryGetLength method in ITransitionDetailed.cs with this:

public static bool TryGetLength(object motionOrTransition, out float length)
{
    if (motionOrTransition is AnimationClip clip)
    {
        if (clip != null)
        {
            length = clip.length;
            return true;
        }
    }
    else if (TryGetWrappedObject(motionOrTransition, out ITransitionDetailed transition))
    {
        length = transition.MaximumDuration;
        return true;
    }

    length = 0;
    return false;
}

That first if would still pass if the object is an AnimationClip which has already been destroyed so we need to add an explicit null check to make sure it isn't destroyed.

Same for TryGetIsLooping above it:

public static bool TryGetIsLooping(object motionOrTransition, out bool isLooping)
{
    if (motionOrTransition is Motion motion)
    {
        if (motion != null)
        {
            isLooping = motion.isLooping;
            return true;
        }
    }
    else if (TryGetWrappedObject(motionOrTransition, out ITransitionDetailed transition))
    {
        isLooping = transition.IsLooping;
        return true;
    }

    isLooping = false;
    return false;
}

@KybernetikGames KybernetikGames added the Solved A solution is available here (but may not yet be included in the latest release) label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Solved A solution is available here (but may not yet be included in the latest release)
Projects
None yet
Development

No branches or pull requests

2 participants