From 68e372d5482625560f619bbc7a0465bcce7cd8d2 Mon Sep 17 00:00:00 2001 From: jakory Date: Tue, 20 Jun 2017 15:27:39 -0400 Subject: [PATCH] Add error handling for loading background image for a story scene --- sar-opal-base/Assets/scripts/MainGameController.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sar-opal-base/Assets/scripts/MainGameController.cs b/sar-opal-base/Assets/scripts/MainGameController.cs index 8c1132a..3264db4 100644 --- a/sar-opal-base/Assets/scripts/MainGameController.cs +++ b/sar-opal-base/Assets/scripts/MainGameController.cs @@ -1573,7 +1573,15 @@ public void SetupSocialStoryScene(int numScenes, bool scenesInOrder, int numAnsw // Load background image. Logger.Log ("Loading background"); - Sprite bk = Resources.Load(Constants.GRAPHICS_FILE_PATH + "SSBackground"); + Sprite bk; + try { + bk = Resources.Load(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. @@ -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