public static void InitUpdate()
{
string prodVersion = ExporterWindow.exportationOptions.ProductionVersion.ToString();
if (prodVersion.IndexOf(".", StringComparison.OrdinalIgnoreCase) < 0)
{
prodVersion += ".0";
}
string updateMsg = (exportationOptions.DefaultUpdateOptions == (int)BabylonUpdateOptions.PreviewRelease) ? "Are you sure you want to update libraries using the github preview release version?" : "Are you sure you want to update libraries using the github stable release version " + prodVersion + "?";
if (ExporterWindow.ShowMessage(updateMsg, "Babylon.js", "Update"))
{
EditorUtility.DisplayProgressBar("Babylon.js", "Updating github editor toolkit library files...", 1);
string libPath = Path.Combine(Application.dataPath, "Babylon/Library/");
string bjsPath = (exportationOptions.DefaultUpdateOptions == (int)BabylonUpdateOptions.PreviewRelease) ? "https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/preview%20release/babylon.js" : "https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/babylon." + prodVersion + ".js";
string bjsTsPath = (exportationOptions.DefaultUpdateOptions == (int)BabylonUpdateOptions.PreviewRelease) ? "https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/preview%20release/babylon.d.ts" : "https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/babylon." + prodVersion + ".d.ts";
string c2dPath = (exportationOptions.DefaultUpdateOptions == (int)BabylonUpdateOptions.PreviewRelease) ? "https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/preview%20release/canvas2D/babylon.canvas2d.js" : "https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/babylon." + prodVersion + ".canvas2d.js";
string c2dTsPath = (exportationOptions.DefaultUpdateOptions == (int)BabylonUpdateOptions.PreviewRelease) ? "https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/preview%20release/canvas2D/babylon.canvas2d.d.ts" : "https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/babylon." + prodVersion + ".canvas2d.d.ts";
string cannonPath = (exportationOptions.DefaultUpdateOptions == (int)BabylonUpdateOptions.PreviewRelease) ? "https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/preview%20release/cannon.js" : "https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/cannon.js";
string oimoPath = (exportationOptions.DefaultUpdateOptions == (int)BabylonUpdateOptions.PreviewRelease) ? "https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/preview%20release/Oimo.js" : "https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/Oimo.js";
try
{
EditorUtility.DisplayProgressBar("Babylon.js", "Updating babylon.bjs...", 0.10f);
Tools.DownloadFile(bjsPath, Path.Combine(libPath, "babylon.bjs"));
EditorUtility.DisplayProgressBar("Babylon.js", "Updating babylon.d.ts...", 0.20f);
Tools.DownloadFile(bjsTsPath, Path.Combine(libPath, "babylon.d.ts"));
EditorUtility.DisplayProgressBar("Babylon.js", "Updating canvas2d.bjs...", 0.30f);
Tools.DownloadFile(c2dPath, Path.Combine(libPath, "canvas2d.bjs"));
EditorUtility.DisplayProgressBar("Babylon.js", "Updating canvas2d.d.ts...", 0.40f);
Tools.DownloadFile(c2dTsPath, Path.Combine(libPath, "canvas2d.d.ts"));
EditorUtility.DisplayProgressBar("Babylon.js", "Updating cannon.bjs...", 0.50f);
Tools.DownloadFile(cannonPath, Path.Combine(libPath, "cannon.bjs"));
EditorUtility.DisplayProgressBar("Babylon.js", "Updating oimo.bjs...", 0.60f);
Tools.DownloadFile(oimoPath, Path.Combine(libPath, "oimo.bjs"));
EditorUtility.DisplayProgressBar("Babylon.js", "Updating navmesh.bjs...", 0.70f);
Tools.DownloadFile("https://raw.githubusercontent.com/BabylonJS/Extensions/master/SceneManager/dist/babylon.navigation.mesh.js", Path.Combine(libPath, "navmesh.bjs"));
EditorUtility.DisplayProgressBar("Babylon.js", "Updating manager.bjs...", 0.80f);
Tools.DownloadFile("https://raw.githubusercontent.com/BabylonJS/Extensions/master/SceneManager/dist/babylon.scenemanager.js", Path.Combine(libPath, "manager.bjs"));
EditorUtility.DisplayProgressBar("Babylon.js", "Updating manager.d.ts...", 0.90f);
Tools.DownloadFile("https://raw.githubusercontent.com/BabylonJS/Extensions/master/SceneManager/dist/babylon.scenemanager.d.ts", Path.Combine(libPath, "manager.d.ts"));
}
catch (System.Exception ex)
{
UnityEngine.Debug.LogException(ex);
}
finally
{
EditorUtility.DisplayProgressBar("Babylon.js", "Refresing assets database...", 1.0f);
AssetDatabase.Refresh();
EditorUtility.ClearProgressBar();
}
}
}