Cute_demon_attacks/meng_yao/Assets/script/A_Fight/BlackHole.cs

33 lines
1.0 KiB
C#
Raw Normal View History

2024-12-12 17:05:28 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BlackHole : MonoBehaviour
{
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>")] public GameObject panelPrefab;
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>")] public GameObject parenttransform;
private void OnMouseDown()
{
// ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD> Trigger <20><><EFBFBD><EFBFBD>
Collider2D parentCollider = GetComponent<Collider2D>();
if (parentCollider != null && parentCollider.isTrigger)
{
// <20><><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD><C7B8>ڵ<EFBFBD>
Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
RaycastHit2D hit = Physics2D.Raycast(mousePosition, Vector2.zero);
if (hit.collider != null && hit.collider.gameObject == gameObject)
{
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>˸<EFBFBD><CBB8>ڵ<EFBFBD>");
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
GameObject obj =GameObject.Instantiate(panelPrefab, GameObject.Find("Canvas").transform);
}
}
}
}