public void RegisterCallBack(LuaTable t, string luaFactionName, GameObject go, EventTriggerType eventType)
    {
        if (luaFactionName == "")
        {
            return;
        }
        LuaFunction luaFunction = t.GetLuaFunction(luaFactionName);

        if (luaFunction == null)
        {
            Debug.LogError("RegisterCallBack is error " + luaFactionName);
            return;
        }

        var eventCom = go.GetComponent <EventTrigger>();

        if (eventCom == null)
        {
            eventCom = go.AddComponent <EventTrigger>();
        }
        EventTrigger.Entry entry = new EventTrigger.Entry();
        entry.eventID = eventType;
        UnityAction <BaseEventData> unityAction = (BaseEventData sender) => {
            luaFunction.Call(t, sender);
        };

        entry.callback.AddListener(unityAction);
        eventCom.triggers.Add(entry);
    }
Ejemplo n.º 2
0
        public override void OnGraphStarted(ExecutionContext g)
        {
            var trigger = g.GameObject.EnsureComponent <EvtTrigger>();

            var init = new Action <EventTriggerType>((eventId) =>
            {
                var entry     = new EvtTrigger.Entry();
                entry.eventID = eventId;
                var evt       = new EvtTrigger.TriggerEvent();
                evt.AddListener((data) =>
                {
                    GetFlowOutput(eventId.ToString()).Execute(g);
                });
                entry.callback = evt;
                trigger.triggers.Add(entry);
                if (entries == null)
                {
                    entries = new List <EvtTrigger.Entry>();
                }
                entries.Add(entry);
            });

            foreach (EventTriggerType eventId in EventIds)
            {
                init(eventId);
            }

            base.OnGraphStarted(g);
        }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        elements_object = transform.Find("Elements");

        for (int i = 0; i < transform.Find("Elements").childCount; i++)
        {
            //Debug.Log(gameObject.transform.Find("Elements").GetChild(i).name);
            EventTrigger       trigger = gameObject.transform.Find("Elements").GetChild(i).GetChild(0).GetComponent <EventTrigger>();
            EventTrigger.Entry entry   = new EventTrigger.Entry();
            entry.eventID = EventTriggerType.PointerClick;
            entry.callback.AddListener((data) => { PressButtons((PointerEventData)data); });
            trigger.triggers.Add(entry);
        }
    }