Search Unity

[Unity-Spine] Why is the Spine SkeletonAnimation instantiated so small?

Discussion in '2D' started by Eriic520, Aug 9, 2019.

  1. Eriic520

    Eriic520

    Joined:
    Oct 23, 2017
    Posts:
    1
    Hi everyone, I’m a beginner of Unity 2D scripting, and I just learned something about 'Intantiate'. So just for fun, I was trying to instantiate a prefabed spine animation in a scene, while I met some problems with it. Is there anything that I did wrong?

    My situation:
    1. I have a prefabed spine skeleton animation;
    2. I have a canvas in the scene containing a UI button to instantiate a new prefab of this animation when pressed.

    My problems:
    1. After instantiating the animation, it was too small to see. I had to resize it to 100 times to see it. And I was pretty sure it’s not instantiated as the child of the UI Canvas, so its transform wasn’t the RectTransform;
    2. I could only see it in the Scene window while I saw nothing in the Game window.

    My code is here:
    Code (CSharp):
    1. public class CreatureGenerator : MonoBehaviour
    2. {
    3.     Vector3 generatePos;
    4.  
    5.     [SerializeField] GameObject creaturePrefab;
    6.  
    7.     void Start()
    8.     {
    9.         generatePos = new Vector3(Screen.width / 2f, Screen.height / 2f, 0f);
    10.     }
    11.  
    12.     public void GenerateCreature()
    13.     {
    14.         GameObject creature = Instantiate(creaturePrefab, generatePos, transform.rotation);
    15.     }
    16. }
    Thanks so much in advance.
     
    GMofOLC likes this.