Hi, I'm tryiing to expose a reference to an animation in an object that hasn't SkeletonAnimation script attached to it.
In Editor, it says: ERROR: Must have a reference to a skeleton data asset.
If I add a SkeletonAnimation script to the same game object everything is fine. Any workaround?
Error in Unity Editor
To resolve the error you're encountering in Unity, you need to ensure that the object you're working with has a reference to a SkeletonDataAsset
. The error message indicates that the object requires this reference to function correctly. When you add a SkeletonAnimation
script, it automatically handles this requirement by linking to the necessary SkeletonDataAsset
. If you want to expose a reference to an animation without attaching a SkeletonAnimation
script, you must manually ensure that the SkeletonDataAsset
is correctly referenced in your script or setup.
One workaround is to create a separate script that manages the SkeletonDataAsset
reference and links it to the animation you want to expose. This script can be attached to the same GameObject or another relevant object in your scene. Ensure that the SkeletonDataAsset
is correctly assigned in the Inspector to avoid runtime errors.
Misaki Sure. I have an object. This object has several child object that act as "interaction point" which the player can interact with. These interaction points have their own collider and rigidbody and must handle a subset of animations.
To separate script responabilities and to avoid huge scripts, I want to have the root object that acts as Manager, or a central brain, and its children that manage privately their stuff.
The image attached to my first post is the inspector of a child object. When I try to reference a spine animation, that error occours. SkeletonAnimation component is attached to the root object.
Found the solution: