public void Show() { if (this.resourcesLoaded) { try { if (this.configuration.ContainsKey("shim")) { ShimLayer shimLayer = this.gameObject.AddComponent <ShimLayer>(); shimLayer.Build(this, this.configuration["shim"] as JSONObject, this.depth); } JSONObject layout = this.configuration["layout"] as JSONObject; object orientation; if (!layout.TryGetValue("landscape", out orientation) && !layout.TryGetValue("portrait", out orientation)) { throw new KeyNotFoundException("Layout missing orientation key."); } BackgroundLayer backgroundLayer = this.gameObject.AddComponent <BackgroundLayer>(); backgroundLayer.Build(this, orientation as JSONObject, this.spriteMap.Background, this.depth - 1); ButtonsLayer buttonLayer = this.gameObject.AddComponent <ButtonsLayer>(); buttonLayer.Build(this, orientation as JSONObject, this.spriteMap.Buttons, backgroundLayer, this.depth - 2); this.showing = true; } catch (KeyNotFoundException exception) { Logger.LogWarning("Failed to show image message, invalid format: " + exception.Message); } catch (Exception exception) { Logger.LogWarning("Failed to show image message: " + exception.Message); } } }
public void Show() { if (IsReady()) { try{ if (spriteMap.Texture == null) { /* * This is a workaround for when we're showing for an * event trigger, as the instance didn't go through the * FetchResources() call to load the texture we need to * do it now. */ spriteMap.LoadResource(e => { }); } Canvas messageCanvas = gameObject.AddComponent <Canvas>(); messageCanvas.renderMode = RenderMode.ScreenSpaceOverlay; messageCanvas.sortingOrder = 32767; gameObject.AddComponent <GraphicRaycaster>(); if (this.configuration.ContainsKey("shim")) { ShimLayer shimLayer = gameObject.AddComponent <ShimLayer>(); shimLayer.Build(ddna, gameObject, this, this.configuration["shim"] as JSONObject, this.depth); } JSONObject layout = configuration["layout"] as JSONObject; object orientation; if (!layout.TryGetValue("landscape", out orientation) && !layout.TryGetValue("portrait", out orientation)) { throw new KeyNotFoundException("Layout missing orientation key."); } BackgroundLayer backgroundLayer = gameObject.AddComponent <BackgroundLayer>(); backgroundLayer.Build(ddna, gameObject, this, orientation as JSONObject, spriteMap.Background, depth - 1); ButtonsLayer buttonLayer = gameObject.AddComponent <ButtonsLayer>(); buttonLayer.Build(ddna, gameObject, this, orientation as JSONObject, spriteMap.Buttons, backgroundLayer, depth - 2); showing = true; } catch (KeyNotFoundException exception) { Logger.LogWarning("Failed to show image message, invalid format: " + exception.Message); } catch (Exception exception) { Logger.LogWarning("Failed to show image message: " + exception.Message); } } }
public void Show() { if (IsReady) { try { if (BeforeShow != null) { BeforeShow(this, new EventArgs()); } object shimDictObj; if (Configuration.TryGetValue("shim", out shimDictObj)) { var shimDict = shimDictObj as Dictionary <string, object>; ShimLayer shim = _gameObject.AddComponent <ShimLayer>(); shim.Init(this, shimDict, _depth); } object layoutDictObj; if (Configuration.TryGetValue("layout", out layoutDictObj)) { var layoutDict = layoutDictObj as Dictionary <string, object>; object orientationDictObj; if ((layoutDict).TryGetValue("landscape", out orientationDictObj) || (layoutDict).TryGetValue("portrait", out orientationDictObj)) { var orientationDict = orientationDictObj as Dictionary <string, object>; BackgroundLayer background = _gameObject.AddComponent <BackgroundLayer>(); background.Init(this, orientationDict, _spritemap.GetBackground(), _depth - 1); ButtonsLayer buttons = _gameObject.AddComponent <ButtonsLayer>(); buttons.Init(this, orientationDict, _spritemap.GetButtons(), background, _depth - 2); IsShowing = true; } else { Logger.LogError("No layout orientation found."); } } else { Logger.LogError("No layout found."); } } catch (Exception ex) { Logger.LogError("Showing popup failed: " + ex.Message); } } }