コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
        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);
                }
            }
        }