• RuntimesUnity
  • No Skins in UnityUI Skeleton graphic.

Hello,

I faced the problem with unity UI skeleton graphic - there is no skins somehow. At SkeletonGraphic all looks fine. In ui case if I try set skins through code - I've get nullref exception when try find skin by name. How I can fix that?

Thanks!


    Related Discussions
    ...

    As far as i can see we have single atlas

    dreding In ui case if I try set skins through code - I've get nullref exception when try find skin by name. How I can fix that?

    How are you trying to set the skin through code? I can see only screenshots of Inspector settings but the relevant code that's failing is missing.

      Harald

      `
      [SerializeField] private SkeletonGraphic skeletonAnimation;
      private void SetupSkin(IEnumerable<string> _skins, WorkerTools _tool)
      {
      var skeleton = skeletonAnimation.Skeleton;
      var skeletonData = skeleton.Data;
      var animName = _tool.ToolToAnimation(Directions.None);

              fullSkin = new Skin("FullSkin");
              
              foreach (var skin in _skins)
              {
                  fullSkin.AddSkin(skeletonData.FindSkin(skin));
              }
              
              skeleton.SetSkin(fullSkin);
              skeleton.SetSlotsToSetupPose();
              skeletonAnimation.startingAnimation = animName;
          }

      `

      @dreding Note that you can format a multi-line block of code via three '`' characters:

      ```
      your
      code
      ```

      In general there is nothing obviously wrong with your code.
      Did you debug your code where exactly it goes wrong, at which line of code and with what value?

        Harald

        skeletonData.FindSkin(skin) returns null. Same code with same strings (skin names) works fine for SkeletonAnimation, but not for UI version

        @dreding Then there is perhaps something wrong with your logic, getting the wrong SkeletonData or something like that (having the wrong GameObject assigned at skeletonAnimation). SkeletonAnimation.Skeleton and SkeletonGraphic.Skeleton access the same skeleton object which is generated equally for any skeleton renderer. Same applies for Skeleton.SkeletonData. If you are sure that everything is named as it should, you can send us a minimal Unity project which reproduces this issue. You can sent it as a zip package to contact@esotericsoftware.com, briefly mentioning this forum thread so that we know the context. Then we can have a look at it.

          Harald As you can see in my origin post on screenshots that I've attached - there is same SkeletonData Asset, but even in unity editor in SkeletonAnimation in Skin Dropdown there a lot of things and in UI version this dropdown is empty

            dreding I am afraid that even if we can confirm that the names of the skeleton data assets set in the Inspector window match, the skeleton data assets refer to other files to manage the skeleton information, so it is not possible to determine whether your skeleton data is correct or not. Please send us a minimal Unity project that reproduces this problem as described by Harald.

            dreding As you can see in my origin post on screenshots that I've attached - there is same SkeletonData Asset, but even in unity editor in SkeletonAnimation in Skin Dropdown there a lot of things and in UI version this dropdown is empty

            Are you sure that both components are referencing the same SkeletonDataAsset, did you check with the Project panel? If so, please send us a minimal Unity project as mentioned above.