Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Commit

Permalink
Fixed loading screen generation when using a Unity editor texture (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamcohen authored Oct 23, 2018
1 parent e978480 commit 7c17059
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions GooglePlayInstant/Editor/QuickDeploy/LoadingScreenGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ private static Vector2 GetPreImportTextureDimensions(Texture2D texture)
throw new ArgumentException("The provided texture must be associated with an asset");
}

// If the asset path isn't accessible, we default to using the texture's dimensions
// This occurs if the provided texture is included with the Unity Editor.
if (!File.Exists(texturePath))
{
return new Vector2(texture.width, texture.height);
}

// Load the image from disk then return its width and height.
var imageBytes = File.ReadAllBytes(texturePath);
var tempTexture = new Texture2D(1, 1);
Expand All @@ -248,12 +255,12 @@ public static T FindAssetByFilter<T>(string searchFilter) where T : UnityEngine.

if (foundGuids.Length == 0)
{
throw new Exception("Failed to find any assets that match: "+searchFilter);
throw new Exception("Failed to find any assets that match: " + searchFilter);
}

if (foundGuids.Length > 1)
{
throw new Exception("Found multiple assets that match: "+searchFilter);
throw new Exception("Found multiple assets that match: " + searchFilter);
}

string path = AssetDatabase.GUIDToAssetPath(foundGuids[0]);
Expand Down

0 comments on commit 7c17059

Please sign in to comment.