![](/cache/com_z2/CM_498eca7fa66cfccb671e570b1a36abbd_2021100201_01.jpg)
最近正好遇到這問題
例如我有日曆功能
但是日曆上的按鈕是動態產生
按下日曆要能夠帶出當下日期的紀錄
我找一找還真有辦法
4.6 How to get name of button that was clicked?
可以用:
EventSystem.current.currentSelectedGameObject.name
例如我將按鈕設定成都會執行同一個事件
ShowDaysWorkoutRecords
在 ShowDaysWorkoutRecords 裡面寫:
using UnityEngine.EventSystems; public void ShowDaysWorkoutRecords() { string DayObjectName = EventSystem.current.currentSelectedGameObject.name; }
也就是只要名稱不一樣就可以再用名稱取得該物件囉~
給大家參考囉![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/0fa3.gif)
![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/0fa3.gif)
留言板
歡迎留下建議與分享!希望一起交流!感恩!