Skip to content

Commit

Permalink
Add error handling for loading background image for a story scene
Browse files Browse the repository at this point in the history
  • Loading branch information
jakory committed Jun 29, 2017
1 parent 7985d02 commit 68e372d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sar-opal-base/Assets/scripts/MainGameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,15 @@ public void SetupSocialStoryScene(int numScenes, bool scenesInOrder, int numAnsw

// Load background image.
Logger.Log ("Loading background");
Sprite bk = Resources.Load<Sprite>(Constants.GRAPHICS_FILE_PATH + "SSBackground");
Sprite bk;
try {
bk = Resources.Load<Sprite>(Constants.GRAPHICS_FILE_PATH + "SSBackground");
}
catch (NullReferenceException e) {
Logger.LogError("Could not find background graphic! Tried to load: " +
Constants.GRAPHICS_FILE_PATH + "SSBackground");
}

BackgroundObjectProperties bops = new BackgroundObjectProperties(
"SSBackground", Constants.TAG_BACKGROUND,
// Scale background to size of camera view.
Expand All @@ -1585,6 +1593,7 @@ public void SetupSocialStoryScene(int numScenes, bool scenesInOrder, int numAnsw
(float)(this.scaleToHeight ? Camera.main.pixelHeight / bk.bounds.size.y
: Camera.main.pixelWidth / bk.bounds.size.x))));
this.InstantiateBackground(bops, bk);


// We need to scale the scene and answer slots to evenly fit in the
// screen. We'll use the background image in place of the actual
Expand Down

0 comments on commit 68e372d

Please sign in to comment.