Giter VIP home page Giter VIP logo

Comments (2)

MrTigerZhang avatar MrTigerZhang commented on July 27, 2024

我放在了预设下。实现通过预设获取xml,实现了xml的热更。

from behaviac.

zhenmu avatar zhenmu commented on July 27, 2024

我们是一般打包时 仍旧放在Resources下,
思路就是:重载 behaviac.FileManager、先去找热更目录有没有这个xml, 有就加载外部文件,没有就直接按原来方式去Resources目录加载。

根据 http://www.behaviac.com/tutorial_10_extent_filemanager/
重写了一个MyBehaviacFileManager

public class MyBehaviacFileManager : behaviac.FileManager
{
    public override byte[] FileOpen(string filePath, string ext)
    {
        bool in_out = false;    //这个有点鸡肋

        //思路:检测热更目录下是否有对应文件,存在则优先读取, 否则仍旧读取Resources
        int k0 = filePath.IndexOf("Resources");
        if (k0 != -1)
        {
            //根据传过来的路径,计算出我们在热更目录下的相对路径。
            string filePathInResources = filePath.Substring(k0);
            string fileOutPath = filePathInResources + ext;
            fileOutPath = fileOutPath.ToLower();
            if (FileHelper.CheckResInPersistentData(fileOutPath))   //封装的 检查安卓、ios热更外部目录的函数
            {
                try
                {
                    string file_name = FileHelper.GetResInPersistentDataPath(fileOutPath);   //封装的检查安卓、ios热更外部目录的文件全路径函数
                    byte[] buffer = CUtility.GetBinaryFileBuffer(file_name);                //文件读取成字节数组(安卓有些不一样,所以统一封装了一个接口)
                    in_out = true;
                    return buffer;
                }
                catch (System.Exception e)
                {
                    Log.Error("LoadJsonFile ({0}) failed, error({1})", fileOutPath, e.ToString());
                }

            }
        }
        if (!in_out)
        {
            return base.FileOpen(filePath, ext);    //外部xml等文件不存在,就走默认基类的加载
        }
        else
        {
            return null;
        }
    }
}

from behaviac.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.