rxmarcus

In our game, players can create custom heroes and save them to disk. We show the player skeleton in many places in our game so I am working on writing a few methods that will accept a SkeletonAnimation and set it up according to the players chosen hero customizations.

The issue I'm running into is that I'd like to write a single method that can accept both a SkeletonAnimation and a SkeletonGraphic, otherwise I'm going to have to have duplicate code for each of these types.... And it appears that SkeletonAniamtion and SkeletonGraphic don't inherit from a shared base class???

for example:
public void CustomizeSkeletonByHero(ref SkeletonAnimation skeleton, TNet.DataNode customizationProfile)
{
// Customize my SkeletonAnimation here
}

public void CustomizeSkeletonByHero(ref SkeletonGraphic skeleton, TNet.DataNode customizationProfile)
{
// Customize my SkeletonGraphic here.... again
}
Any tips or ideas of how I can write code that accepts both of these types?
rxmarcus
Posts: 66

Pharan

They don't, mostly because SkeletonGraphic had to inherit from UnityEngine.UI.MaskableGraphic in order to work with various Unity UI features.

They share a number of interfaces so which one you want depends on what you plan to do with it.
IHasSkeletonDataAsset gives you the SkeletonDataAsset property.
ISkeletonComponent gives you the SkeletonDataAsset property and the Skeleton property.
IAnimationStateComponent gives you the AnimationState property.
User avatar
Pharan

Pharan
Posts: 5284

rxmarcus

Thanks Pharan,
I'll see if I can make some progress using those interfaces!
rxmarcus
Posts: 66


Return to Unity