Push() public method

public Push ( Array array ) : void
array Array
return void
    void Start()
    {
        lua = new LuaState();
        lua.Start();
        lua.DoString(script, "AccessingArray.cs");

        int[] array = { 1, 2, 3, 4, 5};
        func = lua.GetFunction("TestArray");

        func.BeginPCall();
        func.Push(array);
        func.PCall();
        double arg1 = func.CheckNumber();
        string arg2 = func.CheckString();
        bool arg3 = func.CheckBoolean();
        Debugger.Log("return is {0} {1} {2}", arg1, arg2, arg3);
        func.EndPCall();

        //转换一下类型,避免可变参数拆成多个参数传递
        object[] objs = func.Call((object)array);

        if (objs != null)
        {
            Debugger.Log("return is {0} {1} {2}", objs[0], objs[1], objs[2]);
        }

        lua.CheckTop();
    }
示例#2
0
    private void DistributePacket(int _opcode, byte[] _bytes)
    {
        Debug.Log("received socket proto " + GetOpcodeName(_opcode) + " 0x" + _opcode.ToString("X4"));

        if (m_luaDistributePacketFunc == null)
        {
            // DistributePacket
            return;
        }

        m_luaDistributePacketFunc.BeginPCall();
        m_luaDistributePacketFunc.Push(_opcode);
        m_luaDistributePacketFunc.Push(new LuaInterface.LuaByteBuffer(_bytes));
        m_luaDistributePacketFunc.PCall();
        m_luaDistributePacketFunc.EndPCall();
    }
示例#3
0
    public void GetUIPrefab(string assetName, Transform parent, LuaTable luaTable, LuaFunction luaCallBack)
    {
        if (mResManager == null) return;

        string tmpAssetName = assetName;
        if (GameSetting.DevelopMode)
        {
            tmpAssetName = "UIPrefab/" + assetName;
        }
        mResManager.LoadPrefab(assetName + GameSetting.ExtName, tmpAssetName, delegate(UnityEngine.Object[] objs)
        {
            if (objs.Length == 0) return;
            GameObject prefab = objs[0] as GameObject;
            if (prefab == null)
            {
                return;
            }
            GameObject go = UnityEngine.GameObject.Instantiate(prefab) as GameObject;
            go.name = assetName;
            go.layer = LayerMask.NameToLayer("UI");

            Vector3 anchorPos = Vector3.zero;
            Vector2 sizeDel = Vector2.zero;
            Vector3 scale = Vector3.one;

            RectTransform rtTr = go.GetComponent<RectTransform>();
            if (rtTr != null)
            {
                anchorPos = rtTr.anchoredPosition;
                sizeDel = rtTr.sizeDelta;
                scale = rtTr.localScale;
            }

            go.transform.SetParent(parent, false);

            if (rtTr != null)
            {
                rtTr.anchoredPosition = anchorPos;
                rtTr.sizeDelta = sizeDel;
                rtTr.localScale = scale;
            }

            LuaBehaviour tmpBehaviour = go.AddComponent<LuaBehaviour>();
            tmpBehaviour.Init(luaTable);

            if (luaCallBack != null)
            {
                luaCallBack.BeginPCall();
                luaCallBack.Push(go);
                luaCallBack.PCall();
                luaCallBack.EndPCall();
            }
            Debug.Log("CreatePanel::>> " + assetName + " " + prefab);
            //mUIList.Add(go);
        });
    }
示例#4
0
    private string GetOpcodeName(int _opcode)
    {
        if (m_luaGetOpcodeNameFunc == null)
        {
            return(string.Empty);
        }
        m_luaGetOpcodeNameFunc.BeginPCall();
        m_luaGetOpcodeNameFunc.Push(_opcode);
        m_luaGetOpcodeNameFunc.PCall();
        string t_res = m_luaGetOpcodeNameFunc.CheckString();

        m_luaGetOpcodeNameFunc.EndPCall();
        return(t_res);
    }
示例#5
0
    private void ReconnectEvt(bool _connected)
    {
        if (_connected)
        {
            m_pulseSendCount = 0;
        }

        if (m_luaReconnectFunc == null)
        {
            // ReconnectServer
            return;
        }

        m_luaReconnectFunc.BeginPCall();
        m_luaReconnectFunc.Push(_connected);
        m_luaReconnectFunc.PCall();
        m_luaReconnectFunc.EndPCall();
    }
示例#6
0
 public void AddClick(GameObject go, LuaFunction luafunc)
 {
     if (!CheckValid()) return;
     if (go == null || luafunc == null) return;
     if (!mButtonCallbacks.ContainsKey(go.name))
     {
         mButtonCallbacks.Add(go.name, luafunc);
         go.GetComponent<Button>().onClick.AddListener(
             delegate()
             {
                 luafunc.BeginPCall();
                 luafunc.Push(go);
                 luafunc.PCall();
                 luafunc.EndPCall();
             }
         );
     }
 }
示例#7
0
 void CallLuaFunction(LuaFunction func)
 {
     func.BeginPCall();
     func.Push(listener);
     func.PCall();
     func.EndPCall();
 }
示例#8
0
 //获取UI特效
 public void GetUIEffect(string effname, LuaFunction luaCallBack)
 {
     GetEffectObj(effname, (Obj) =>
     {
         if (Obj != null)
         {
             mUIEffectsList.Add(Obj);
         }
         if (luaCallBack != null)
         {
             luaCallBack.BeginPCall();
             luaCallBack.Push(Obj);
             luaCallBack.PCall();
             luaCallBack.EndPCall();
         }
     });
 }