Пример #1
0
 static int Add(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UIResMgr arg0 = (UIResMgr)ToLua.CheckUnityObject(L, 1, typeof(UIResMgr));
         string   arg1 = ToLua.CheckString(L, 2);
         UIResTool.Add(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #2
0
    void LoadPrefabAsync(string modName, string abName, string assetName, LuaFunction func = null, LuaTable tab = null)
    {
        ResManager.LoadPrefab(abName, assetName, delegate(UnityEngine.Object[] objs)
        {
            if (objs.Length == 0)
            {
                return;
            }
            GameObject prefab = objs[0] as GameObject;
            if (prefab == null)
            {
                return;
            }

            GameObject go = Instantiate(prefab) as GameObject;
            go.name       = assetName;

            if (assetName == "UIResMgr")
            {
                UIResMgr uiResMgr = go.GetComponent <UIResMgr>();
                if (uiResMgr == null)
                {
                    Debug.LogError("abName : " + abName + "  assetName : " + assetName + " 没有UIResMgr脚本");
                    return;
                }
                UIResTool.Add(uiResMgr, modName);
                return;
            }

            RectTransform rt = go.GetComponent <RectTransform>();
            if (rt != null && m_canvasRoot != null)
            {
                rt.SetParent(m_canvasRoot, false);
                rt.anchorMin          = Vector2.zero;
                rt.anchorMax          = Vector2.one;
                rt.localScale         = Vector3.one;
                rt.anchoredPosition3D = Vector3.zero;
                rt.sizeDelta          = Vector2.zero;

                m_panels[assetName] = go;
                //AddSoundFX(panel);//添加UI音效
                if (func != null)
                {
                    func.Call(tab, go);
                }
            }
        });
    }
Пример #3
0
    IEnumerator LoadPrefab(string modName, string assetName, LuaFunction func = null, LuaTable tab = null)
    {
        GameObject prefab = Resources.Load("Prefab/" + modName + "/" + assetName) as GameObject;

        while (prefab == null)
        {
            Debug.Log("加载资源-------" + assetName);
            yield return(1);
        }
        GameObject go = Instantiate(prefab) as GameObject;

        go.name = assetName;
        RectTransform rt = go.GetComponent <RectTransform>();

        if (rt != null && m_canvasRoot != null)
        {
            rt.SetParent(m_canvasRoot);
            rt.anchorMin          = Vector2.zero;
            rt.anchorMax          = Vector2.one;
            rt.localScale         = Vector3.one;
            rt.anchoredPosition3D = Vector3.zero;
            rt.sizeDelta          = Vector2.zero;

            m_panels[assetName] = go;
            //AddSoundFX(panel);//添加UI音效
            if (func != null)
            {
                func.Call(tab, go);
            }
        }

        if (assetName == "UIResMgr")
        {
            UIResMgr uiResMgr = go.GetComponent <UIResMgr>();
            if (uiResMgr == null)
            {
                Debug.LogError("modName : " + modName + "  assetName : " + assetName + " 没有UIResMgr脚本");
                yield break;
            }
            UIResTool.Add(uiResMgr, modName);
        }
        yield break;
    }