Beispiel #1
0
        static SpriteState?ParseSpriteState(ConfigNode node)
        {
            if (node == null)
            {
                return(null);
            }
            SpriteState sprites = new SpriteState();

            { if (SpriteLoader.GetSprite(node.GetValue("highlightedSprite")) is Sprite s)
              {
                  sprites.highlightedSprite = s;
              }
            }
            { if (SpriteLoader.GetSprite(node.GetValue("pressedSprite")) is Sprite s)
              {
                  sprites.pressedSprite = s;
              }
            }
            { if (SpriteLoader.GetSprite(node.GetValue("selectedSprite")) is Sprite s)
              {
                  sprites.selectedSprite = s;
              }
            }
            { if (SpriteLoader.GetSprite(node.GetValue("disabledSprite")) is Sprite s)
              {
                  sprites.disabledSprite = s;
              }
            }
            return(sprites);
        }
Beispiel #2
0
 public void Load(ConfigNode node)
 {
     { if (ParseColorBlock(node.GetNode("stateColors")) is ColorBlock cb)
       {
           stateColors = cb;
       }
     }
     { if (ParseColor(node.GetValue("color")) is Color c)
       {
           color = c;
       }
     }
     { if (SpriteLoader.GetSprite(node.GetValue("sprite")) is Sprite s)
       {
           sprite = s;
       }
     }
     { if (ParseSpriteState(node.GetNode("stateSprites")) is SpriteState s)
       {
           stateSprites = s;
       }
     }
     { if (ParseTransition(node.GetValue("transition")) is Selectable.Transition t)
       {
           transition = t;
       }
     }
     { if (ParseImageType(node.GetValue("type")) is Image.Type t)
       {
           type = t;
       }
     }
     { if (ParseFloat(node.GetValue("fontSize")) is float f)
       {
           fontSize = f;
       }
     }
     { if (ParseAlignment(node.GetValue("alignment")) is TextAlignmentOptions a)
       {
           alignment = a;
       }
     }
     { if (ParseVector4(node.GetValue("margin")) is Vector4 v)
       {
           margin = v;
       }
     }
     { if (ParseRectOffset(node.GetValue("padding")) is RectOffset ro)
       {
           padding = ro;
       }
     }
     { if (ParseFloat(node.GetValue("spacing")) is float f)
       {
           spacing = f;
       }
     }
 }
Beispiel #3
0
        public static void SetupImage(Image image, string name)
        {
            ImageData id = null;

            if (images.TryGetValue(name, out id))
            {
                Sprite sprite = SpriteLoader.GetSprite(id.sprite);
                if (sprite == null)
                {
                    Debug.LogFormat("[KodeUI.ImageLoader] sprite not found:{0}", id.sprite);
                }
                image.sprite = sprite;
                image.type   = id.type;
            }
        }