Beispiel #1
0
        public static void AddEventTrigger(GameObject go, EventTriggerType eventTriggerType, LuaFunction luaFunc, LuaRef self)
        {
            if (go == null || luaFunc == null)
            {
                return;
            }

            CacheLuaFunction(go, luaFunc);

            UnityAction <BaseEventData> click = (data) =>
            {
                luaFunc.Call(self, go, data);
            };

            EventTrigger.Entry eventTrigger = new EventTrigger.Entry();
            eventTrigger.eventID = eventTriggerType;
            eventTrigger.callback.AddListener(click);

            EventTrigger trigger = go.GetComponent <EventTrigger>();

            if (trigger == null)
            {
                trigger = go.AddComponent <EventTrigger>();
            }

            for (int i = 0; i < trigger.triggers.Count; ++i)
            {
                if (trigger.triggers[i].eventID == eventTriggerType)
                {
                    return;
                }
            }

            trigger.triggers.Add(eventTrigger);
        }
Beispiel #2
0
 public static void ScrollRectListener(ScrollRect sr, LuaFunction func, LuaRef self)
 {
     CacheLuaFunction(sr, func);
     sr.onValueChanged.AddListener((vc2) =>
     {
         func.Call(self, vc2);
     });
 }
Beispiel #3
0
 public static void InputFieldEndEdit(InputField inputfield, LuaFunction func, LuaRef self)
 {
     CacheLuaFunction(inputfield, func);
     inputfield.onEndEdit.RemoveAllListeners();
     inputfield.onEndEdit.AddListener((val) =>
     {
         func.Call(self, val);
     });
 }
Beispiel #4
0
 public static void ScrollbarListener(Scrollbar scrollbar, LuaFunction func, LuaRef self)
 {
     CacheLuaFunction(scrollbar, func);
     scrollbar.onValueChanged.RemoveAllListeners();
     scrollbar.onValueChanged.AddListener((val) =>
     {
         func.Call(self, val);
     });
 }
Beispiel #5
0
 public static void ToggleListener(Toggle toggle, LuaFunction func, LuaRef self)
 {
     CacheLuaFunction(toggle, func);
     toggle.onValueChanged.RemoveAllListeners();
     toggle.onValueChanged.AddListener((val) =>
     {
         func.Call(self, val);
     });
 }
Beispiel #6
0
 public static void DropdownListener(Dropdown dropdown, LuaFunction func, LuaRef self)
 {
     CacheLuaFunction(dropdown, func);
     dropdown.onValueChanged.RemoveAllListeners();
     dropdown.onValueChanged.AddListener((val) =>
     {
         func.Call(self, val);
     });
 }
Beispiel #7
0
 public static void ButtonListener(Button btn, LuaFunction luaFunc, LuaRef self)
 {
     CacheLuaFunction(btn, luaFunc);
     btn.onClick.AddListener(() => luaFunc.Call(self));
 }
Beispiel #8
0
 public static void AddClick(GameObject go, LuaFunction luaFunc, LuaRef self)
 {
     CacheLuaFunction(go, luaFunc);
     go.GetComponent <Button>().onClick.AddListener(() => luaFunc.Call(self, go));
 }