Ejemplo n.º 1
0
    public void LoadMesh(string respath, string name, Action <IProxy <Mesh> > finish)
    {
        var mesh = assetMgrIO.GetMesh(name);

        if (mesh != null)
        {
            var pmesh = new ProxyMesh(mesh, name);
            assetMgrIO.MeshAddRef(name);
            finish(pmesh);
        }
        else
        {
            ResmgrNative.Instance.LoadBytesFromCache(respath + "/mesh/" + name + ".mesh.bytes",
                                                     name,
                                                     (bytes, tagName) =>
            {
                Mesh lmesh = AssetMgr.ReadMesh(bytes, tagName);
                assetMgrIO.AddMesh(tagName, lmesh);
                var pmesh = new ProxyMesh(lmesh, name);
                assetMgrIO.MeshAddRef(tagName);
                finish(pmesh);
            });
        }
    }
Ejemplo n.º 2
0
    public void LoadLayout(string respath, string layoutname, Action <IProxy <GameObject> > finish)
    {
        Action Finish = () =>
        {
            ResmgrNative.Instance.LoadStringFromCache(respath + "/layout/" + layoutname + ".layout.txt",
                                                      "",
                                                      (code, tag) =>
            {
                var json = MyJson.Parse(code);
                var obj  = GameObjParser.FromJson(json);
                finish(new ProxyLayout(obj, layoutname));
            }
                                                      );
        };
        Action <MyJson.IJsonNode> dependLoaded = (json) =>
        {
            if (json.HaveDictItem("mesh"))
            {
                var list = json.GetDictItem("mesh").AsList();
                foreach (var l in list)
                {
                    ResmgrNative.Instance.LoadBytesFromCache(respath + "/mesh/" + l.AsString() + ".mesh.bytes",
                                                             l.AsString(),
                                                             (bytes, tagName) =>
                    {
                        Mesh mesh = AssetMgr.ReadMesh(bytes, tagName);
                        assetMgrIO.AddMesh(tagName, mesh);
                        assetMgrIO.MeshAddRef(tagName);
                    });
                    Debug.Log("dependmesh:" + l.AsString());
                }
            }
            if (json.HaveDictItem("tex"))
            {
                var list = json.GetDictItem("tex").AsList();
                foreach (var l in list)
                {
                    ResmgrNative.Instance.LoadTexture2DFromCache(respath + "/texture/" + l.AsString(),
                                                                 l.AsString(),
                                                                 (tex, tagName) =>
                    {
                        assetMgrIO.AddTexture2D(tagName, tex);
                        assetMgrIO.TextureAddRef(tagName);
                    });
                }
            }
            ResmgrNative.Instance.WaitForTaskFinish(Finish);
        };

        if (layoutDepends.ContainsKey(layoutname))
        {
            dependLoaded(layoutDepends[layoutname]);
        }
        else
        {
            ResmgrNative.Instance.LoadStringFromCache(respath + "/layout/" + layoutname + ".depend.txt", "", (code, tag) =>
            {
                layoutDepends[layoutname] = MyJson.Parse(code) as MyJson.JsonNode_Object;
                dependLoaded(layoutDepends[layoutname]);
            });
        }
    }