Cannot access SpriteSkin component

Hello, I’m trying to access the SpriteSkin component in order to change the sprite name with the assigned bone’s name, but I noticed I cannot access anything from the SpriteSkin component.

Here is the code I am trying to run:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.U2D.Animation;

public class BonesUtilityEditor : EditorWindow
{
    [MenuItem("Bones Utility/Rename Sprite")]
    static void RenameSprite()
    {
        GameObject go = (Selection.activeObject as GameObject);
       
        foreach (SpriteSkin sprite in go.GetComponentsInChildren<SpriteSkin>())
        {
            //Cannot access SpriteSkin
        }
    }
}

Is this how it’s supposed to be? How can I access which bone a sprite is attached to?

Thank you for your time.

It doesnt appear that you are declaring the SpriteSkin class as a variable and then assigning it in Start or Awake. You are trying to access components in a Class from a different Class.

Well it is a component on the GameObject referenced in the script above and I am trying to access its own SpriteSkin component. I don’t get what I’m doing wrong.

Even if it is a component on the same gameobject as the script, you will have to reference it. Just like when you use an object’s Rigidbody2D, you have to declare it as a variable, assign it in start, and then you can access the properties of that component. Same thing for the Animator component, SpriteRender, etc.

I am referencing it in the foreach loop itself though.
Here, an example where I create a variable of type SpriteSkin but the issue persists, along another example with a component that works as intended.

5138423--508559--upload_2019-11-4_22-48-40.png

So that error refers to it being a private or protected class so you cannot reference it in other scripts. Make it public.

Man, the whole point of the thread is that I cannot do that :smile:. It’s Unity’s own library UnityEngine.U2D.Animation.
5141036--508934--upload_2019-11-5_16-17-44.png

Ahh, that makes sense. No idea then, sorry to waste your time. Here is a good post on working with different aspects of that library. Its all i got now.

No worries, was just a misunderstanding. Sadly, I have already looked into that but nothing regarding this.
I feel like it’s mostly a matter of waiting for Unity to realize this and change the library protection level. I could really use accessing it, would speed things up a ton!