12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System;
- using UnityEngine.EventSystems;
- public class ChuanSongMen : MonoBehaviour
- {
- /// <summary>
- /// 门的类型
- /// </summary>
- public int doorType = 1;
- /// <summary>
- /// 出生时间
- /// </summary>
- public float liveTime = 2.0f;
- /// <summary>
- /// 点击回调
- /// </summary>
- public Action<int> clickAC = null;
- /// <summary>
- /// 进入碰撞器回调
- /// </summary>
- public Action<int, GameObject> enterAC = null;
- private bool bEnable = false;
- private void OnEnable()
- {
- Invoke("LateEnable", liveTime);
- }
- private void LateEnable()
- {
- bEnable = true;
- }
- private void OnMouseUpAsButton()
- {
- Debug.Log("点击触发器");
- if (bEnable == false)
- {
- return;
- }
- if (clickAC != null)
- {
- clickAC(doorType);
- }
- }
- private void OnTriggerEnter(Collider other)
- {
- Debug.Log("进入到触发器 " + other.name);
- if (bEnable == false)
- {
- return;
- }
- if (enterAC != null)
- {
- enterAC(doorType, other.gameObject);
- }
- }
- }
|