using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class GenerateSkeletonScript : MonoBehaviour {

    [SerializeField] GameObject skeletonPrefab;

    void Start() {
        Button button = GetComponentInChildren<Button>();
        button.onClick.AddListener(SpawnSkeleton);
    }

    private void SpawnSkeleton() {
        GameObject generatedSkelleton = GameObject.Instantiate(skeletonPrefab, new Vector3(), Quaternion.identity);

        Vector3 mousePos = Camera.main.ScreenToViewportPoint(Input.mousePosition);
        mousePos.z = Camera.main.transform.position.z + Camera.main.nearClipPlane;
        generatedSkelleton.transform.position = mousePos;

        generatedSkelleton.GetComponent<NewSkeletonSpriteScript>().IsDragged(true);
    }
}
