using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UGUI_AutoBindBoxCollder : MonoBehaviour {
// Use this for initialization
void Start () {
//Vector2 size = GetComponent<RectTransform>().sizeDelta;
BoxCollider collider = gameObject.AddComponent<BoxCollider>();
collider.size = new Vector3(GetComponent<RectTransform>().rect.width,GetComponent<RectTransform>().rect.height,1);
collider.isTrigger = true;
}
// Update is called once per frame
void Update () {
}
}
UGUI自动生成bottom的BoxCollider组件,符合Bottom大小的(代码已解决锚点不同的问题)
于 2024-07-13 15:43:44 首次发布