private void Run(BuildTarget target)
{
try {
ResetNodeExceptionPool();
if (!SaveData.IsSaveDataAvailableAtDisk()) {
SaveData.RecreateDataOnDisk();
Debug.Log("AssetBundleGraph save data not found. Creating from scratch...");
return;
}
// load data from file.
SaveData saveData = SaveData.LoadFromDisk();
List<NodeGUI> currentNodes = null;
List<ConnectionGUI> currentConnections = null;
ConstructGraphFromSaveData(saveData, out currentNodes, out currentConnections);
var currentCount = 0.00f;
var totalCount = currentNodes.Count * 1f;
Action<NodeData, float> updateHandler = (node, progress) => {
var progressPercentage = ((currentCount/totalCount) * 100).ToString();
if (progressPercentage.Contains(".")) progressPercentage = progressPercentage.Split('.')[0];
if (0 < progress) {
currentCount = currentCount + 1f;
}
EditorUtility.DisplayProgressBar("AssetBundleGraph Processing... ", "Processing " + node.Name + ": " + progressPercentage + "%", currentCount/totalCount);
};
Action<NodeException> errorHandler = (NodeException e) => {
AssetBundleGraphEditorWindow.AddNodeException(e);
};
// perform setup. Fails if any exception raises.
s_assetStreamMap = AssetBundleGraphController.Perform(saveData, target, false, errorHandler, null);
// if there is not error reported, then run
if(s_nodeExceptionPool.Count == 0) {
// run datas.
s_assetStreamMap = AssetBundleGraphController.Perform(saveData, target, true, errorHandler, updateHandler);
}
RefreshInspector(s_assetStreamMap);
AssetDatabase.Refresh();
ShowErrorOnNodes();
AssetBundleGraphController.Postprocess(saveData, s_assetStreamMap, true);
} catch(Exception e) {
Debug.LogError(e);
} finally {
EditorUtility.ClearProgressBar();
}
}