| | |
| | | using LitJsonForAot;
|
| | | using System.Collections;
|
| | | using UnityEngine.Networking;
|
| | | using System.Linq;
|
| | | using StartAotSDK;
|
| | | using UnityEngine.U2D;
|
| | |
|
| | |
|
| | | namespace StartAot
|
| | | {
|
| | |
| | | {
|
| | | //不下载时本地安卓测试路径
|
| | | public string assetBundlesPath { get; private set; }
|
| | | public static string bytesFolderName = "daimazijie/";
|
| | | public static string bytesFolderName = "logicbytes/";
|
| | | public string StreamingAssetPath { get; private set; }
|
| | | public string ExternalStorePath { get; private set; }
|
| | |
|
| | |
| | | public bool isPCTestDownLoad = false;
|
| | |
|
| | | public static readonly string[] VERSION_URL = new string[] {
|
| | | "http://vncenter.tuyetvn.com:11000/center/appversion_new.php/?"};
|
| | | "http://vncenter.daojmengxvn.com:11000/center/appversion_new.php/?"};
|
| | |
|
| | | readonly static List<string> excludePngs = new List<string>() { "Launch_1.png", "Launch_2.png", "Launch_3.png", "LoginBackGround.png", "TB_DL_Logo.png" };
|
| | |
|
| | | public int debugBranch { get; private set; }
|
| | |
|
| | |
| | | string assetBytesUrl;
|
| | | //从网络获取的资源版本信息
|
| | | public Dictionary<string, AssetVersion> assetVersions = new Dictionary<string, AssetVersion>();
|
| | | //本地daimazijie文件和 assetVersions 比较是否需要下载
|
| | | //本地LogicBytes文件和 assetVersions 比较是否需要下载
|
| | | public Dictionary<string, AssetVersion> localAssetVersions = new Dictionary<string, AssetVersion>();
|
| | | public static string versionUrlResult { get; private set; }
|
| | |
|
| | |
| | | {
|
| | | if (Application.isMobilePlatform)
|
| | | {
|
| | | if (LocalSave.GetString("#@#BrancH") != string.Empty)
|
| | | {
|
| | | int tmpbranch;
|
| | | int.TryParse(LocalSave.GetString("#@#BrancH").Substring(1), out tmpbranch);
|
| | | if (tmpbranch != 0)
|
| | | debugBranch = tmpbranch;
|
| | | }
|
| | |
|
| | | var parentDirectory = Directory.GetParent(Application.persistentDataPath);
|
| | | if (File.Exists(parentDirectory + "/Debug"))
|
| | | {
|
| | |
| | |
|
| | | }
|
| | |
|
| | | //将文件名倒序,加上_aop后缀
|
| | | public string EncodeFileName(string name)
|
| | |
|
| | | public string GetAssetFilePath(string _assetKey)
|
| | | {
|
| | | name = name.Replace("\\", "/");
|
| | | int index = name.LastIndexOf("/");
|
| | | string headString;
|
| | | if (index >= 0)
|
| | | {
|
| | | int dotLastIndex = name.LastIndexOf(".");
|
| | | if (dotLastIndex == -1)
|
| | | {
|
| | | headString = name.Substring(0, index);
|
| | | name = name.Substring(index + 1);
|
| | | return StringUtility.Contact(headString, "/", new string(name.Reverse().ToArray()), "_aop");
|
| | | }
|
| | | else
|
| | | {
|
| | | headString = name.Substring(0, index);
|
| | | var ext = name.Substring(dotLastIndex);
|
| | | name = name.Substring(index + 1, dotLastIndex - index - 1);
|
| | | return StringUtility.Contact(headString, "/", new string(name.Reverse().ToArray()), "_aop", ext);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | int dotLastIndex = name.LastIndexOf(".");
|
| | | if (dotLastIndex == -1)
|
| | | return StringUtility.Contact(new string(name.Reverse().ToArray()), "_aop");
|
| | | else
|
| | | {
|
| | | var ext = name.Substring(dotLastIndex);
|
| | | name = name.Substring(0, dotLastIndex);
|
| | | return StringUtility.Contact(new string(name.Reverse().ToArray()), "_aop", ext);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | public string GetAssetFilePath(string _assetKey, bool reverse = true)
|
| | | {
|
| | | if (reverse)
|
| | | _assetKey = EncodeFileName(_assetKey);
|
| | | var path = Path.Combine(ExternalStorePath, _assetKey);
|
| | | if (!File.Exists(path))
|
| | | {
|
| | |
| | | {
|
| | | Sprite sprite = null;
|
| | | #if UNITY_EDITOR
|
| | | var path = StringUtility.Contact("Assets/ResourcesOut/BuiltIn/Sprites/", name, ".png");
|
| | | sprite = UnityEditor.AssetDatabase.LoadAssetAtPath<Sprite>(path);
|
| | | if (excludePngs.Contains(StringUtility.Contact(name, ".png")))
|
| | | {
|
| | | var path = StringUtility.Contact("Assets/ResourcesOut/BuiltIn/Sprites/", name, ".png");
|
| | | sprite = UnityEditor.AssetDatabase.LoadAssetAtPath<Sprite>(path);
|
| | | }
|
| | | else
|
| | | {
|
| | | var spriteAtlas = UnityEditor.AssetDatabase.LoadAssetAtPath<SpriteAtlas>("Assets/ResourcesOut/BuiltIn/Sprites/sprites.spriteatlasv2");
|
| | | sprite = spriteAtlas.GetSprite(name);
|
| | | }
|
| | |
|
| | | #else
|
| | | if (spriteBundle == null)
|
| | |
| | | //LogicBytes文件的MD5信息
|
| | | public void RequestLogicBytes()
|
| | | {
|
| | | var remoteURL = string.Concat(versionInfo.GetResourcesURL(VersionConfigEx.Get().branch), fixPath, "/daimazijie.txt");
|
| | | var remoteURL = string.Concat(versionInfo.GetResourcesURL(VersionConfigEx.Get().branch), fixPath, "/logicbytes.txt");
|
| | | //var localURL = string.Concat(.ExternalStorePath, "/logicbytes.txt");
|
| | | assetBytesUrl = remoteURL;
|
| | | Debug.Log("http地址:logicbytesUrl " + assetBytesUrl);
|
| | |
| | | if (isPCTestDownLoad || Application.isMobilePlatform)
|
| | | {
|
| | | //读取的一定是StreamingAssetPath路径
|
| | | StartCoroutine(ReadText("daimazijie", (isOK, value) =>
|
| | | StartCoroutine(ReadText("logicbytes", (isOK, value) =>
|
| | | {
|
| | | if (isOK)
|
| | | InitLocalLogicbytes(value);
|