Example #1
0
        public static IEnumerator LoadImages()
        {
            var dbase     = GameDatabase.Instance;
            var node_list = dbase.GetConfigNodes("KodeUI_Image");

            for (int i = 0; i < node_list.Length; i++)
            {
                var    node = node_list[i];
                string name = node.GetValue("name");
                if (String.IsNullOrEmpty(name))
                {
                    Debug.Log("[KodeUI.ImageLoader] skipping unnamed image");
                    continue;
                }

                string sprite = node.GetValue("sprite");

                string     type_str = "";
                Image.Type type     = Image.Type.Simple;
                node.TryGetValue("type", ref type_str);
                type = KodeUI_Utils.ToEnum <Image.Type> (type_str, type);

                Debug.LogFormat("[KodeUI.ImageLoader] {0}: {1} {2}",
                                name, sprite, type);
                ImageData id = new ImageData();
                id.sprite    = sprite;
                id.type      = type;
                images[name] = id;
                yield return(null);
            }
        }
Example #2
0
 static Image.Type?ParseImageType(string str)
 {
     if (String.IsNullOrEmpty(str))
     {
         return(null);
     }
     Image.Type transition = Image.Type.Simple;            //Simple, Sliced, Tiled, Filled
     transition = KodeUI_Utils.ToEnum <Image.Type> (str, transition);
     return(transition);
 }
Example #3
0
 static Selectable.Transition?ParseTransition(string str)
 {
     if (String.IsNullOrEmpty(str))
     {
         return(null);
     }
     Selectable.Transition transition = Selectable.Transition.ColorTint;
     transition = KodeUI_Utils.ToEnum <Selectable.Transition> (str, transition);
     return(transition);
 }
Example #4
0
        static TextAlignmentOptions?ParseAlignment(string str)
        {
            if (String.IsNullOrEmpty(str))
            {
                return(null);
            }
            TextAlignmentOptions alignment = TextAlignmentOptions.TopLeft;

            alignment = KodeUI_Utils.ToEnum <TextAlignmentOptions> (str, alignment);
            return(alignment);
        }
Example #5
0
        public static IEnumerator LoadSprites()
        {
            var dbase     = GameDatabase.Instance;
            var node_list = dbase.GetConfigNodes("KodeUI_Sprite");

            for (int i = 0; i < node_list.Length; i++)
            {
                var    node = node_list[i];
                string name = node.GetValue("name");
                if (String.IsNullOrEmpty(name))
                {
                    Debug.Log("[KodeUI.SpriteLoader] skipping unnamed sprite");
                    continue;
                }

                string    textureUrl = node.GetValue("textureUrl");
                Texture2D tex        = dbase.GetTexture(textureUrl, false);
                if (tex == null)
                {
                    Debug.LogFormat("[KodeUI.SpriteLoader] error loading texture {0}", textureUrl);
                    continue;
                }

                Rect rect = new Rect(0, 0, tex.width, tex.height);
                node.TryGetValue("rect", ref rect);

                Vector2 pivot = new Vector2(0.5f, 0.5f);
                node.TryGetValue("pivot", ref pivot);

                float pixelsPerUnit = 100;
                node.TryGetValue("pixelsPerUnit", ref pixelsPerUnit);

                uint extrude = 0;
                node.TryGetValue("extrude", ref extrude);

                string         type_str = "";
                SpriteMeshType type     = SpriteMeshType.Tight;
                node.TryGetValue("type", ref type_str);
                type = KodeUI_Utils.ToEnum <SpriteMeshType> (type_str, type);

                Vector4 border = Vector4.zero;
                node.TryGetValue("border", ref border);

                Debug.LogFormat("[KodeUI.SpriteLoader] {0}: {1} {2} {3} {4} {5} {6} {7}",
                                name, textureUrl, rect, pivot, pixelsPerUnit,
                                extrude, type, border);
                sprites[name] = Sprite.Create(tex, rect, pivot, pixelsPerUnit,
                                              extrude, type, border);
                yield return(null);
            }
        }