Question by
oulino · Mar 01, 2017 at 04:16 AM ·
unity5debuggingupdate problemmigration
How do I i fix error CS0619?
After migrating from unity 4.6 to 5.0 i am getting this error :
Assets/Scripts/Resource/LoadProcess.cs(121,96): error CS0619: `UnityEngine.AssetBundle.Load(string)' is obsolete: `Method Load has been deprecated. Script updater cannot update it as the loading behaviour has changed. Please use LoadAsset instead and check the documentation for details.'
is there any way to fix it please ?
my code from LoadProcess.cs :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace BlGame.Resource
{
public class LoadProcess
{
public static int aSyncLoadCount = 4;
public string SceneRes;
public bool isLoading = false;
//private int curLoadCount;
public int curLoadCount
{
get
{
return ResourceManager.Instance.getLoadCount();
}
}
public Dictionary<string, LogicLoadRequest> logicReqDic = new Dictionary<string, LogicLoadRequest>();
public Dictionary<string, PhyLoadRequest> phyReqDic = new Dictionary<string, PhyLoadRequest>();
public float curProgress
{
get;
set;
}
public bool isDone = false;
public int fileCount
{
get;
set;
}
public int doneFileCount
{
get;
set;
}
public int filesSize
{
get;
set;
}
public int doneFilesSize
{
get;
set;
}
public void Start()
{
isLoading = true;
logicReqDic.Clear();
phyReqDic.Clear();
isDone = false;
}
public void Stop()
{
}
public void End()
{
isLoading = false;
}
private bool isAllLogicComplete()
{
foreach (LogicLoadRequest r in logicReqDic.Values)
{
LogicResouce res = ResourceManager.Instance.GetLogicRes(r.resPath);
if (res == null)
{
return false;
}
}
return true;
}
private bool isAllLogicRootComplete()
{
foreach (LogicLoadRequest r in logicReqDic.Values)
{
PhyResouce res = ResourceManager.Instance.GetPhyRes(r.resPath);
if (res == null)
{
return false;
}
}
return true;
}
public void Update()
{
if (isAllLogicRootComplete() == false)
{
foreach (LogicLoadRequest logicLoadReq in logicReqDic.Values)
{
if (curLoadCount < aSyncLoadCount)
{
if (ResourceManager.Instance.GetLogicRes(logicLoadReq.resPath) != null)
{
logicLoadReq.status = LogicLoadRequest.LOADSTATUS.END;
}
else
{
if (logicLoadReq.status == LogicLoadRequest.LOADSTATUS.WAIT)
{
ResourceManager.Instance.LoadImpl(logicLoadReq.resPath, LogicResouce.getRootResType(logicLoadReq.resType),
(path) =>
{
AssetBundle ab = ResourceManager.Instance.GetPhyRes(path).assetBundle;
StringScriptableObject holder = (StringScriptableObject)ab.Load("DependentBundleNames");
LogicResourceBuilder logicBuilder = new LogicResourceBuilder();
logicBuilder.resPath = logicLoadReq.resPath;
logicBuilder.logicResType = logicLoadReq.resType;
if (holder != null)
{
if (holder.content != null)
{
foreach (string s in holder.content)
{
// GameDefine.GameMethod.DebugError("got dependency:" + s);
AddPhyFile(s, PhyResouce.EPhyResType.EPhyResPrefab);
logicBuilder.resLists.Add(s);
}
}
}
ResourceManager.Instance.AddLogicResourceBuilder(logicBuilder);
});
logicLoadReq.status = LogicLoadRequest.LOADSTATUS.START;
}
}
}
}
}
else
{
foreach (PhyLoadRequest phyLoadReq in phyReqDic.Values)
{
if (curLoadCount < aSyncLoadCount)
{
ResourceManager.Instance.LoadImpl(phyLoadReq.resPath, phyLoadReq.resType);
}
}
}
UpdateProgress();
}
private void UpdateProgress()
{
if (isDone == true)
{
return;
}
float logicPercent = 0.15f;
float phyPercent = 0.85f;
float logicReqNum = logicReqDic.Count;
float phyReqNum = phyReqDic.Count;
curProgress = 0.0f;
if (logicReqDic.Count == 0)
{
curProgress += 0.15f;
}
else
{
foreach (LogicLoadRequest lr in logicReqDic.Values)
{
curProgress += (logicPercent * getFileDownloadPercent(lr.resPath) / logicReqNum);
}
}
if (phyReqDic.Count == 0 && isAllLogicRootComplete() == true)
{
curProgress += 0.85f;
}
else
{
foreach (PhyLoadRequest pr in phyReqDic.Values)
{
curProgress += (phyPercent * getFileDownloadPercent(pr.resPath) / phyReqNum);
}
}
isDone = isAllLogicComplete();
if (isDone == true)
{
OnSceneLoadComplete();
Stop();
}
}
private void OnSceneLoadComplete()
{
LogicResouce lRes = ResourceManager.Instance.GetLogicRes(SceneRes);
//LogicResourceBuilder builder = null;
LightmapSettings.lightmapsMode = LightmapsMode.NonDirectional;
LightmapSettings.lightmapsMode = LightmapsMode.NonDirectional;
Dictionary<int, Texture2D> lightMapDic = new Dictionary<int, Texture2D>();
foreach (string s in lRes.phyResList)
{
if (s.Contains("LightmapFar"))
{
string[] strs = s.Split(new char[] { '-', '.' });
if (strs != null && strs.Length > 0)
{
int index = Int32.Parse(strs[strs.Length - 2]);//strs[Length - 1];
if (lightMapDic.ContainsKey(index))
{
}
else
{
lightMapDic.Add(index, ResourceManager.Instance.GetPhyRes(s).getTexture());
}
}
}
if (s.Contains("LightProbe"))
{
PhyResouce probe = ResourceManager.Instance.GetPhyRes(s);
if (probe != null)
{
LightProbes probes = (LightProbes)probe.assetBundle.mainAsset;
LightmapSettings.lightProbes = probes;
}
}
}
LightmapData[] ldarr = new LightmapData[lightMapDic.Count];
foreach (KeyValuePair<int, Texture2D> kv in lightMapDic)
{
LightmapData ld = new LightmapData();
ld.lightmapFar = kv.Value;
ldarr[kv.Key] = ld;
}
LightmapSettings.lightmaps = ldarr;
PhyResouce res = ResourceManager.Instance.GetPhyRes(SceneRes);
UnityEngine.Object obj = res.assetBundle.mainAsset;
GameObject.Instantiate(obj);
}
private float getFileDownloadPercent(string path)
{
if (ResourceManager.Instance.GetPhyRes(path) != null)
{
return 1.0f;
}
LoadImplement impl = ResourceManager.Instance.getLoadImplement(path);
if (impl == null)
{
return 0.0f;
}
return impl.www.progress;
}
private void OnLogicRootLoaded(string path)
{
//
}
public void AddLogicFile(string logicFile, LogicResouce.ELogicResType logicResType)
{
//if (ResourceManager.Instance.GetLogicRes(logicFile) != null)
//{
// return;
//}
if (logicReqDic.ContainsKey(logicFile) == true)
{
return;
}
//
LogicLoadRequest loadReq = new LogicLoadRequest();
loadReq.resPath = logicFile;
loadReq.resType = logicResType;
logicReqDic.Add(logicFile, loadReq);
//
}
public void AddPhyFile(string phyFile, PhyResouce.EPhyResType phyResType)
{
if (ResourceManager.Instance.GetPhyRes(phyFile) != null)
{
return;
}
if (phyReqDic.ContainsKey(phyFile) == true)
{
return;
}
PhyLoadRequest loadReq = new PhyLoadRequest();
loadReq.resPath = phyFile;
loadReq.resType = phyResType;
phyReqDic.Add(phyFile, loadReq);
}
}
public class LogicLoadRequest
{
public string resPath;
public LogicResouce.ELogicResType resType;
public enum LOADSTATUS
{
WAIT,
START,
END,
}
//
public LOADSTATUS status = LOADSTATUS.WAIT;
//
}
public class PhyLoadRequest
{
public string resPath;
public PhyResouce.EPhyResType resType;
}
}
thank you for your help people !
Comment