Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        public DescriptorStructure(PsdReader reader, bool hasVersion)
        {
            if (hasVersion == true)
            {
                this.version = reader.ReadInt32();
            }

            this.Add("Name", reader.ReadString());
            this.Add("ClassID", reader.ReadKey());

            int count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                string key    = reader.ReadKey();
                string osType = reader.ReadType();
                if (key == "EngineData")
                {
                    var engineData = new StructureEngineData(reader);
                    this.Add(key.Trim(), engineData);
                }
                else
                {
                    object value = StructureReader.Read(osType, reader);
                    this.Add(key.Trim(), value);
                }
            }
        }