You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.8 KiB
53 lines
1.8 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
/// <summary> |
|
/// 测试 |
|
/// </summary> |
|
public class textcollider : MonoBehaviour { |
|
|
|
Canvas canvas; |
|
private void Start() |
|
{ |
|
canvas = GameObject.Find("Canvas").GetComponent<Canvas>(); |
|
|
|
} |
|
|
|
|
|
private void Update() |
|
{ |
|
transform.LookAt(Camera.main.transform); |
|
transform.localEulerAngles = new Vector3(-transform.localEulerAngles.x,-180+transform.localEulerAngles.y,transform.localEulerAngles.z); |
|
if (Input.GetMouseButtonDown(1)&&MySceneManager.GetActiveScene().name=="5") |
|
{ |
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); |
|
RaycastHit hitinfo; |
|
if (Physics.Raycast(ray,out hitinfo,100,LayerMask.GetMask("UI"))) |
|
{ |
|
|
|
if (hitinfo.collider.name.Equals("text")) |
|
{ |
|
UI_FourFireController[] uiArray = canvas.GetComponentsInChildren<UI_FourFireController>(); |
|
if (uiArray.Length != 0) |
|
{ |
|
foreach (var item in uiArray) |
|
{ |
|
Destroy(item.gameObject); |
|
} |
|
} |
|
GameObject obj = Resources.Load("UIPrefab/UI_FourFireController") as GameObject; |
|
obj= Instantiate(obj, canvas.transform); |
|
Vector2 pos; |
|
RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.GetComponent<RectTransform>(), Input.mousePosition, canvas.worldCamera, out pos); |
|
obj.GetComponent<RectTransform>().localPosition = pos; |
|
obj.GetComponent<UI_FourFireController>().SetParticle(hitinfo.transform.parent.gameObject); |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
}
|
|
|