wuxianshengcong/Assets/Scripts/PointAnim.cs
2024-12-30 10:39:09 +08:00

40 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class PointAnim : MonoBehaviour
{
public Sprite point;
public GameObject mage;
public GameObject canvas;
// Start is called before the first frame update
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0) && EventSystem.current.IsPointerOverGameObject())
{
Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mousePosition.z = 0;
GameObject ImaGameObject = Instantiate(mage);
ImaGameObject.transform.SetParent(canvas.transform);
ImaGameObject.transform.position = mousePosition;
ImaGameObject.GetComponent<Image>().sprite=point;
ImaGameObject.transform.DOScale(new Vector3(0,0,0), 01f);
Destroy(ImaGameObject, 1f);
}
}
}