public MyJson.IJsonNode Parser(Component com, NeedList list) { UITexture t = com as UITexture; var json = new MyJson.JsonNode_Object(); if (t.mainTexture != null) { string needtex = AtlasMgr.SaveTexture(t.mainTexture, System.IO.Path.Combine(Application.streamingAssetsPath, "nguitex")); json["mainTexture"] = new MyJson.JsonNode_ValueString(needtex); list.AddDependTexture(needtex); if (t.shader != null) { string shader = t.shader.name; json["shader"] = new MyJson.JsonNode_ValueString(shader); } } else { Debug.LogWarning("不支持 导出使用材质的UITexture"); } json["uvRect"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.RectToString(t.uvRect)); ComponentParser.ParserWidget(json, t); return(json); }
public IEnumerable <IAstNode> Parse() { while (Current is not null) { switch (Current.TokenType) { case TokenType.KwRecord: var recordNode = new RecordParser(this).Parse(); if (recordNode is not null) { yield return(recordNode); } break; case TokenType.KwComponent: var componentNode = new ComponentParser(this).Parse(); if (componentNode is not null) { yield return(componentNode); } break; default: Take(); break; } } }
private void parseComponents(IEntity entity, XmlNode componentsNode) { foreach (XmlNode componentNode in componentsNode) { ComponentParser componentParser = null; switch (componentNode.Name) { case "position": componentParser = parsePosition; break; case "mesh": componentParser = parseMesh; break; case "camera": componentParser = parseCamera; break; case "renderable": componentParser = parseRenderable; break; case "velocity": componentParser = parseVelocity; break; case "scale": componentParser = parseScale; break; case "playerinput": componentParser = parsePlayerInput; break; case "animation": componentParser = parseAnimation; break; default: throw new NotImplementedException(); } Type componentType; ComponentProperties componentProperties; (componentType, componentProperties) = componentParser(entity, componentNode); entity.AddComponent(componentType, componentProperties, _context, entity); } }
public MyJson.IJsonNode Parser(Component com, NeedList needlist) { UISprite t = com as UISprite; var json = new MyJson.JsonNode_Object(); //t.atlas atlas 有特殊的打包逻辑 string atlas = AtlasMgr.SaveAtlas(t.atlas, System.IO.Path.Combine(Application.streamingAssetsPath, "nguiatlas"), System.IO.Path.Combine(Application.streamingAssetsPath, "nguitex")); json["atlas"] = new MyJson.JsonNode_ValueString(atlas); if (needlist != null) { needlist.AddDependAtlas(atlas); } json["spriteName"] = new MyJson.JsonNode_ValueString(t.spriteName); json["spriteType"] = new MyJson.JsonNode_ValueString(t.type.ToString()); if (t.type == UISprite.Type.Simple) { json["flip"] = new MyJson.JsonNode_ValueString(t.flip.ToString()); } else if (t.type == UISprite.Type.Sliced) { json["centerType"] = new MyJson.JsonNode_ValueString(t.centerType.ToString()); json["flip"] = new MyJson.JsonNode_ValueString(t.flip.ToString()); } else if (t.type == UISprite.Type.Tiled) { } else if (t.type == UISprite.Type.Filled) { json["flip"] = new MyJson.JsonNode_ValueString(t.flip.ToString()); json["fillDirection"] = new MyJson.JsonNode_ValueString(t.fillDirection.ToString()); json["fillAmount"] = new MyJson.JsonNode_ValueNumber(t.fillAmount); json["invert"] = new MyJson.JsonNode_ValueNumber(t.invert); } else if (t.type == UISprite.Type.Advanced) { json["leftType"] = new MyJson.JsonNode_ValueString(t.leftType.ToString()); json["rightType"] = new MyJson.JsonNode_ValueString(t.rightType.ToString()); json["topType"] = new MyJson.JsonNode_ValueString(t.topType.ToString()); json["bottomType"] = new MyJson.JsonNode_ValueString(t.bottomType.ToString()); json["centerType"] = new MyJson.JsonNode_ValueString(t.centerType.ToString()); json["flip"] = new MyJson.JsonNode_ValueString(t.flip.ToString()); } ComponentParser.ParserWidget(json, t); return(json); }
public MyJson.IJsonNode Parser(Component com, NeedList list) { UILabel t = com as UILabel; var json = new MyJson.JsonNode_Object(); //font 有特殊的打包逻辑 if (t.bitmapFont != null) { json["bfont"] = new MyJson.JsonNode_ValueString(t.bitmapFont.name); } else if (t.trueTypeFont != null) { json["tfont"] = new MyJson.JsonNode_ValueString(t.trueTypeFont.name); if (list != null) { list.AddDependTFont(t.trueTypeFont.name); } } else { Debug.LogError("UILabel" + com.name + " 未指定Font"); } json["fontsize"] = new MyJson.JsonNode_ValueNumber(t.fontSize); //材质有特殊的打包逻辑 //json["mate"] = t.material; json["text"] = new MyJson.JsonNode_ValueString(t.text); json["overflowMethod"] = new MyJson.JsonNode_ValueString(t.overflowMethod.ToString()); json["alignment"] = new MyJson.JsonNode_ValueString(t.alignment.ToString()); json["keepCrispWhenShrunk"] = new MyJson.JsonNode_ValueString(t.keepCrispWhenShrunk.ToString()); json["applyGradient"] = new MyJson.JsonNode_ValueNumber(t.applyGradient); json["gradientTop"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.ColorToString(t.gradientTop)); json["gradientBottom"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.ColorToString(t.gradientBottom)); json["effectStyle"] = new MyJson.JsonNode_ValueString(t.effectStyle.ToString()); json["effectColor"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.ColorToString(t.effectColor)); json["effectDistance"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.Vector2ToString(t.effectDistance)); json["spacing"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.Vector2ToString(new Vector2(t.spacingX, t.spacingY))); json["maxLineCount"] = new MyJson.JsonNode_ValueNumber(t.maxLineCount); ComponentParser.ParserWidget(json, t); return(json); }
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); }
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); }
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); }