Ejemplo n.º 1
0
    /// <summary>
    /// 回收item到缓存中
    /// </summary>
    private void RecycleCacheItems()
    {
        Transform gridTrans = grid.transform;

        if (gridTrans.childCount <= 0)
        {
            return;
        }

        Queue <GameObject> cacheItems = null;

        if (!cacheItemDic.TryGetValue(itemPrefabPath, out cacheItems))
        {
            return;
        }

        for (int i = gridTrans.childCount - 1; i >= 0; i--)
        {
            Transform itemTrans = gridTrans.GetChild(i);
            if (cacheItems.Contains(itemTrans.gameObject))
            {
                continue;
            }

            MonoExtendUtil.AddChildToTarget(cacheItemRoot.transform, itemTrans);
            NGUITools.SetActive(itemTrans.gameObject, false);

            cacheItems.Enqueue(itemTrans.gameObject);
        }
        grid.ClearChildren();
    }
Ejemplo n.º 2
0
    static int AddChildToTarget(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <UnityEngine.Transform, UnityEngine.Transform>(L, 1))
            {
                UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.ToObject(L, 1);
                UnityEngine.Transform arg1 = (UnityEngine.Transform)ToLua.ToObject(L, 2);
                MonoExtendUtil.AddChildToTarget(arg0, arg1);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes <UnityEngine.Transform, UnityEngine.Transform, UnityEngine.Vector3>(L, 1))
            {
                UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.ToObject(L, 1);
                UnityEngine.Transform arg1 = (UnityEngine.Transform)ToLua.ToObject(L, 2);
                UnityEngine.Vector3   arg2 = ToLua.ToVector3(L, 3);
                MonoExtendUtil.AddChildToTarget(arg0, arg1, arg2);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: MonoExtendUtil.AddChildToTarget"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 3
0
    public static void PlayTweenScaleReverse(GameObject go)
    {
        TweenScale ts = MonoExtendUtil.GetOrAddComponent <TweenScale>(go);

        ts.enabled = true;
        ts.PlayReverse();
    }
Ejemplo n.º 4
0
    public void LoadAsyncInstance(string name, GameObject parent, Action <UnityEngine.Object> load, Action <float> progress,
                                  int type = ResourceType.RES_UI, bool unloadObject = false, bool isPermanent = false)
    {
        LoadResourceAsync(name, (_obj) =>
        {
            if (_obj == null)
            {
                Debug.LogError("resource load prefab object is null! name:" + name);
                return;
            }

            GameObject ret = MonoExtendUtil.CreateChild(parent, _obj as GameObject);
            if (ret == null)
            {
                Debug.LogError("Instantiate object is null!");
                load(null);
                return;
            }

            UnloadResource(name, unloadObject);

            if (load != null)
            {
                load(ret);
            }
        }
                          , progress, type, isPermanent);
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 停止牌桌倒计时
    /// </summary>
    /// <param name="go">Go.</param>
    /// <param name="str">String.</param>
    public static void StopLabelCount(GameObject go, string str)
    {
        LabelCount lc = MonoExtendUtil.GetOrAddComponent <LabelCount>(go);

        lc.label.text = str;
        lc.enabled    = false;
    }
Ejemplo n.º 6
0
    public static void PlayTweenScale(GameObject go)
    {
        TweenScale tp = MonoExtendUtil.GetOrAddComponent <TweenScale>(go);

        tp.ResetToBeginning();
        tp.enabled = true;
        tp.Play();
    }
Ejemplo n.º 7
0
    public static void ChangeTextureName(GameObject go, string name)
    {
        UITexture ut = MonoExtendUtil.GetOrAddComponent <UITexture>(go);

        Debugger.Log(name);
        Debugger.Log(ut.mainTexture);
        // ut.name= name;
    }
Ejemplo n.º 8
0
    public void OnContentUpdate(GameObject scrollView, GameObject go, object data)
    {
        PlayerScore itemData = data as PlayerScore;

        UILabel label = MonoExtendUtil.FindDeepChild <UILabel>(go, "ItemLab");

        label.text = itemData.name + ": " + itemData.score;
    }
Ejemplo n.º 9
0
    protected override void InitWindowOnAwake()
    {
        GameObject buyBtn    = MonoExtendUtil.FindDeepChild(this.gameObject, "DynamicPanel/BuyBtn").gameObject;
        GameObject cancelBtn = MonoExtendUtil.FindDeepChild(this.gameObject, "DynamicPanel/CancelBtn").gameObject;

        UIEventListener.Get(buyBtn).onClick    = OnBuyBtnClick;
        UIEventListener.Get(cancelBtn).onClick = OnCancelBtnClick;
    }
Ejemplo n.º 10
0
    protected override void InitWindowOnAwake()
    {
        loopScrollView = MonoExtendUtil.FindDeepChild <UILoopScrollView>(this.gameObject, "DynamicPanel/ScorePanel");
        GameObject backBtn = MonoExtendUtil.FindDeepChild(this.gameObject, "DynamicPanel/BackBtn").gameObject;

        loopScrollView.onContentUpdate       = OnContentUpdate;
        loopScrollView.onContentClick        = OnContentClick;
        UIEventListener.Get(backBtn).onClick = OnBackBtnClick;
    }
Ejemplo n.º 11
0
    /// <summary>
    /// 同步加载核心接口方法
    /// </summary>
    /// <param name="name"></param>
    /// <param name="parent"></param>
    /// <param name="type"></param>
    /// <returns></returns>
    public UnityEngine.Object LoadInstance(string name, GameObject parent, int type = ResourceType.RES_UI,
                                           bool unloadObject = false, bool isPermanent = false)
    {
        UnityEngine.Object prefabObj = LoadResource(name, type, isPermanent);

        GameObject ret = MonoExtendUtil.CreateChild(parent, prefabObj as GameObject);

        StartCoroutine(UnloadResourceCoroutine(name, unloadObject));
        return(ret);
    }
Ejemplo n.º 12
0
    public static void SetUILabelText(GameObject go, string text)
    {
        if (go == null)
        {
            return;
        }
        UILabel uiLable = MonoExtendUtil.GetOrAddComponent <UILabel>(go);

        uiLable.text = text;
    }
Ejemplo n.º 13
0
    public static void SetUILabelTextLength(GameObject go, string text, int value)
    {
        if (go == null)
        {
            return;
        }
        UILabel uiLable = MonoExtendUtil.GetOrAddComponent <UILabel>(go);

        uiLable.text = text.PadLeft(value, '0');
    }
Ejemplo n.º 14
0
    /// <summary>
    /// 牌桌倒计时
    /// </summary>
    /// <param name="go">Go.</param>
    /// <param name="start">开始Date.</param>
    /// <param name="stop">结束Date.</param>
    /// <param name="speed">间隔速度.</param>
    public static void SetCountLabelTime(GameObject go, int start, int stop, int speed)
    {
        LabelCount lc = MonoExtendUtil.GetOrAddComponent <LabelCount>(go);

        lc.enabled   = false;
        lc.startTime = start;
        lc.stopTime  = stop;
        lc.speed     = speed;
        lc.enabled   = true;
    }
Ejemplo n.º 15
0
    public static void PlayTweenScale(GameObject go, Vector3 vFrom, Vector3 vTo, float time1, float time2)
    {
        TweenScale ts = MonoExtendUtil.GetOrAddComponent <TweenScale>(go);

        ts.from     = vFrom;
        ts.to       = vTo;
        ts.duration = time1;
        ts.delay    = time2;
        ts.style    = UITweener.Style.Once;
        ts.enabled  = true;
        ts.PlayForward();
    }
Ejemplo n.º 16
0
    /// <summary>
    /// 更改UISprite图片名称
    /// </summary>
    /// <param name="go">Go.</param>
    public static void ChangeSpriteName(GameObject go, string name)
    {
        UISprite us = MonoExtendUtil.GetOrAddComponent <UISprite>(go);

        us.spriteName = name;
        UIButton bt = go.GetComponent <UIButton>();

        if (bt != null)
        {
            bt.normalSprite = name;
        }
    }
Ejemplo n.º 17
0
    protected override void InitWindowOnAwake()
    {
        GameObject buyCoinBtn  = MonoExtendUtil.FindDeepChild(this.gameObject, "DynamicPanel/BuyCoinBtn").gameObject;
        GameObject scoreBtn    = MonoExtendUtil.FindDeepChild(this.gameObject, "DynamicPanel/PlayerScoreBtn").gameObject;
        GameObject msgBoxBtn   = MonoExtendUtil.FindDeepChild(this.gameObject, "DynamicPanel/MsgBoxBtn").gameObject;
        GameObject backMenuBtn = MonoExtendUtil.FindDeepChild(this.gameObject, "DynamicPanel/BackMenuBtn").gameObject;

        UIEventListener.Get(buyCoinBtn).onClick  = OnBuyCoinBtnClick;
        UIEventListener.Get(scoreBtn).onClick    = OnScoreBtnClick;
        UIEventListener.Get(msgBoxBtn).onClick   = OnMsgBoxBtnClick;
        UIEventListener.Get(backMenuBtn).onClick = OnBackMenuBtnClick;
    }
Ejemplo n.º 18
0
    public static Component GetUIWidget(GameObject go, string childName, string type)
    {
        GameObject childObj = MonoExtendUtil.FindDeepChild(go, childName).gameObject;

        if (childObj == null)
        {
            return(null);
        }

        Type t = Type.GetType(type);

        return(childObj.GetComponent(t));
    }
Ejemplo n.º 19
0
 static int AddToDDOLRoot(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
         MonoExtendUtil.AddToDDOLRoot(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 20
0
 static int DestroyChildren(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 1);
         MonoExtendUtil.DestroyChildren(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 21
0
 static int ChangeChildLayer(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 1);
         int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
         MonoExtendUtil.ChangeChildLayer(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 22
0
 static int SetChildIdentityNoLayer(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
         UnityEngine.GameObject arg1 = (UnityEngine.GameObject)ToLua.CheckObject(L, 2, typeof(UnityEngine.GameObject));
         MonoExtendUtil.SetChildIdentityNoLayer(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 23
0
 static int SetTargetMinPanel(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
         int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
         MonoExtendUtil.SetTargetMinPanel(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 24
0
 static int GetMaxTargetDepth(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
         bool arg1 = LuaDLL.luaL_checkboolean(L, 2);
         int  o    = MonoExtendUtil.GetMaxTargetDepth(arg0, arg1);
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 25
0
 static int FindDeepChild(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
         string arg1             = ToLua.CheckString(L, 2);
         UnityEngine.Transform o = MonoExtendUtil.FindDeepChild(arg0, arg1);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 26
0
 static int CreateChild(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
         UnityEngine.GameObject arg1 = (UnityEngine.GameObject)ToLua.CheckObject(L, 2, typeof(UnityEngine.GameObject));
         UnityEngine.GameObject o    = MonoExtendUtil.CreateChild(arg0, arg1);
         ToLua.PushSealed(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 27
0
    /// <summary>
    /// 创建表单元格
    /// </summary>
    private void CreateGridCells()
    {
        if (grid == null)
        {
            return;
        }

        if (datas.Count == grid.transform.childCount || grid.transform.childCount >= maxGridNum)
        {
            RefreshScrollView(true);
            return;
        }

        Queue <GameObject> cacheItems = null;

        if (!cacheItemDic.TryGetValue(itemPrefabPath, out cacheItems))
        {
            return;
        }

        int hasCount = grid.transform.childCount;

        for (int i = 0; i < datas.Count - hasCount; i++)
        {
            if (i >= maxGridNum || cacheItems.Count <= 0)
            {
                break;
            }

            GameObject cell = cacheItems.Dequeue();
            if (cell == null)
            {
                continue;
            }

            MonoExtendUtil.AddChildToTarget(grid.transform, cell.transform);
            NGUITools.SetActive(cell, true);

            UIGridItem gridItem = cell.GetOrAddComponent <UIGridItem>();
            gridItem.Data = datas[i];
            gridItem.createBoxCollider();

            items.Add(gridItem);
        }

        RefreshScrollView(false);
    }
Ejemplo n.º 28
0
 static int GetPanelDepthMaxMin(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
         bool arg1 = LuaDLL.luaL_checkboolean(L, 2);
         bool arg2 = LuaDLL.luaL_checkboolean(L, 3);
         UnityEngine.GameObject o = MonoExtendUtil.GetPanelDepthMaxMin(arg0, arg1, arg2);
         ToLua.PushSealed(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 29
0
 static int AddColliderBgToTarget(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 4);
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
         string  arg1             = ToLua.CheckString(L, 2);
         UIAtlas arg2             = (UIAtlas)ToLua.CheckObject <UIAtlas>(L, 3);
         bool    arg3             = LuaDLL.luaL_checkboolean(L, 4);
         UnityEngine.GameObject o = MonoExtendUtil.AddColliderBgToTarget(arg0, arg1, arg2, arg3);
         ToLua.PushSealed(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 30
0
    protected override void Awake()
    {
        base.Awake();

        grid = transform.GetComponentInChildren <UIBetterGrid>();
        if (grid == null)
        {
            Debugger.LogError("Need UIBetterGrid Component!!");
            return;
        }

        grid.onUpdateGrid = OnUpdateGrid;

        // 预创建缓存item根节点
        cacheItemRoot = MonoExtendUtil.FindDeepChild(gameObject, CACHE_ITEM_ROOT);
        if (cacheItemRoot == null)
        {
            cacheItemRoot = new GameObject("CacheItemRoot").transform;
            MonoExtendUtil.AddChildToTarget(transform, cacheItemRoot);
        }
    }