- Home /
Why does asset import fail?
I'm trying to download and import a package from a menu item using the following:
string remotePackagePath = "http://path/to/package/package.unitypackage";
string localPackageDir = Path.Combine(RootDir, "Packages");
string localPackagePath = Path.Combine(localPackageDir, "package.unitypackage");
if(!Directory.Exists(localPackageDir))
Directory.CreateDirectory(localPackageDir);
using(WebClient client = new WebClient())
{
client.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes("user:pass")));
client.DownloadFile(new Uri(remotePackagePath), localPackagePath);
}
AssetDatabase.ImportPackage(localPackagePath, true);
It works fine on Mac, but on Windows I get an error: "Package has unknown format." However, if I manually import the dowloaded package, it imports fine. The package I'm trying to import was exported on a Mac.
What's going on?
Not trivially as some of the assets are generated by scripts.
Hmm... Is there any specific reason to compile on $$anonymous$$ac other than the scripts?
Our OS of choice is $$anonymous$$acOS, but the some of the artists need to work on Windows. The aim of the package export/import is to avoid having to rewrite a load of scripts just so they can get the game running for rapid iteration.
So, apart from the scripts, no, but the scripts are the only reason we're doing it at all.
Your answer
Follow this Question
Related Questions
EditorSceneManager.OpenScene fails after AssetDatabase.Refresh 1 Answer
Strange crash on package import 1 Answer
[SOLVED]Firebase Remote Config and Facebook Audience Network SDK conflict 1 Answer
Importing assets breaks my game 1 Answer
How to add and remove installed packages more easily? E.g. Google Admob. Package control in Unity? 0 Answers