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); } } }
public void Init(IPopup popup, Dictionary <string, object> orientation, List <Texture> textures, BackgroundLayer content, int depth) { _popup = popup; _depth = depth; object buttonsObj; if (orientation.TryGetValue("buttons", out buttonsObj)) { var buttons = buttonsObj as List <object>; for (int i = 0; i < buttons.Count; ++i) { var button = buttons[i] as Dictionary <string, object>; float left = 0, top = 0; object x, y; if (button.TryGetValue("x", out x)) { left = (int)((long)x) * content.Scale + content.Position.xMin; } if (button.TryGetValue("y", out y)) { top = (int)((long)y) * content.Scale + content.Position.yMin; } _positions.Add(new Rect(left, top, textures[i].width * content.Scale, textures[i].height * content.Scale)); object actionObj; if (button.TryGetValue("action", out actionObj)) { RegisterAction((Dictionary <string, object>)actionObj, "button" + (i + 1)); } else { RegisterAction(); } } _textures = textures; } }