- Изменено
Duplicating and configuring slots at runtime. Possible?
Hi there,
I've searched this to no avail. Sorry if it's been already taken care of.
Part of my workflow implies duplicating "main" slots in the Editor (saying "yes" to the "copy animation keys?" dialog), setting them up to Additive or Multiply, and changing the default color of all of them.
For example, I take these...:
...and clone them to get these...:
I do this every time I change a mesh in the Editor, because I always forget to change the duplicated meshes as well. :rolleyes:
I started doing this when I realized how good the tinting was by overlapping the same mesh in normal and additive. But this process of needing to duplicate everything every time I change a vertex... it's a bit annoying.
So, I was asking myself if there isn't a way to do that inside Unity, via the runtimes, when the SkeletonAnimation is being instanced, for example (?).
I know attachments can be manipulated and all but... can slots be setup like this as well?
Thank you.
If you want to change the blend mode, unfortunately you can't set this per Skeleton instance since it's a property of the shared SlotData and not of an instance Slot. You theoretically could modify the SlotData, but this is obviously not recommended since it would affect all Skeleton instances if there are more than one.
So it would be required to modify the SkeletonData accordingly, to add the adjusted Slot copies programmatically in Unity instead of via the Spine Editor. However this is not trivial, as you would need to traverse the SkeletonData structures yourself, add entries and make sure everything is hooked up properly. I'm not sure that you really want to go down that road.
Regarding how to call such a method:
You could modify the SkeletonData e.g. via a AssetPostprocessor hook
, where you call your custom import post-processing method, after e.g. a SkeletonDataAsset
has been created. You could alternatively create your own custom Editor window that provides a small UI with an asset property and a Process
button.