add
This commit is contained in:
155
Assets/CoolapeFrame/Scripts/resMgr/CLPathCfg.cs
Normal file
155
Assets/CoolapeFrame/Scripts/resMgr/CLPathCfg.cs
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
********************************************************************************
|
||||
*Copyright(C),coolae.net
|
||||
*Author: chenbin
|
||||
*Version: 2.0
|
||||
*Date: 2017-01-09
|
||||
*Description: 路径配置
|
||||
*Others:
|
||||
*History:
|
||||
*********************************************************************************
|
||||
*/
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Coolape
|
||||
{
|
||||
public class CLPathCfg : MonoBehaviour
|
||||
{
|
||||
public static CLPathCfg self;
|
||||
|
||||
public CLPathCfg ()
|
||||
{
|
||||
self = this;
|
||||
}
|
||||
|
||||
static string _persistentDataPath = "";
|
||||
|
||||
public static string persistentDataPath {
|
||||
get {
|
||||
#if UNITY_EDITOR
|
||||
if (CLCfgBase.self.isEditMode) {
|
||||
return Application.dataPath;
|
||||
} else {
|
||||
if (_persistentDataPath == null || _persistentDataPath == "") {
|
||||
_persistentDataPath = Application.persistentDataPath;
|
||||
}
|
||||
return _persistentDataPath;
|
||||
}
|
||||
#else
|
||||
if(_persistentDataPath == null || _persistentDataPath == "") {
|
||||
_persistentDataPath = Application.persistentDataPath;
|
||||
#if UNITY_ANDROID
|
||||
if(_persistentDataPath == null || _persistentDataPath == "") {
|
||||
AndroidJavaClass jc = new AndroidJavaClass("com.x3gu.tools.Tools4FilePath");
|
||||
_persistentDataPath = jc.CallStatic<string>("getPath");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return _persistentDataPath;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public string platform {
|
||||
get
|
||||
{
|
||||
#if UNITY_IOS
|
||||
return "IOS";
|
||||
#elif UNITY_ANDROID
|
||||
return "Android";
|
||||
#elif UNITY_STANDALONE_WIN
|
||||
return "Standalone";
|
||||
#elif UNITY_STANDALONE_OSX
|
||||
return "StandaloneOSX";
|
||||
#elif UNITY_WEBGL
|
||||
return "WebGL";
|
||||
|
||||
#else
|
||||
return "Standalone";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public string runtimePlatform {
|
||||
get {
|
||||
switch (Application.platform)
|
||||
{
|
||||
case RuntimePlatform.WindowsPlayer:
|
||||
return "win|player";
|
||||
case RuntimePlatform.WindowsEditor:
|
||||
return "win|editor";
|
||||
case RuntimePlatform.Android:
|
||||
return "android|player";
|
||||
case RuntimePlatform.IPhonePlayer:
|
||||
return "ios|player";
|
||||
case RuntimePlatform.OSXEditor:
|
||||
return "osx|editor";
|
||||
case RuntimePlatform.OSXPlayer:
|
||||
return "osx|player";
|
||||
case RuntimePlatform.WebGLPlayer:
|
||||
return "web|player";
|
||||
case RuntimePlatform.LinuxPlayer:
|
||||
return "linux|player";
|
||||
case RuntimePlatform.LinuxEditor:
|
||||
return "linux|editor";
|
||||
}
|
||||
return "others";
|
||||
}
|
||||
}
|
||||
//
|
||||
// [HideInInspector]
|
||||
public string basePath = "xxx";
|
||||
//实际的font路径
|
||||
// public string realFontPath = "xxx/upgradeRes/priority/font/FontDynReal.unity3d";
|
||||
//页面数据存放路径
|
||||
public string panelDataPath = "xxx/upgradeRes/priority/ui/panel/";
|
||||
public string cellDataPath = "xxx/upgradeRes/priority/ui/cell/";
|
||||
|
||||
public string _cellDataPath {
|
||||
get {
|
||||
#if UNITY_EDITOR
|
||||
if (!CLCfgBase.self.isEditMode) {
|
||||
return cellDataPath;
|
||||
}
|
||||
return cellDataPath.Replace ("/upgradeRes/", "/upgradeRes4Publish/");
|
||||
#else
|
||||
return cellDataPath;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//多语言文件路径
|
||||
public string localizationPath = "xxx/upgradeRes/priority/localization/";
|
||||
public string luaPathRoot = "xxx/upgradeRes/priority/lua";
|
||||
|
||||
public static string upgradeRes {
|
||||
get {
|
||||
#if UNITY_EDITOR
|
||||
if (!CLCfgBase.self.isEditMode) {
|
||||
return "upgradeRes";
|
||||
}
|
||||
return "upgradeRes4Publish";
|
||||
#else
|
||||
return "upgradeRes";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public void resetPath (string basePath)
|
||||
{
|
||||
this.basePath = basePath;
|
||||
//实际的font路径
|
||||
// realFontPath = basePath + "/upgradeRes/priority/font/FontDynReal.unity3d";
|
||||
//页面数据存放路径
|
||||
panelDataPath = basePath + "/upgradeRes/priority/ui/panel/";
|
||||
cellDataPath = basePath + "/upgradeRes/priority/ui/cell/";
|
||||
//多语言文件路径
|
||||
localizationPath = basePath + "/upgradeRes/priority/localization/";
|
||||
|
||||
luaPathRoot = basePath + "/upgradeRes/priority/lua/";
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/CoolapeFrame/Scripts/resMgr/CLPathCfg.cs.meta
Normal file
12
Assets/CoolapeFrame/Scripts/resMgr/CLPathCfg.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ecbc2f436f1c94ebaa658567e590caed
|
||||
timeCreated: 1484012494
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
409
Assets/CoolapeFrame/Scripts/resMgr/CLPreLoadRes4Webgl.cs
Normal file
409
Assets/CoolapeFrame/Scripts/resMgr/CLPreLoadRes4Webgl.cs
Normal file
@@ -0,0 +1,409 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coolape
|
||||
{
|
||||
public class CLPreLoadRes4Webgl
|
||||
{
|
||||
public static Hashtable resCache4Webgl = new Hashtable();
|
||||
static string baseUrl = ""; //--"http.//gamesres.ultralisk.cn/cdn/test";
|
||||
static string platform = "";
|
||||
static string newestVerPath = "newestVers";
|
||||
static string resVer = "resVer";
|
||||
static string versPath = "VerCtl";
|
||||
static string fverVer = "VerCtl.ver"; //--本地所有版本的版本信息
|
||||
//---@type System.Collections.Hashtable
|
||||
static Hashtable localverVer = new Hashtable();
|
||||
//---@type System.Collections.Hashtable
|
||||
static Hashtable serververVer = new Hashtable();
|
||||
//--========================
|
||||
static string verPriority = "priority.ver";
|
||||
//---@type System.Collections.Hashtable
|
||||
static Hashtable localPriorityVer = new Hashtable(); //--本地优先更新资源
|
||||
//---@type System.Collections.Hashtable
|
||||
static Hashtable serverPriorityVer = new Hashtable(); //--服务器优先更新资源
|
||||
|
||||
static string verOthers = "other.ver";
|
||||
//---@type System.Collections.Hashtable
|
||||
static Hashtable otherResVerOld = new Hashtable(); //--所有资源的版本管理
|
||||
//---@type System.Collections.Hashtable
|
||||
static Hashtable otherResVerNew = new Hashtable(); //--所有资源的版本管理
|
||||
|
||||
static string tmpUpgradePirorityPath = "tmpUpgrade4Pirority";
|
||||
static bool haveUpgrade = false;
|
||||
|
||||
static object onFinishInit = null;
|
||||
static object progressCallback = null;
|
||||
static string mVerverPath = "";
|
||||
static string mVerPrioriPath = "";
|
||||
static string mVerOtherPath = "";
|
||||
|
||||
//---@type System.Collections.Hashtable
|
||||
static Hashtable needUpgradeVerver = new Hashtable();
|
||||
static int progress = 0;
|
||||
|
||||
static bool isNeedUpgradePriority = false;
|
||||
static Queue needUpgradePrioritis = new Queue();
|
||||
static bool isSucessUpgraded = false;
|
||||
static string verVerMD5 = "";
|
||||
|
||||
public static byte[] getContent(string fileName)
|
||||
{
|
||||
return MapEx.getBytes(resCache4Webgl, fileName);
|
||||
}
|
||||
|
||||
/// iprogressCallback. 进度回调,回调有两个参数
|
||||
/// ifinishCallback. 完成回调
|
||||
/// isdoUpgrade. 是否做更新处理
|
||||
public static void init(object iprogressCallback, object ifinishCallback, bool isdoUpgrade, string _verVerMD5)
|
||||
{
|
||||
haveUpgrade = false;
|
||||
verVerMD5 = _verVerMD5;
|
||||
baseUrl = CLVerManager.self.baseUrl;
|
||||
//CLVerManager.self.haveUpgrade = false;
|
||||
isNeedUpgradePriority = false;
|
||||
localverVer.Clear();
|
||||
serververVer.Clear();
|
||||
localPriorityVer.Clear();
|
||||
serverPriorityVer.Clear();
|
||||
otherResVerOld.Clear();
|
||||
otherResVerNew.Clear();
|
||||
platform = CLPathCfg.self.platform;
|
||||
CLVerManager.self.platform = platform;
|
||||
|
||||
mVerverPath = PStr.begin().a(CLPathCfg.self.basePath).a("/").a(resVer).a("/").a(platform).a("/").a(fverVer).e();
|
||||
mVerPrioriPath = PStr.begin().a(CLPathCfg.self.basePath).a("/").a(resVer).a("/").a(platform).a("/").a(versPath).a("/").a(verPriority).e();
|
||||
mVerOtherPath = PStr.begin().a(CLPathCfg.self.basePath).a("/").a(resVer).a("/").a(platform).a("/").a(versPath).a("/").a(verOthers).e();
|
||||
CLVerManager.self.mVerverPath = mVerverPath;
|
||||
CLVerManager.self.mVerPrioriPath = mVerPrioriPath;
|
||||
CLVerManager.self.mVerOtherPath = mVerOtherPath;
|
||||
|
||||
progressCallback = iprogressCallback;
|
||||
onFinishInit = ifinishCallback;
|
||||
getServerVerverMap();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the server verver map.取得服务器版本文件的版本信息
|
||||
/// </summary>
|
||||
static void getServerVerverMap()
|
||||
{
|
||||
string url = "";
|
||||
//if (CLCfgBase.self.hotUpgrade4EachServer)
|
||||
//{
|
||||
// //-- 说明是每个服务器单独处理更新控制
|
||||
// url = PStr.begin().a(baseUrl).a("/").a(mVerverPath).a(".").a(verVerMD5).e();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// url = PStr.begin().a(baseUrl).a("/").a(mVerverPath).e();
|
||||
//}
|
||||
url = PStr.begin().a(baseUrl).a("/").a(mVerverPath).e();
|
||||
|
||||
WWWEx.get(
|
||||
Utl.urlAddTimes(url), //加了时间戳,保证一定会取得最新的
|
||||
CLAssetType.bytes,
|
||||
(Callback)onGetServerVerverBuff,
|
||||
(Callback)onGetServerVerverBuff, null, true);
|
||||
}
|
||||
|
||||
static void onGetServerVerverBuff(params object[] param)
|
||||
{
|
||||
byte[] content = param[0] as byte[];
|
||||
object orgs = param[1];
|
||||
if (content != null)
|
||||
{
|
||||
serververVer = CLVerManager.self.toMap(content);
|
||||
}
|
||||
else
|
||||
{
|
||||
serververVer = new Hashtable();
|
||||
Debug.LogError("取得服务器版本文件的版本信息 error!!!!");
|
||||
}
|
||||
//--判断哪些版本控制信息需要更新
|
||||
checkVervers();
|
||||
}
|
||||
|
||||
static void checkVervers()
|
||||
{
|
||||
progress = 0;
|
||||
needUpgradeVerver.Clear();
|
||||
isNeedUpgradePriority = false;
|
||||
string ver = null;
|
||||
ArrayList keysList = MapEx.keys2List(serververVer);
|
||||
int count = keysList.Count;
|
||||
string basePath = CLPathCfg.self.basePath;
|
||||
string key = "";
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
key = keysList[i] as string;
|
||||
|
||||
ver = MapEx.getString(localverVer, key); //实际上这个时间localverVer是空的
|
||||
if (ver == null || ver != MapEx.getString(serververVer, key))
|
||||
{
|
||||
if (!key.Contains(PStr.b().a(basePath).a("/ui/panel").e())
|
||||
&& !key.Contains(PStr.b().a(basePath).a("/ui/cell").e())
|
||||
&& !key.Contains(PStr.b().a(basePath).a("/ui/other").e()))
|
||||
{
|
||||
MapEx.set(needUpgradeVerver, key, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
keysList.Clear();
|
||||
keysList = null;
|
||||
|
||||
if (needUpgradeVerver.Count > 0)
|
||||
{
|
||||
if (progressCallback != null)
|
||||
{
|
||||
Utl.doCallback(progressCallback, needUpgradeVerver.Count, 0);
|
||||
}
|
||||
|
||||
keysList = MapEx.keys2List(needUpgradeVerver);
|
||||
count = keysList.Count;
|
||||
key = "";
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
key = keysList[i] as string;
|
||||
getVerinfor(key, MapEx.getString(serververVer, key));
|
||||
}
|
||||
keysList.Clear();
|
||||
keysList = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
loadPriorityVer();
|
||||
loadOtherResVer(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-- 取得版本文件
|
||||
static void getVerinfor(string fPath, string verVal)
|
||||
{
|
||||
//-- 注意是加了版本号的,可以使用cdn
|
||||
string url = PStr.b().a(baseUrl).a("/").a(fPath).a(".").a(verVal).e();
|
||||
WWWEx.get(url, CLAssetType.bytes,
|
||||
(Callback)onGetVerinfor,
|
||||
(Callback)onGetVerinfor, fPath, true);
|
||||
}
|
||||
|
||||
static void onGetVerinfor(params object[] param)
|
||||
{
|
||||
byte[] content = param[0] as byte[];
|
||||
object orgs = param[1];
|
||||
if (content != null)
|
||||
{
|
||||
string fPath = orgs as string;
|
||||
progress = progress + 1;
|
||||
MapEx.set(localverVer, fPath, MapEx.getString(serververVer, fPath));
|
||||
|
||||
string fName = PStr.b().a(CLPathCfg.persistentDataPath).a("/").a(newestVerPath).a("/").a(fPath).e();
|
||||
if (Path.GetFileName(fName) == "priority.ver")
|
||||
{
|
||||
//-- 优先更新需要把所有资源更新完后才记录
|
||||
isNeedUpgradePriority = true;
|
||||
serverPriorityVer = CLVerManager.self.toMap(content);
|
||||
CLVerManager.self.localPriorityVer = serverPriorityVer;
|
||||
}
|
||||
else
|
||||
{
|
||||
otherResVerNew = CLVerManager.self.toMap(content);
|
||||
CLVerManager.self.otherResVerNew = otherResVerNew;
|
||||
}
|
||||
|
||||
MapEx.set(needUpgradeVerver, fPath, true);
|
||||
|
||||
if (progressCallback != null)
|
||||
{
|
||||
Utl.doCallback(progressCallback, needUpgradeVerver.Count, progress);
|
||||
}
|
||||
|
||||
//-- if (isFinishAllGet()) then
|
||||
if (needUpgradeVerver.Count == progress)
|
||||
{
|
||||
if (!isNeedUpgradePriority)
|
||||
{
|
||||
//-- 说明没有优先资源需要更新,可以不做其它处理了
|
||||
//--同步到本地
|
||||
loadPriorityVer();
|
||||
loadOtherResVer(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
checkPriority(); //--处理优先资源更新
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
initFailed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void checkPriority()
|
||||
{
|
||||
localPriorityVer = new Hashtable();
|
||||
|
||||
progress = 0;
|
||||
needUpgradeVerver.Clear();
|
||||
needUpgradePrioritis.Clear();
|
||||
string ver = null;
|
||||
ArrayList keysList = MapEx.keys2List(serverPriorityVer);
|
||||
string key = null;
|
||||
int count = keysList.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
key = keysList[i] as string;
|
||||
ver = MapEx.getString(localPriorityVer, key);
|
||||
//实际上这个时间localverVer是空的,因此其实就是取得所有优先资源,但是因为了加了版本号,所以可以使用cdn,或者本地缓存什么的
|
||||
if (ver == null || ver != MapEx.getString(serverPriorityVer, key))
|
||||
{
|
||||
MapEx.set(needUpgradeVerver, key, false);
|
||||
needUpgradePrioritis.Enqueue(key);
|
||||
}
|
||||
}
|
||||
keysList.Clear();
|
||||
keysList = null;
|
||||
|
||||
if (needUpgradePrioritis.Count > 0)
|
||||
{
|
||||
haveUpgrade = true;
|
||||
CLVerManager.self.haveUpgrade = true;
|
||||
if (progressCallback != null)
|
||||
{
|
||||
Utl.doCallback(progressCallback, needUpgradeVerver.Count, 0);
|
||||
}
|
||||
getPriorityFiles(needUpgradePrioritis.Dequeue() as string);
|
||||
}
|
||||
else
|
||||
{
|
||||
//--同步总的版本管理文件到本地
|
||||
//MemoryStream ms = new MemoryStream();
|
||||
//B2OutputStream.writeMap(ms, localverVer);
|
||||
//string vpath = PStr.b().a(CLPathCfg.persistentDataPath).a("/").a(mVerverPath).e();
|
||||
//FileEx.CreateDirectory(Path.GetDirectoryName(vpath));
|
||||
//File.WriteAllBytes(vpath, ms.ToArray());
|
||||
|
||||
loadOtherResVer(true);
|
||||
}
|
||||
}
|
||||
|
||||
//-- 取得优先更新的资源
|
||||
static void getPriorityFiles(string fPath)
|
||||
{
|
||||
string Url = "";
|
||||
string verVal = MapEx.getString(serverPriorityVer, fPath);
|
||||
//--把版本号拼在后面
|
||||
Url = PStr.begin().a(baseUrl).a("/").a(fPath).a(".").a(verVal).e();
|
||||
//-- print("Url=="..Url);
|
||||
|
||||
WWWEx.get(Url, CLAssetType.bytes,
|
||||
(Callback)onGetPriorityFiles,
|
||||
(Callback)initFailed, fPath, true);
|
||||
|
||||
if (progressCallback != null)
|
||||
{
|
||||
Utl.doCallback(progressCallback, needUpgradeVerver.Count, progress, WWWEx.getWwwByUrl(Url));
|
||||
}
|
||||
}
|
||||
|
||||
static void onGetPriorityFiles(params object[] param)
|
||||
{
|
||||
byte[] content = param[0] as byte[];
|
||||
object orgs = param[1];
|
||||
if (content == null)
|
||||
{
|
||||
Utl.doCallback((Callback)initFailed);
|
||||
return;
|
||||
}
|
||||
|
||||
string fPath = orgs as string;
|
||||
progress = progress + 1;
|
||||
//缓存起来
|
||||
resCache4Webgl[fPath] = content;
|
||||
//-- 先把文件放在tmp目录,等全部下载好后再移到正式目录
|
||||
//string fName = PStr.b().a(CLPathCfg.persistentDataPath).a("/").a(tmpUpgradePirorityPath).a("/").a(fPath).e();
|
||||
//FileEx.CreateDirectory(Path.GetDirectoryName(fName));
|
||||
//File.WriteAllBytes(fName, content);
|
||||
|
||||
//--同步到本地
|
||||
//MapEx.set(localPriorityVer, fPath, MapEx.getString(serverPriorityVer, fPath));
|
||||
//MapEx.set(needUpgradeVerver, fPath, true);
|
||||
//CLVerManager.self.localPriorityVer = localPriorityVer;
|
||||
if (progressCallback != null)
|
||||
{
|
||||
Utl.doCallback(progressCallback, needUpgradeVerver.Count, progress);
|
||||
}
|
||||
|
||||
if (needUpgradePrioritis.Count > 0)
|
||||
{
|
||||
getPriorityFiles(needUpgradePrioritis.Dequeue() as string);
|
||||
}
|
||||
else
|
||||
{
|
||||
//--已经把所有资源取得完成
|
||||
//-- 先把文件放在tmp目录,等全部下载好后再移到正式目录
|
||||
//ArrayList keysList = MapEx.keys2List(needUpgradeVerver);
|
||||
//int count = keysList.Count;
|
||||
//string key = null;
|
||||
//string fromFile = "";
|
||||
//string toFile = "";
|
||||
//for (int i = 0; i < count; i++)
|
||||
//{
|
||||
// key = keysList[i];
|
||||
// fromFile = PStr.b().a(CLPathCfg.persistentDataPath).a("/").a(tmpUpgradePirorityPath).a("/").a(key).e();
|
||||
// toFile = PStr.begin().a(CLPathCfg.persistentDataPath).a("/").a(key).e();
|
||||
// FileEx.CreateDirectory(Path.GetDirectoryName(toFile));
|
||||
// File.Copy(fromFile, toFile, true);
|
||||
//}
|
||||
//Directory.Delete(PStr.b().a(CLPathCfg.persistentDataPath).a("/").a(tmpUpgradePirorityPath).e(), true);
|
||||
//keysList.Clear();
|
||||
//keysList = null;
|
||||
|
||||
//--同步优先资源更新的版本管理文件到本地
|
||||
//MemoryStream ms = new MemoryStream();
|
||||
//B2OutputStream.writeMap(ms, localPriorityVer);
|
||||
//string vpath = PStr.b().a(CLPathCfg.persistentDataPath).a("/").a(mVerPrioriPath).e();
|
||||
//FileEx.CreateDirectory(Path.GetDirectoryName(vpath));
|
||||
//File.WriteAllBytes(vpath, ms.ToArray());
|
||||
|
||||
//--同步总的版本管理文件到本地
|
||||
//ms = new MemoryStream();
|
||||
//B2OutputStream.writeMap(ms, localverVer);
|
||||
//vpath = PStr.b().a(CLPathCfg.persistentDataPath).a("/").a(mVerverPath).e();
|
||||
//FileEx.CreateDirectory(Path.GetDirectoryName(vpath));
|
||||
//File.WriteAllBytes(vpath, ms.ToArray());
|
||||
|
||||
loadOtherResVer(true);
|
||||
}
|
||||
}
|
||||
|
||||
static void loadPriorityVer()
|
||||
{
|
||||
localPriorityVer = serverPriorityVer;
|
||||
CLVerManager.self.localPriorityVer = localPriorityVer;
|
||||
}
|
||||
|
||||
static void loadOtherResVer(bool sucessProcUpgrade)
|
||||
{
|
||||
isSucessUpgraded = sucessProcUpgrade;
|
||||
otherResVerOld = otherResVerNew;
|
||||
Utl.doCallback(onFinishInit, isSucessUpgraded);
|
||||
}
|
||||
|
||||
static void initFailed(params object[] param)
|
||||
{
|
||||
if (progressCallback != null)
|
||||
{
|
||||
Utl.doCallback(progressCallback, needUpgradeVerver.Count, progress, null);
|
||||
}
|
||||
loadPriorityVer();
|
||||
loadOtherResVer(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3687bed0e966e4938bf295ca02f1cc1e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
688
Assets/CoolapeFrame/Scripts/resMgr/CLVerManager.cs
Normal file
688
Assets/CoolapeFrame/Scripts/resMgr/CLVerManager.cs
Normal file
@@ -0,0 +1,688 @@
|
||||
/*
|
||||
********************************************************************************
|
||||
*Copyright(C),coolae.net
|
||||
*Author: chenbin
|
||||
*Version: 2.0
|
||||
*Date: 2017-01-09
|
||||
*Description: 热更新处理(处理部分移到lua里了)
|
||||
*Others:
|
||||
*History:
|
||||
*********************************************************************************
|
||||
*/
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace Coolape
|
||||
{
|
||||
public class CLVerManager : CLBaseLua
|
||||
{
|
||||
public bool isPrintDownload = false;
|
||||
public int downLoadTimes4Failed = 3;
|
||||
//服务器
|
||||
public string baseUrl = "http://your hot fix url";
|
||||
[HideInInspector]
|
||||
public string platform = "";
|
||||
public static CLVerManager self;
|
||||
public static string resVer = "resVer";
|
||||
public static string versPath = "VerCtl";
|
||||
public const string fverVer = "VerCtl.ver";
|
||||
|
||||
//========================
|
||||
//本地所有版本的版本信息
|
||||
public const string verPriority = "priority.ver";
|
||||
public Hashtable localPriorityVer = new Hashtable();
|
||||
|
||||
//本地优先更新资源
|
||||
public const string verOthers = "other.ver";
|
||||
public Hashtable otherResVerOld = new Hashtable();
|
||||
|
||||
//所有资源的版本管理
|
||||
public Hashtable otherResVerNew = new Hashtable();
|
||||
//所有资源的版本管理
|
||||
|
||||
public bool haveUpgrade = false;
|
||||
public bool is2GNetUpgrade = false;
|
||||
public bool is3GNetUpgrade = true;
|
||||
public bool is4GNetUpgrade = true;
|
||||
[HideInInspector]
|
||||
public string mVerverPath = "";
|
||||
[HideInInspector]
|
||||
public string mVerPrioriPath = "";
|
||||
[HideInInspector]
|
||||
public string mVerOtherPath = "";
|
||||
|
||||
static string clientVersionPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(CLPathCfg.persistentDataPath, "ver.v"); //客户端版本
|
||||
}
|
||||
}
|
||||
|
||||
public CLVerManager()
|
||||
{
|
||||
self = this;
|
||||
}
|
||||
|
||||
public string clientVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(clientVersionPath))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return File.ReadAllText(clientVersionPath);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(clientVersionPath));
|
||||
File.WriteAllText(clientVersionPath, value);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 用文件来表示是否已经处理完资源从包里释放出来的状态
|
||||
static string hadPoc
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(CLPathCfg.persistentDataPath, "resPoced");
|
||||
}
|
||||
}
|
||||
|
||||
Callback onFinisInitStreaming;
|
||||
|
||||
/// <summary>
|
||||
/// Inits the streaming assets packge.
|
||||
/// 将流目录中优先需要加载的资源集解压到可读写目录
|
||||
/// </summary>
|
||||
/// <param name="onFinisInitStreaming">On finis init streaming.</param>
|
||||
public void initStreamingAssetsPackge(Callback onFinisInitStreaming)
|
||||
{
|
||||
this.onFinisInitStreaming = onFinisInitStreaming;
|
||||
// clean cache
|
||||
#if UNITY_EDITOR
|
||||
if (CLCfgBase.self.isEditMode)
|
||||
{
|
||||
onFinisInitStreaming();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
try
|
||||
{
|
||||
// 当版本不同时, clean cache
|
||||
if (string.Compare(Application.version, clientVersion) != 0)
|
||||
{
|
||||
string path = Application.persistentDataPath;
|
||||
// 先删掉目录下的文件
|
||||
string[] fEntries = Directory.GetFiles(path);
|
||||
foreach (string f in fEntries)
|
||||
{
|
||||
File.Delete(f);
|
||||
}
|
||||
// 再删掉所有文件夹
|
||||
string[] dirEntries = Directory.GetDirectories(path);
|
||||
foreach (string dir in dirEntries)
|
||||
{
|
||||
Directory.Delete(dir, true);
|
||||
}
|
||||
clientVersion = Application.version;
|
||||
}
|
||||
|
||||
// 处理资源释放
|
||||
if (!File.Exists(hadPoc))
|
||||
{
|
||||
string path = "priority.r";
|
||||
Callback cb = onGetStreamingAssets;
|
||||
StartCoroutine(FileEx.readNewAllBytesAsyn(path, cb));
|
||||
}
|
||||
else
|
||||
{
|
||||
onFinisInitStreaming();
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
onFinisInitStreaming();
|
||||
}
|
||||
}
|
||||
|
||||
// 取得"priority.r"
|
||||
void onGetStreamingAssets(params object[] para)
|
||||
{
|
||||
if (para != null && para.Length > 0)
|
||||
{
|
||||
byte[] buffer = (byte[])(para[0]);
|
||||
if (buffer != null)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.Write(buffer, 0, buffer.Length);
|
||||
ms.Position = 0;
|
||||
object obj = B2InputStream.readObject(ms);
|
||||
if (obj != null)
|
||||
{
|
||||
Hashtable map = (Hashtable)(obj);
|
||||
string path = "";
|
||||
foreach (DictionaryEntry cell in map)
|
||||
{
|
||||
try
|
||||
{
|
||||
path = CLPathCfg.persistentDataPath + "/" + cell.Key;
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
File.WriteAllBytes(path, (byte[])(cell.Value));
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
}
|
||||
}
|
||||
// 处理完包的资源释放,弄个标志
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(hadPoc));
|
||||
File.WriteAllText(hadPoc, "ok");
|
||||
}
|
||||
}
|
||||
}
|
||||
Utl.doCallback(onFinisInitStreaming);
|
||||
}
|
||||
|
||||
public Hashtable toMap(byte[] buffer)
|
||||
{
|
||||
Hashtable r = new Hashtable();
|
||||
if (buffer != null)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.Write(buffer, 0, buffer.Length);
|
||||
ms.Position = 0;
|
||||
object obj = B2InputStream.readObject(ms);
|
||||
if (obj != null && obj is Hashtable)
|
||||
{
|
||||
r = (Hashtable)obj;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = new Hashtable();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
r = new Hashtable();
|
||||
}
|
||||
return r;
|
||||
}
|
||||
//================================================================
|
||||
public static Hashtable wwwMap = Hashtable.Synchronized(new Hashtable());
|
||||
//public static Hashtable wwwTimesMap = new Hashtable();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the newest res.取得最新的资源
|
||||
/// </summary>
|
||||
/// <param name='path'>
|
||||
/// Path.资源的相对路径
|
||||
/// </param>
|
||||
/// <param name='type'>
|
||||
/// Type.资源的类型
|
||||
/// </param>
|
||||
/// <param name='onGetAsset'>
|
||||
/// On get asset.取得资源后的回调(回调信息中:
|
||||
/// 第一个参数是资源路径,
|
||||
/// 第二参数是资源的内容,
|
||||
/// 第三个参数传入的原样返回的参数)
|
||||
/// </param>
|
||||
/// <param name='originals'>
|
||||
/// Originals.原样返回的参数
|
||||
/// </param>
|
||||
public void getNewestRes4Lua(string path, CLAssetType type, object onGetAsset, bool autoRealseAB, object originals)
|
||||
{
|
||||
getNewestRes(path, type, onGetAsset, autoRealseAB, originals);
|
||||
}
|
||||
|
||||
public void getNewestRes(string path, CLAssetType type, object onGetAsset, bool autoRealseAB, params object[] originals)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string verVal = "";
|
||||
if (!MapEx.getBool(wwwMap, path))
|
||||
{
|
||||
string url = "";
|
||||
bool needSave = false;
|
||||
wwwMap[path] = true;
|
||||
|
||||
#if UNITY_WEBGL
|
||||
if (!CLCfgBase.self.isEditMode)
|
||||
{
|
||||
if (localPriorityVer[path] != null)
|
||||
{
|
||||
verVal = MapEx.getString(localPriorityVer, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
verVal = MapEx.getString(otherResVerNew, path);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(verVal))
|
||||
{
|
||||
url = PStr.begin().a(baseUrl).a("/").a(path).a(".").a(verVal).end();
|
||||
}
|
||||
else
|
||||
{
|
||||
url = PStr.begin().a(baseUrl).a("/").a(path).end();
|
||||
}
|
||||
doGetContent(path, url, needSave, type, onGetAsset, autoRealseAB, originals);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (localPriorityVer[path] != null)
|
||||
{
|
||||
//在优先资源里有
|
||||
needSave = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//则可能在others里
|
||||
object obj1 = otherResVerOld[path];
|
||||
object obj2 = otherResVerNew[path];
|
||||
if (obj1 == null && obj2 != null)
|
||||
{ //本地没有,最新有
|
||||
verVal = MapEx.getString(otherResVerNew, path);
|
||||
needSave = true;
|
||||
}
|
||||
else if (obj1 != null && obj2 != null)
|
||||
{
|
||||
if (obj1.ToString().Equals(obj2.ToString()))
|
||||
{//本地是最新的
|
||||
needSave = false;
|
||||
}
|
||||
else
|
||||
{ //本地不是最新的
|
||||
verVal = MapEx.getString(otherResVerNew, path);
|
||||
needSave = true;
|
||||
}
|
||||
}
|
||||
else if (obj1 != null && obj2 == null)
|
||||
{//本地有,最新没有
|
||||
needSave = false;
|
||||
}
|
||||
else
|
||||
{ //都没有找到
|
||||
needSave = false;
|
||||
#if UNITY_EDITOR
|
||||
// Debug.LogWarning ("Not found.path==" + path);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (needSave)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(verVal))
|
||||
{
|
||||
url = PStr.begin().a(baseUrl).a("/").a(path).a(".").a(verVal).end();
|
||||
}
|
||||
else
|
||||
{
|
||||
url = PStr.begin().a(baseUrl).a("/").a(path).end();
|
||||
}
|
||||
if (isPrintDownload)
|
||||
{
|
||||
Debug.LogWarning(url);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
url = PStr.begin().a(CLPathCfg.persistentDataPath).a("/").a(path).end();
|
||||
if (!File.Exists(url))
|
||||
{
|
||||
url = System.IO.Path.Combine(Application.streamingAssetsPath, path);
|
||||
#if !UNITY_ANDROID || UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
|
||||
#if UNITY_STANDALONE
|
||||
url = PStr.begin ().a ("file:///").a (url).end ();
|
||||
#else
|
||||
url = PStr.begin().a("file://").a(url).end();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_STANDALONE
|
||||
url = PStr.begin ().a ("file:///").a (url).end ();
|
||||
#else
|
||||
url = PStr.begin().a("file://").a(url).end();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
doGetContent(path, url, needSave, type, onGetAsset, autoRealseAB, originals);
|
||||
}
|
||||
}
|
||||
|
||||
void doGetContent(string path, string url, bool needSave,
|
||||
CLAssetType type, object onGetAsset, bool autoRealseAB, params object[] originals)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
getedResMap[path] = true;
|
||||
#endif
|
||||
if (url.StartsWith("http"))
|
||||
{
|
||||
url = url.Replace("+", "%2B");
|
||||
}
|
||||
|
||||
wwwMap[path] = true;
|
||||
|
||||
NewList transParam = ObjPool.listPool.borrowObject();
|
||||
transParam.Add(path);
|
||||
transParam.Add(url);
|
||||
transParam.Add(needSave);
|
||||
transParam.Add(type);
|
||||
transParam.Add(onGetAsset);
|
||||
transParam.Add(originals);
|
||||
transParam.Add(autoRealseAB);
|
||||
UnityWebRequest www = null;
|
||||
if (needSave)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Debug.LogWarning(url);
|
||||
#endif
|
||||
CLAssetType tmptype = type;
|
||||
if (type == CLAssetType.assetBundle)
|
||||
{
|
||||
//因为通过DownloadHandlerAssetBundle无法取得bytes,所以只能先改变取得数据类型,然后再通过AssetBundle.LoadFromMemory取得AssetBundle
|
||||
tmptype = CLAssetType.bytes;
|
||||
}
|
||||
www = WWWEx.get(url, tmptype, (Callback)onWWWBack, (Callback)onWWWBack, transParam, true, downLoadTimes4Failed);
|
||||
addWWW(www, path, url);
|
||||
}
|
||||
else
|
||||
{
|
||||
www = WWWEx.get(url, type, (Callback)onWWWBack, (Callback)onWWWBack, transParam, true);
|
||||
}
|
||||
}
|
||||
|
||||
void onWWWBack(params object[] parma)
|
||||
{
|
||||
try
|
||||
{
|
||||
object content = parma[0];
|
||||
NewList list = parma[1] as NewList;
|
||||
string path = list[0] as string;
|
||||
string url = list[1] as string;
|
||||
bool needSave = (bool)(list[2]);
|
||||
CLAssetType type = (CLAssetType)(list[3]);
|
||||
object onGetAsset = list[4];
|
||||
object[] originals = list[5] as object[];
|
||||
bool autoRealseAB = (bool)(list[6]);
|
||||
|
||||
UnityWebRequest www = null;
|
||||
if (parma.Length > 2)
|
||||
{
|
||||
www = parma[2] as UnityWebRequest;
|
||||
}
|
||||
|
||||
if (needSave && www != null && www.downloadHandler.data != null)
|
||||
{
|
||||
saveNewRes(path, www.downloadHandler.data);
|
||||
if (type == CLAssetType.assetBundle)
|
||||
{
|
||||
content = AssetBundle.LoadFromMemory(www.downloadHandler.data);
|
||||
}
|
||||
}
|
||||
onGetNewstRes(www, url, path, type, content, needSave, onGetAsset, autoRealseAB, originals);
|
||||
ObjPool.listPool.returnObject(list);
|
||||
list = null;
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void onGetNewstRes(UnityWebRequest www, string url, string path, CLAssetType type, object content, bool needSave, object onGetAsset, bool autoRealseAB, params object[] originals)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (needSave)
|
||||
{
|
||||
//说明是需要下载的资源
|
||||
//if (www != null && content == null && (MapEx.getInt(wwwTimesMap, path) + 1) < downLoadTimes4Failed)
|
||||
//{
|
||||
// //需要下载资源时,如查下载失败,且少于失败次数,则再次下载
|
||||
// wwwTimesMap[path] = MapEx.getInt(wwwTimesMap, path) + 1;
|
||||
// doGetContent(path, url, needSave, type, onGetAsset, autoRealseAB, originals);
|
||||
// return;
|
||||
//}
|
||||
rmWWW(url);
|
||||
}
|
||||
if (content == null)
|
||||
{
|
||||
Debug.LogError("get newstRes is null. url==" + url);
|
||||
}
|
||||
Utl.doCallback(onGetAsset, path, content, originals);
|
||||
|
||||
|
||||
if (autoRealseAB && content != null && type == CLAssetType.assetBundle)
|
||||
{
|
||||
AssetBundle ab = content as AssetBundle;
|
||||
if (ab != null)
|
||||
{
|
||||
ab.Unload(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e + "\n" + path);
|
||||
}
|
||||
|
||||
|
||||
if (www != null)
|
||||
{
|
||||
www.Dispose();
|
||||
www = null;
|
||||
}
|
||||
|
||||
wwwMap[path] = false;
|
||||
//wwwTimesMap[path] = 0;
|
||||
}
|
||||
|
||||
object addWWWcb;
|
||||
object rmWWWcb;
|
||||
|
||||
public void setWWWListner(object addWWWcb, object rmWWWcb)
|
||||
{
|
||||
this.addWWWcb = addWWWcb;
|
||||
this.rmWWWcb = rmWWWcb;
|
||||
}
|
||||
|
||||
public void addWWW(UnityWebRequest www, string path, string url)
|
||||
{
|
||||
Utl.doCallback(addWWWcb, www, path, url);
|
||||
}
|
||||
|
||||
public void rmWWW(string url)
|
||||
{
|
||||
Utl.doCallback(rmWWWcb, url);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the new res.保存最新取得的资源
|
||||
/// </summary>
|
||||
/// <param name='path'>
|
||||
/// Path.
|
||||
/// </param>
|
||||
/// <param name='content'>
|
||||
/// Content.
|
||||
/// </param>
|
||||
void saveNewRes(string path, byte[] content)
|
||||
{
|
||||
string file = PStr.begin().a(CLPathCfg.persistentDataPath).a("/").a(path).end();
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(file));
|
||||
File.WriteAllBytes(file, content);
|
||||
if (otherResVerNew[path] != null)
|
||||
{ //优先更新资源已经是最新的了,所以不用再同步
|
||||
otherResVerOld[path] = otherResVerNew[path];
|
||||
MemoryStream ms = new MemoryStream();
|
||||
B2OutputStream.writeMap(ms, otherResVerOld);
|
||||
|
||||
string vpath = PStr.begin().a(CLPathCfg.persistentDataPath).a("/").a(mVerOtherPath).end();
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(vpath));
|
||||
File.WriteAllBytes(vpath, ms.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public Texture getAtalsTexture4Edit(string path)
|
||||
{
|
||||
string url = "";
|
||||
#if UNITY_EDITOR
|
||||
url = "file://" + Application.dataPath + "/" + path;
|
||||
#endif
|
||||
WWW www = new WWW(Utl.urlAddTimes(url));
|
||||
while (!www.isDone)
|
||||
{
|
||||
// new WaitForSeconds (0.05f);
|
||||
System.Threading.Thread.Sleep(50); //比较hacker的做法
|
||||
}
|
||||
if (string.IsNullOrEmpty(www.error))
|
||||
{
|
||||
Texture texture = www.texture;
|
||||
www.Dispose();
|
||||
www = null;
|
||||
return texture;
|
||||
}
|
||||
else
|
||||
{
|
||||
www.Dispose();
|
||||
www = null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool checkNeedDownload(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool ret = false;
|
||||
if (localPriorityVer[path] != null)
|
||||
{ //在优先资源里有
|
||||
ret = false;
|
||||
}
|
||||
else
|
||||
{ //则可能在others里
|
||||
object obj1 = otherResVerOld[path];
|
||||
object obj2 = otherResVerNew[path];
|
||||
if (obj1 == null && obj2 != null)
|
||||
{ //本地没有,最新有
|
||||
ret = true;
|
||||
}
|
||||
else if (obj1 != null && obj2 != null)
|
||||
{
|
||||
if (NumEx.stringToInt(obj1.ToString()) >= NumEx.stringToInt(obj2.ToString()))
|
||||
{//本地是最新的
|
||||
ret = false;
|
||||
}
|
||||
else
|
||||
{ //本地不是最新的
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
else if (obj1 != null && obj2 == null)
|
||||
{//本地有,最新没有
|
||||
ret = false;
|
||||
}
|
||||
else
|
||||
{ //都没有找到
|
||||
// NAlertTxt.add("Cannot Found the res. Path= \n"+ path, Color.red, 1);
|
||||
Debug.LogError("Cannot Found the res. Path= \n" + path);
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
// if (ret) {
|
||||
// if (!Utl.netIsActived ()) {
|
||||
// NAlertTxt.add (Localization.Get ("MsgNetWorkCannotReached"), Color.red, 1);
|
||||
// reLoadGame ();
|
||||
// }
|
||||
// }
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ises the ver newest.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The ver newest.
|
||||
/// </returns>
|
||||
/// <param name='path'>
|
||||
/// If set to <c>true</c> path.
|
||||
/// </param>
|
||||
/// <param name='ver'>
|
||||
/// If set to <c>true</c> ver.
|
||||
/// </param>
|
||||
public bool isVerNewest(string path, string ver)
|
||||
{
|
||||
object newVer = localPriorityVer[path];
|
||||
if (newVer != null)
|
||||
{ //在优先资源里有
|
||||
if (!ver.Equals(newVer.ToString()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{ //则可能在others里
|
||||
newVer = otherResVerNew[path];
|
||||
if (newVer != null)
|
||||
{
|
||||
if (!ver.Equals(newVer.ToString()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Hashtable getedResMap = new Hashtable();
|
||||
|
||||
[ContextMenu("save loaded assets(with out priority assets)")]
|
||||
public void getCurrentRes()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
string str = "";
|
||||
foreach (DictionaryEntry cell in getedResMap)
|
||||
{
|
||||
str += cell.Key + "," + "true" + "\n";
|
||||
}
|
||||
Debug.LogError(str);
|
||||
string path = EditorUtility.SaveFilePanelInProject("save loaded assets(with out priority assets)", "newAssetsInfor", "v", "");
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
File.WriteAllText(path, str);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
12
Assets/CoolapeFrame/Scripts/resMgr/CLVerManager.cs.meta
Normal file
12
Assets/CoolapeFrame/Scripts/resMgr/CLVerManager.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eae7e7bfc540d494795c77cf1420f4a9
|
||||
timeCreated: 1483978281
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user