Skip to content
Permalink
Browse files

[Assets] Perform null check before upgrading PackageProfile

  • Loading branch information
xen2 committed Jan 27, 2019
1 parent 7144d61 commit c5164c5939a0ec7b1edf79d231b2107cf130f998
Showing with 15 additions and 9 deletions.
  1. +15 −9 sources/assets/Xenko.Core.Assets/Package.cs
@@ -1266,25 +1266,31 @@ protected override void UpgradeAsset(AssetMigrationContext context, PackageVersi
{
if (profile.Platform == "Shared")
{
if (profile.ProjectReferences.Count == 1)
if (profile.ProjectReferences != null && profile.ProjectReferences.Count == 1)
{
var projectLocation = (UFile)(string)profile.ProjectReferences[0].Location;
assetFile.FilePath = UPath.Combine(assetFile.OriginalFilePath.GetFullDirectory(), (UFile)(projectLocation.GetFullPathWithoutExtension() + PackageFileExtension));
asset.Meta.Name = projectLocation.GetFileNameWithoutExtension();
}

for (int i = 0; i < profile.AssetFolders.Count; ++i)
if (profile.AssetFolders != null)
{
var assetPath = UPath.Combine(assetFile.OriginalFilePath.GetFullDirectory(), (UDirectory)(string)profile.AssetFolders[i].Path);
assetPath = assetPath.MakeRelative(assetFile.FilePath.GetFullDirectory());
profile.AssetFolders[i].Path = (string)assetPath;
for (int i = 0; i < profile.AssetFolders.Count; ++i)
{
var assetPath = UPath.Combine(assetFile.OriginalFilePath.GetFullDirectory(), (UDirectory)(string)profile.AssetFolders[i].Path);
assetPath = assetPath.MakeRelative(assetFile.FilePath.GetFullDirectory());
profile.AssetFolders[i].Path = (string)assetPath;
}
}

for (int i = 0; i < profile.ResourceFolders.Count; ++i)
if (profile.ResourceFolders != null)
{
var resourcePath = UPath.Combine(assetFile.OriginalFilePath.GetFullDirectory(), (UDirectory)(string)profile.ResourceFolders[i]);
resourcePath = resourcePath.MakeRelative(assetFile.FilePath.GetFullDirectory());
profile.ResourceFolders[i] = (string)resourcePath;
for (int i = 0; i < profile.ResourceFolders.Count; ++i)
{
var resourcePath = UPath.Combine(assetFile.OriginalFilePath.GetFullDirectory(), (UDirectory)(string)profile.ResourceFolders[i]);
resourcePath = resourcePath.MakeRelative(assetFile.FilePath.GetFullDirectory());
profile.ResourceFolders[i] = (string)resourcePath;
}
}

asset.AssetFolders = profile.AssetFolders;

0 comments on commit c5164c5

Please sign in to comment.
You can’t perform that action at this time.