Closed kodra-dev closed 3 months ago
Are you doing something that causes Animancer to initialize on objects which are inactive and never get activated? That's the only thing I know of that could prevent Unity from calling AnimancerComponent.OnDestroy
where the graph is supposed to be destroyed.
Are you doing something that causes Animancer to initialize on objects which are inactive and never get activated? That's the only thing I know of that could prevent Unity from calling
AnimancerComponent.OnDestroy
where the graph is supposed to be destroyed.
I don't think so. I only use AnimancerComponent on objects that are actually animated. Unless "causes Animancer to initialize" isn't just AnimancerComponent?
Line 347 of AnimancerPlayable for me looks like this:
#if UNITY_EDITOR
var name = _NextGraphName;
_NextGraphName = null;
var graph = name != null ? // <- this is line 347
PlayableGraph.Create(name) :
PlayableGraph.Create();
#else
Which is... quite confusing to me. Why does the error happen on this line?
Should I put some debug print in AnimancerComponent.OnDestroy
to see if it's called?
Ah, I've found the problem. It's on my side. I (mistakenly) set _animancer.Layers
's name in editor mode for debugging reason, which seems to cause the PlayableGraph be to initialize.
That's the line where the graph is created and there obviously isn't a line where it's being destroyed since the error is about it not being destroyed, so that's the only useful line they could give you.
I'm thinking I'll add an OptionalWarning
if you initialize Animancer on an inactive object to help explain this issue. Can't just make it an error because there might be legitimate reasons why you want to do that such as to prepare a bunch of instances in an object pool.
Since I've been using Animancer as my main animation system, when I exit Play mode in the editor, it always spams this warning message:
Assets/ThirdParty/Animancer/Internal/Core/AnimancerPlayable.cs(347): PlayableGraph was not destroyed.
The game seems to work fine, but the more AnimancerComponent I have in the scene, the more it spams this message and it's getting quite annoying. Is this something to worry about? How to avoid it?
Unity version: 2022.3.24f1 Animancer version: 7.3