• 关于Unity中资源打包


    资源包详细说明

    Unity很智能只会打包用到的资源,比如sharedassets0.assets中的shader资源,如果场景中有OBJ用到了shader那么就会有shader打进这个包,如果没有就不会打进来。没有打的时候是5k打进来就是90k.

    BuildPipeline:

    当使用BuildPipeline进行打包时,要注意打包的目标平台,否则无法被加载成功,BuildTarget平台枚举.

    文件夹:

          StreamingAssets: 为流资源,在这个文件夹里的资源不会被Unity打入到默认的资源包中,

    在加载的时候要注意平台相关。

          Application.streamingAssetsPath: 获取StreamingAssets的路径对于不同的平台这个不一样,

    所以要加载StreamingAssets文件夹中的资源要用这个值。

    string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "test.csv");
          if (filePath.Contains("://")) // Android平台必须用 www
          {
              WWW www = new WWW(filePath);
              yield return www;
              mStrTest = www.text;
          }
          else
          {

              // PC 平台 自己写加载方式
              mStrTest = System.IO.File.ReadAllText(filePath);

             //也可以用www加载,需要用“file://”

             filePath = “file://”+filePath;

             www file = new www(filePath);

         TextAsset txt = file.assetBundle.Load("myBinaryAsText", typeof(TextAsset)) as TextAsset;        
        }
    注意: test.csv名字要大小写匹配

    文本文件:

    上述加载方式方可。

    二进制文件:

    文件扩展名要用 .bytes

    加载方式上述方式方可。

  • 相关阅读:
    ZooKeeper 授权访问
    jQuery代码优化:事件委托篇
    设计一个学生作业完成情况的管理程序
    UVa 10192 Vacation(LCS水题)
    BBS快照源代码代写
    ftp服务器系统编程编码程序下载代写代开发
    文件夹病毒专杀工具
    C#生成软件注册码
    《恐怖丛林生存》肉搏攻略,解开星星系统之谜
    《恐怖丛林生存》各种bug 各种解密
  • 原文地址:https://www.cnblogs.com/ThreeThousandBigWorld/p/3160610.html
Copyright © 2020-2023  润新知