private void JudgeType() { if (SectionType == SectionType.Closed || SectionType == SectionType.Opend) { layerType = LayerType.Group; } else if (this.resources.Contains("SoLd.Idnt")) { layerType = LayerType.Normal; } else if (this.resources.Contains("SoCo") == true) { layerType = LayerType.Color; } else if (this.resources.Contains("TySh.Idnt")) { layerType = LayerType.Text; Readers.LayerResources.Reader_TySh reader = resources["TySh"] as Readers.LayerResources.Reader_TySh; DescriptorStructure text = null; if (reader.TryGetValue <DescriptorStructure>(ref text, "Text")) { textinfo = new TextInfo(text); } } else if (deepth > 6) { layerType = LayerType.Overflow; } else { layerType = LayerType.Complex; } }
public TextInfo(DescriptorStructure text) { this.Text = text["Txt"].ToString(); //颜色路径EngineData/EngineDict/StyleRun/RunArray/StyleSheet/StyleSheetData/FillColor //UnityEngine.Debug.Log(Newtonsoft.Json.JsonConvert.SerializeObject(Text)); engineData = text["EngineData"] as StructureEngineData; engineDict = engineData["EngineDict"] as Properties; var stylerun = engineDict["StyleRun"] as Properties; var runarray = stylerun["RunArray"] as ArrayList; var styleSheet = (runarray[0] as Properties)["StyleSheet"] as Properties; var styleSheetsData = styleSheet?["StyleSheetData"] as Properties; FontSize = (int)(float)styleSheetsData["FontSize"]; if (styleSheetsData.Contains("Font")) { FontName = styleSheetsData["Font"] as string; } if (styleSheetsData.Contains("FillColor")) { var strokeColorProp = styleSheetsData["FillColor"] as Properties; var strokeColor = strokeColorProp["Values"] as ArrayList; Color = new UnityEngine.Color(float.Parse(strokeColor[1].ToString()), float.Parse(strokeColor[2].ToString()), float.Parse(strokeColor[3].ToString()), float.Parse(strokeColor[0].ToString())); } else { //var json= Newtonsoft.Json.JsonConvert.SerializeObject(styleSheetsData); //UnityEngine.Debug.Log(json); Color = UnityEngine.Color.black; } }
public TextInfo(DescriptorStructure text) { this.text = text["Txt"].ToString(); //颜色路径EngineData/EngineDict/StyleRun/RunArray/StyleSheet/StyleSheetData/FillColor //UnityEngine.Debug.Log(Newtonsoft.Json.JsonConvert.SerializeObject(text)); var engineData = text["EngineData"] as StructureEngineData; var engineDict = engineData["EngineDict"] as Properties; var stylerun = engineDict["StyleRun"] as Properties; var runarray = stylerun["RunArray"] as ArrayList; var styleSheet = (runarray[0] as Properties)["StyleSheet"] as Properties; var styleSheetsData = (styleSheet as Properties)["StyleSheetData"] as Properties; if (styleSheetsData.Contains("FontSize")) { fontSize = (int)(System.Single)styleSheetsData["FontSize"]; } if (styleSheetsData.Contains("Font")) { fontName = styleSheetsData["Font"] as string; } if (styleSheetsData.Contains("FillColor")) { var strokeColorProp = styleSheetsData["FillColor"] as Properties; var strokeColor = strokeColorProp["Values"] as ArrayList; if (strokeColor != null && strokeColor.Count >= 4) { color = new float[] { float.Parse(strokeColor[1].ToString()), float.Parse(strokeColor[2].ToString()), float.Parse(strokeColor[3].ToString()), float.Parse(strokeColor[0].ToString()) }; } else { color = new float[4] { 0, 0, 0, 1 }; } } else { color = new float[4] { 0, 0, 0, 1 }; } }
public void SetExtraRecords(LayerMask layerMask, LayerBlendingRanges blendingRanges, IProperties resources, string name) { this.layerMask = layerMask; this.blendingRanges = blendingRanges; this.resources = resources; this.name = name; this.resources.TryGetValue <string>(ref this.name, "luni.Name"); this.resources.TryGetValue <SectionType>(ref this.sectionType, "lsct.SectionType"); if (SectionType == SectionType.Divider) { layerType = LayerType.Divider; } else if (SectionType == SectionType.Closed || SectionType == SectionType.Opend) { layerType = LayerType.Group; } else if (this.resources.Contains("SoLd.Idnt") == true) { this.placedID = this.resources.ToGuid("SoLd.Idnt"); layerType = LayerType.Normal; } else if (this.resources.Contains("SoLE.Idnt") == true) { this.placedID = this.resources.ToGuid("SoLE.Idnt"); throw new Exception("WaitDefine"); } else if (this.resources.Contains("TySh.Idnt")) { Readers.LayerResources.Reader_TySh reader = resources["TySh"] as Readers.LayerResources.Reader_TySh; DescriptorStructure text = null; if (reader.TryGetValue <DescriptorStructure>(ref text, "Text")) { textinfo = new TextInfo(text); } layerType = LayerType.Text; } else { layerType = LayerType.SolidImage; } foreach (var item in this.channels) { switch (item.Type) { case ChannelType.Mask: { if (this.layerMask != null) { item.Width = this.layerMask.Width; item.Height = this.layerMask.Height; } } break; case ChannelType.Alpha: { if (this.resources.Contains("iOpa") == true) { byte opa = this.resources.ToByte("iOpa", "Opacity"); item.Opacity = opa / 255.0f; } } break; } } }