예제 #1
0
    public void Show(string title, string contentName, string content, float w, float h,
                     EventListener.VoidDelegate submitEvent = null,
                     EventListener.VoidDelegate cancelEvent = null,
                     params object[] pars)
    {
        Field.gameObject.SetActive(false);
        LbMsg.gameObject.SetActive(true);
        base.ExcuteInit();

        SubmitEvent    = submitEvent;
        CancelEvent    = cancelEvent;
        PageTitle.text = title;
        EventListener.Get(this.gameObject).onClick = Close;

        this.gameObject.SetActive(true);
        BoxContent.GetComponent <RectTransform>().sizeDelta = new Vector2(w, h);

        if (!string.IsNullOrEmpty(content))
        {
            LbMsg.text = content;
            LbMsg.gameObject.transform.parent.gameObject.SetActive(true);
        }
        else
        {
            LbMsg.gameObject.transform.parent.gameObject.SetActive(false);
        }

        if (!string.IsNullOrEmpty(contentName))
        {
            Transform item = SignalObjectManager.Instance.Spawn(contentName);
            item.parent = Content.transform;
            ContentPage = item.GetComponent <DialogPage>();
            if (pars != null)
            {
                for (int i = 0; i < pars.Length; i++)
                {
                    ContentPage.SetPar(i, pars[i]);
                }
            }
            ContentPage.ExcuteInit();
        }

        if (submitEvent != null)
        {
            EventListener.Get(BtnSubmit.gameObject).onClick = OnSubmit;
        }
        else
        {
            BtnSubmit.gameObject.SetActive(false);
        }
        if (cancelEvent != null)
        {
            EventListener.Get(BtnCancel.gameObject).onClick = OnCancel;
        }
        else
        {
            BtnCancel.gameObject.SetActive(false);
        }
    }
예제 #2
0
    public void ShowImportBox(string title, float w, float h,
                              EventListener.VoidDelegate submitEvent = null,
                              EventListener.VoidDelegate cancelEvent = null,
                              params object[] pars)
    {
        Show(title, "", "", w, h, submitEvent, cancelEvent);

        LbMsg.gameObject.transform.parent.gameObject.SetActive(true);
        Field.gameObject.SetActive(true);
        LbMsg.gameObject.SetActive(false);
    }
예제 #3
0
    public void AddButton(string text, Sprite img = null, EventListener.VoidDelegate btnEvent = null)
    {
        GameObject newBtn = GameObject.Instantiate <GameObject>(BtnTemplated.gameObject);

        newBtn.SetActive(true);
        if (img != null)
        {
            newBtn.GetComponent <Image>().sprite = img;
        }
        else
        {
            newBtn.GetComponent <Image>().enabled = false;
        }
        if (!string.IsNullOrEmpty(text))
        {
            newBtn.GetComponentInChildren <Text>().text  = text;
            newBtn.GetComponentInChildren <Text>().color = ColorFont;
        }
        newBtn.GetComponent <RectTransform>().SetParent(TitleRight.transform);
        newBtn.GetComponent <RectTransform>().localScale         = new Vector3(1, 1, 1);
        newBtn.GetComponent <RectTransform>().anchoredPosition3D = Vector3.zero;
        EventListener.Get(newBtn).onClick = btnEvent;
    }
        static internal int checkDelegate(IntPtr l, int p, out EventListener.VoidDelegate ua)
        {
            int op = extractFunction(l, p);

            if (LuaDLL.lua_isnil(l, p))
            {
                ua = null;
                return(op);
            }
            else if (LuaDLL.lua_isuserdata(l, p) == 1)
            {
                ua = (EventListener.VoidDelegate)checkObj(l, p);
                return(op);
            }
            LuaDelegate ld;

            checkType(l, -1, out ld);
            if (ld.d != null)
            {
                ua = (EventListener.VoidDelegate)ld.d;
                return(op);
            }
            LuaDLL.lua_pop(l, 1);

            l  = LuaState.get(l).L;
            ua = (UnityEngine.GameObject a1) =>
            {
                int error = pushTry(l);

                pushValue(l, a1);
                ld.pcall(1, error);
                LuaDLL.lua_settop(l, error - 1);
            };
            ld.d = ua;
            return(op);
        }
예제 #5
0
 public void SetClick(EventListener.VoidDelegate <object> callbackWithParam, object param)
 {
     this.onClick         = null;
     this.onClickWithPara = callbackWithParam;
     this.paraRef         = param;
 }
예제 #6
0
 public void Init(string title, Color colorBg, Color colorFont, EventListener.VoidDelegate backEvent = null, EventListener.VoidDelegate menuEvent = null)
 {
     base.ExcuteInit();
     for (int i = 0; i < TitleRight.transform.childCount; i++)
     {
         if (TitleRight.transform.GetChild(i).gameObject != BtnTemplated.gameObject)
         {
             GameObject.Destroy(TitleRight.transform.GetChild(i).gameObject);
         }
     }
     ColorFont = colorFont;
     this.GetComponent <Image>().color = colorBg;
     LbTitle.color = colorFont;
     LbTitle.text  = title;
     if (backEvent != null)
     {
         BtnBack.gameObject.SetActive(true);
         EventListener.Get(BtnBack.gameObject).onClick = backEvent;
     }
     else
     {
         BtnBack.gameObject.SetActive(false);
     }
     if (menuEvent != null)
     {
         BtnMenu.gameObject.SetActive(true);
         EventListener.Get(BtnMenu.gameObject).onClick = menuEvent;
     }
     else
     {
         BtnMenu.gameObject.SetActive(false);
     }
 }