/// <summary>Called when the given character was not found in the font.</summary>
        /// <param name="glyph">The character to try and find an alternate image for.</param.
        public ImagePackage Load(Glyph glyph, int charcode)
        {
            string path = GetPath(charcode);

            if (string.IsNullOrEmpty(path))
            {
                return(null);
            }

            // Create an image package and request for the graphic. Convert it to lowercase hex to match standard filenames:
            ImagePackage package = new ImagePackage(path, null);

            // Go get it, calling ImageReady when it's been retrieved (we only care about success here).
            package.onload = delegate(UIEvent e){
                // Tell it about the success:
                glyph.SetupImage(package);
            };

            package.send();

            return(package);
        }
Example #2
0
        public override bool OnAttributeChange(string property)
        {
            if (base.OnAttributeChange(property))
            {
                return(true);
            }

            if (property == "path")
            {
                // Go get the camera now!

                // Clear any existing one:
                Camera = null;

                Callback.MainThread(delegate(){
                    // Grab the path itself:
                    string path = this["path"];

                    // Get it:
                    GameObject gameObject = GameObject.Find(path);

                    if (gameObject != null)
                    {
                        // Grab the camera:
                        Camera = gameObject.GetComponent <Camera>();
                    }

                    if (Camera != null)
                    {
                        ComputedStyle computed = Style.Computed;

                        // Create RT if one is needed:
                        RenderTexture rt = Camera.targetTexture;

                        if (rt == null)
                        {
                            // Apply:
                            ApplyNewRenderTexture((int)computed.InnerWidth, (int)computed.InnerHeight);
                        }
                        else
                        {
                            // Apply to background:
                            image = rt;
                        }
                    }

                    ParentMask();
                });

                return(true);
            }
            else if (property == "noresize")
            {
                // Can't resize if noresize is not null:
                CanResize = (this["noresize"] == null);
            }
            else if (property == "mask")
            {
                // We've got a mask!

                // Grab the file path:
                string maskFile = this["mask"];

                if (maskFile == null)
                {
                    SetMask(null);
                }
                else
                {
                    // Create a package to get the mask:
                    ImagePackage package = new ImagePackage(maskFile, document.basepath);

                    package.onload = delegate(UIEvent e){
                        // Apply the mask:
                        PictureFormat pict = package.Contents as PictureFormat;

                        if (pict != null)
                        {
                            SetMask(pict.Image);
                        }
                    };

                    // Go get it:
                    package.send();
                }

                return(true);
            }

            return(false);
        }