Ejemplo n.º 1
0
    public void Fill(Component com, MyJson.IJsonNode json)
    {
        UILabel t     = com as UILabel;
        var     jsono = json as MyJson.JsonNode_Object;

        //font 有特殊的打包逻辑
        if (jsono.ContainsKey("bfont"))
        {
            string bfontname = jsono["bfont"] as MyJson.JsonNode_ValueString;
            t.bitmapFont = FontMgr.Instance.GetUIFont(bfontname);
        }
        else if (jsono.ContainsKey("tfont"))
        {
            string tfontname = jsono["tfont"] as MyJson.JsonNode_ValueString;
            t.trueTypeFont = FontMgr.Instance.GetUnityFont(tfontname);
        }
        else
        {
            Debug.LogWarning("UILabel" + com.name + " 未指定Font");
        }
        t.fontSize = (jsono["fontsize"] as MyJson.JsonNode_ValueNumber);


        //材质有特殊的打包逻辑
        //json["mate"] = t.material;


        t.text                = jsono["text"] as MyJson.JsonNode_ValueString;
        t.overflowMethod      = (UILabel.Overflow)Enum.Parse(typeof(UILabel.Overflow), jsono["overflowMethod"] as MyJson.JsonNode_ValueString);
        t.alignment           = (NGUIText.Alignment)Enum.Parse(typeof(NGUIText.Alignment), jsono["alignment"] as MyJson.JsonNode_ValueString);
        t.keepCrispWhenShrunk = (UILabel.Crispness)Enum.Parse(typeof(UILabel.Crispness), jsono["keepCrispWhenShrunk"] as MyJson.JsonNode_ValueString);
        t.applyGradient       = (jsono["applyGradient"] as MyJson.JsonNode_ValueNumber);
        t.gradientTop         = ComponentTypeConvert.StringToColor(jsono["gradientTop"] as MyJson.JsonNode_ValueString);
        t.gradientBottom      = ComponentTypeConvert.StringToColor(jsono["gradientBottom"] as MyJson.JsonNode_ValueString);
        t.effectStyle         = (UILabel.Effect)Enum.Parse(typeof(UILabel.Effect), jsono["effectStyle"] as MyJson.JsonNode_ValueString);
        t.effectColor         = ComponentTypeConvert.StringToColor(jsono["effectColor"] as MyJson.JsonNode_ValueString);
        t.effectDistance      = ComponentTypeConvert.StringToVector2(jsono["effectDistance"] as MyJson.JsonNode_ValueString);
        var spacing = ComponentTypeConvert.StringToVector2(jsono["spacing"] as MyJson.JsonNode_ValueString);

        t.spacingX     = (int)spacing.x;
        t.spacingY     = (int)spacing.y;
        t.maxLineCount = (jsono["maxLineCount"] as MyJson.JsonNode_ValueNumber);

        ComponentParser.FillWidget(t, jsono);
    }
Ejemplo n.º 2
0
    public void Fill(Component com, MyJson.IJsonNode json)
    {
        UISprite t     = com as UISprite;
        var      jsono = json as MyJson.JsonNode_Object;

        //t.atlas atlas 有特殊的打包逻辑
        string atlas = jsono["atlas"] as MyJson.JsonNode_ValueString;

        t.atlas = AtlasMgr.Instance.GetAtlas(atlas);
        //Debug.Log("atals:" + atlas + "," + t.atlas);
        t.spriteName = jsono["spriteName"] as MyJson.JsonNode_ValueString;
        t.type       = (UISprite.Type)Enum.Parse(typeof(UISprite.Type), jsono["spriteType"] as MyJson.JsonNode_ValueString);
        if (t.type == UISprite.Type.Simple)
        {
            t.flip = (UISprite.Flip)Enum.Parse(typeof(UISprite.Flip), jsono["flip"] as MyJson.JsonNode_ValueString);
        }
        else if (t.type == UISprite.Type.Sliced)
        {
            t.centerType = (UISprite.AdvancedType)Enum.Parse(typeof(UISprite.AdvancedType), jsono["centerType"] as MyJson.JsonNode_ValueString);
            t.flip       = (UISprite.Flip)Enum.Parse(typeof(UISprite.Flip), jsono["flip"] as MyJson.JsonNode_ValueString);
        }
        else if (t.type == UISprite.Type.Tiled)
        {
        }
        else if (t.type == UISprite.Type.Filled)
        {
            t.flip          = (UISprite.Flip)Enum.Parse(typeof(UISprite.Flip), jsono["flip"] as MyJson.JsonNode_ValueString);
            t.fillDirection = (UISprite.FillDirection)Enum.Parse(typeof(UISprite.FillDirection), jsono["fillDirection"] as MyJson.JsonNode_ValueString);
            t.fillAmount    = jsono["fillAmount"] as MyJson.JsonNode_ValueNumber;
            t.invert        = jsono["invert"] as MyJson.JsonNode_ValueNumber;
        }
        else if (t.type == UISprite.Type.Advanced)
        {
            t.leftType   = (UISprite.AdvancedType)Enum.Parse(typeof(UISprite.AdvancedType), jsono["leftType"] as MyJson.JsonNode_ValueString);
            t.rightType  = (UISprite.AdvancedType)Enum.Parse(typeof(UISprite.AdvancedType), jsono["rightType"] as MyJson.JsonNode_ValueString);
            t.topType    = (UISprite.AdvancedType)Enum.Parse(typeof(UISprite.AdvancedType), jsono["topType"] as MyJson.JsonNode_ValueString);
            t.bottomType = (UISprite.AdvancedType)Enum.Parse(typeof(UISprite.AdvancedType), jsono["bottomType"] as MyJson.JsonNode_ValueString);
            t.centerType = (UISprite.AdvancedType)Enum.Parse(typeof(UISprite.AdvancedType), jsono["centerType"] as MyJson.JsonNode_ValueString);
            t.flip       = (UISprite.Flip)Enum.Parse(typeof(UISprite.Flip), jsono["flip"] as MyJson.JsonNode_ValueString);
        }
        ComponentParser.FillWidget(t, jsono);
    }
Ejemplo n.º 3
0
    public void Fill(Component com, MyJson.IJsonNode json)
    {
        UITexture t     = com as UITexture;
        var       jsono = json as MyJson.JsonNode_Object;

        if (jsono.ContainsKey("mainTexture"))
        {
            string needtex = jsono["mainTexture"] as MyJson.JsonNode_ValueString;
            needtex = needtex.ToLower();
            var tex = AtlasMgr.Instance.GetTexture(needtex);
            if (tex != null)
            {
                //贴图的恢复
                t.mainTexture = tex;
            }
            else
            {
                Debug.LogWarning(com.name + "Can't find texture:" + needtex);
            }

            if (jsono.ContainsKey("shader"))
            {
                string shader = jsono["shader"] as MyJson.JsonNode_ValueString;
                Shader s      = Shader.Find(shader);
                if (s != null)
                {
                    t.shader = s;
                }
                else
                {
                    Debug.LogWarning(com.name + "Can't find shader:" + shader);
                }
            }
        }


        ComponentParser.FillWidget(t, jsono);
    }