按住,松开按钮调用不同的方法

xiaoxiao2025-08-31  9

需求模拟激光枪

按下一直会生成特效,松开时特效消失

using UnityEngine; using UnityEngine.EventSystems;

public class buttonEvent : MonoBehaviour,IPointerDownHandler,IPointerUpHandler {

 public GameObject texiao;

public void OnPointerDown(PointerEventData eventData)///按下按钮时执行的一个方法     {         texiao.GetComponent<fire>().go.SetActive(true);

    }     public void OnPointerUp(PointerEventData eventData)///松开按钮时执行方法     {         texiao.GetComponent<fire>().go.SetActive(false);     }

 

}

 

转载请注明原文地址: https://www.6miu.com/read-5035526.html

最新回复(0)