如果你想手动设置每个骨架的材质覆盖,你可以避免使用 SkeletonAnimationMulti
示例组件。 您可以创建在编辑模式下创建子 SkeletonAnimation
实例的组件(或 SkeletonAnimationMulti
的子类)。 您可以在新组件的顶部添加 [ExecuteAlways]
以确保它在编辑器中被调用,然后在实例化骨架之前检查它们是否已经存在。
最简单的解决方案可能是手动创建子 SkeletonAnimation
实例,并让替换 SkeletonAnimationMulti
的组件仅在活动实例之间切换。
无论如何,拥有一个统一的命名方案是一个非常好的主意,通过代码以统一的方式应用材质覆盖是有意义的。 这取决于您的个人喜好和您的用例。
If you want to manually setup each skeleton's material overrides, you could just avoid using the SkeletonAnimationMulti
example component. You could create your component (or a subclass of SkeletonAnimationMulti
) that creates the child SkeletonAnimation
instances in edit mode. You would add [ExecuteAlways]
at the top of your new component to ensure it's called in the Editor, and then before instantiating the skeletons check if they already exist.
The simplest solution would perhaps be to just manually create the child SkeletonAnimation
instances and let your component that replaces SkeletonAnimationMulti
only switch between the active ones.
Anyway, having a unified naming scheme is a very good idea, applying material overrides via code in a unified way makes sense. It depends on your personal preferences and on your use-case.