- 已编辑
How to realize skeletonanimation interaction?
- 已编辑
I have an animation with 10 actions. In Unity Engine, when I place a skeleton animation, for a skeleton animation of the same source image, when I copy the skeleton animation, it will automatically detect other skeleton animations in the same scene (different skeleton animations of the same source image).
For example, I have a skeletal animation (this source image contains 10 actions, I only need to duplicate this skeletal animation 10 times, each skeletal animation will detect animations on other skeletal animations with the same source image in the same scene to achieve each The bones will automatically play one of the 10 actions of the effect.
{If you don't understand what I mean, I can give a similar example to help you understand. For example: In the Unity Engine user interface, I created 10 buttons and set 10 numbers in the background, such as 1-10. When I click "Play", each time the text of each button is automatically assigned to 1-10, and the button text will judge each other, so the numbers on the 10 button texts are different. But the text numbers of these ten buttons include all 1-10, there are no buttons with repeated digital text. You can replace the button in this example with a skeletal animation, and the action in my animation is the "text" in this example, but I do n’t know how many actions are in the animation beforehand)
How do I achieve this? Please leave examples.
This is the result of my manual setup, and I need to copy skeleton animation to achieve this without any setting of skeleton animation.
Please leave examples.
The above are outdated
//
I have three files
akhee.atlas
akhee.json
akhee.png
I imported them into Unity.
I created a "skeletal animation" in Unity and then selected an image in the SkeletonData asset of the inspector. Then, in the inspector, there is an "animation name" property, and I can select it. I click on the "Animation Name" property and the "Animation Name" property pops up a menu with 10 options on the menu, which means it has 10 "Animation Name"?
Then, my requirement was that I wanted to duplicate the "skeletal animation" UI ten times in the Unity scene. I want to write a script to bind these ten "skeletal animations". When I click Unity's play button, these ten identical "skeletal animations" play different "animation names". And there is no duplication.
1329343592 :I have an animation with 10 actions.
By that you mean that you have one skeleton with 10 animations, or did I misunderstand that?
I'm afraid I don't understand the following paragraph, I assume some automatic translations were not going too well here:
1329343592 :In Unity Engine, when I place a skeleton animation, for a skeleton animation of the same source image, when I copy the skeleton animation, it will automatically detect other skeleton animations in the same scene (different skeleton animations of the same source image).
By source image
, do you mean source skeleton data file
(the .json file)?
Could you please explain what you are trying to achieve in different words? Please also add the text in your native language, so that we can have a try re-translating it to English.
1329343592 :How do I achieve this?
From the video and the text I would assume you want to do the following:
- You have a skeleton and want to automatically create a scene with one SkeletonAnimation instance per animation
- When the skeleton asset is updated (e.g. because you re-exported the skeleton with additional animations), you want the scene to be updated as well to reflect this.
If that is what you are trying to achieve, this is a general Unity editor scripting task.
You could create a custom editor window with input properties like the SkeletonDataAsset
to be instantiated, the number of rows and columns of your grid of animation GameObjects and an 'Instantiate' button.
This Instantiate button would then populate the scene by instantiating the skeleton once for every animation. I posted an answer about how you can iterate over all animations as a reply to your question in the other thread. Please have a look at the Spine Examples/Other Examples/Instantiate from Script
example scene that comes with the spine-unity unitypackage on how to instantiate skeletons from scripts.
1329343592 :and the action in my animation is the "text" in this example, but I do n’t know how many actions are in the animation beforehand
Please note that action
is not part of Spine terminology. Please use animation
instead. Instead of your usage of animation
, what I think you actually mean is called skeleton
in Spine terminology (the whole character with its 10 animations).
Regarding the question on how to update the instances when the assets change (when I wrote this, the posting was at the bottom but later it seems to have been moved up into the first posting as an edit):
I would suggest to simple delete all instances from the scene and re-create them properly.
Since you updated the original posting again with a new paragraph added - please do not edit postings and add new text if there was already a reply posted below it. Instead post a new reply with new questions below, otherwise the order of messages gets messed up completely.
Regarding the additional questions:
These should already be answered by my previous posting above.