Beispiel #1
0
    //弹出一个消息
    public void PopMsg(string msg, Color color)
    {
        float minY = m_StartY + (float)m_PopingObjs.Count * m_ItemHeight;

        if (IsSameItem(msg))
        {
            return;
        }

        //将一些过矮的元素提升
        foreach (TipItem curr in m_PopingObjs)
        {
            GameObject obj = curr.obj;
            if (obj.transform.localPosition.y < minY)
            {
                Vector3 pos = obj.transform.localPosition;
                pos.y = minY;
                obj.transform.localPosition = pos;
            }

            minY -= m_ItemHeight;
        }

        //创建item对象
        GameObject item = GameObjectExtension.InstantiateFromPreobj(m_ItemMB, m_ItemMB.transform.parent.gameObject);

        item.SetActive(true);
        NGUITools.MarkParentAsChanged(item);

        TipItem newItem = new TipItem()
        {
            lostTime = 0, obj = item
        };

        m_PopingObjs.Add(newItem);

        //设置标签
        string[] findpath = new string[1];
        findpath[0] = "Label";

        GameObject lableObj = GameObjectExtension.FindChild(item.transform, findpath).gameObject;
        UILabel    cmlabel  = lableObj.GetComponent <UILabel>();

        cmlabel.text  = msg;
        cmlabel.color = color;

        //解除位置绑定关系
        UIRect cm_rect = item.GetComponent <UIRect>();

        cm_rect.SetAnchor((GameObject)null);

        if (!m_CoroutineIsDoing)
        {
            CoroutineManage.Single.StartCoroutine(coUpdate());
        }
    }
Beispiel #2
0
 static int InstantiateFromPreobj(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Object     arg0 = (UnityEngine.Object)ToLua.CheckUnityObject(L, 1, typeof(UnityEngine.Object));
         UnityEngine.GameObject arg1 = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.GameObject));
         UnityEngine.GameObject o    = GameObjectExtension.InstantiateFromPreobj(arg0, arg1);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }