Exemple #1
0
        public SerializeEntity Serialize()
        {
            SerializeEntity se = new SerializeEntity();

            se.Type = "Text";
            se.Add("info", text);
            //TODO 字体和字体暂时不支持序列化,后期自定义字体时再做支持
            se.Add("FStyle", fontStyle.ToString())
            .Add("FSize", fontSize)
            .Add("LS", lineSpacing)
            .Add("RT", supportRichText)
            .Add("AG", alignment.ToString())
            .Add("ABG", alignByGeometry)
            .Add("HO", horizontalOverflow.ToString())
            .Add("VO", verticalOverflow.ToString())
            .Add("col", SerializeUitls.S_Color(color))
            .Add("RayT", raycastTarget)
            .Add("BF", resizeTextForBestFit);
            if (resizeTextForBestFit)
            {
                se.Add("MinS", resizeTextMinSize)
                .Add("MaxS", resizeTextMaxSize);
            }
            return(se);
        }
        public static SerializeEntity Serialize(this CanvasRenderer render)
        {
            SerializeEntity se = new SerializeEntity();

            se.Type = "CanvasRender";
            return(se);
        }
        public static SerializeEntity Serialize(this Transform trans)
        {
            SerializeEntity se = new SerializeEntity();

            if (trans is RectTransform)
            {
                se.Type = "RectTrans";
            }
            else
            {
                se.Type = "Trans";
            }

            if (trans is RectTransform)
            {
                var rTrans = trans as RectTransform;
                se.Add("AnMin", SerializeUitls.S_Vector2(rTrans.anchorMin));
                se.Add("AnMax", SerializeUitls.S_Vector2(rTrans.anchorMax));
                se.Add("pivot", SerializeUitls.S_Vector2(rTrans.pivot));
                se.Add("W", rTrans.rect.width);
                se.Add("H", rTrans.rect.height);
            }
            se.Add("p", SerializeUitls.S_Vector3(trans.localPosition));
            se.Add("r", SerializeUitls.S_Vector3(trans.localEulerAngles));
            se.Add("s", SerializeUitls.S_Vector3(trans.localScale));
            se.Add("active", trans.gameObject.activeSelf);
            return(se);
        }
Exemple #4
0
        public static SerializeEntity Ser_MaskableGraphic(this MaskableGraphic mg)
        {
            SerializeEntity se = new SerializeEntity();

            se.Add("m", SerializeUitls.GetResPath(mg.material))
            .Add("col", SerializeUitls.S_Color(mg.color))
            .Add("RT", mg.raycastTarget);
            return(se);
        }
Exemple #5
0
    private void Start()
    {
        SerializeEntity data = new SerializeEntity();

        data.Add("int1", "22.2")
        .Add("str", "str111")
        .Add("float", 1.244f)
        .Add("double", 2.55);
    }
        public SerializeEntity Serialize()
        {
            SerializeEntity data   = new SerializeEntity();
            LitButton       defBtn = DefValueMgr.Instance.GetDefComp <LitButton>();

            data.Type = "Btn";
            data.Add("AN", audioName, defBtn.audioName)
            .Add("AT", (int)this.animationType, (int)defBtn.animationType)
            .Add("TD", tweenDuration, defBtn.tweenDuration)
            .Add("SF", scaleFactor, defBtn.scaleFactor)
            .Add("CI", clickInterval, defBtn.clickInterval);
            return(data);
        }
 public static void DeSerialize(this Transform trans, SerializeEntity data)
 {
     if (trans is RectTransform)
     {
         var rTrans = trans as RectTransform;
         rTrans.anchorMin = SerializeUitls.D_Vector2(data["AnMin"]);
         rTrans.anchorMax = SerializeUitls.D_Vector2(data["AnMax"]);
         rTrans.pivot     = SerializeUitls.D_Vector2(data["pivot"]);
         rTrans.sizeDelta = new Vector2(data["W"], data["H"]);
     }
     trans.localPosition    = SerializeUitls.D_Vector3(data["p"]);
     trans.localScale       = SerializeUitls.D_Vector3(data["s"]);
     trans.localEulerAngles = SerializeUitls.D_Vector3(data["r"]);
     trans.gameObject.SetActive(data["active"]);
 }
        /// <summary>
        /// 生成序列化反序列化接口代码(类型拆分分解)
        /// </summary>
        /// <param name="type"></param>
        /// <param name="builder"></param>
        /// <param name="deserializeBuilder"></param>
        /// <param name="serializeFieldName"></param>
        /// <param name="deserializeFieldName"></param>
        /// <returns></returns>
        void generateCodeByProperties(Type type, StringBuilder builder, StringBuilder deserializeBuilder, string serializeFieldName, string deserializeFieldName)
        {
            startMember();
            var(properties, fields) = getTypeMembers(type);
            var             propertyFullName = Utils.GetFullName(type);
            SerializeEntity serializeEntity  = new SerializeEntity(type);

            genCodeDict[propertyFullName] = serializeEntity;
            generateCode(type, serializeEntity.SerializeBuilder, serializeEntity.DerializeBuilder, properties, fields, "model", "model");

            builder.AppendLine($"            {serializeEntity.SerializeName}({serializeFieldName}, stream);");

            deserializeBuilder.AppendLine($"            {deserializeFieldName} = {serializeEntity.DerializeName}(stream);");
            endMember();
        }
        public void DeSerialize(SerializeEntity data)
        {
            SerializeUitls.SetString(ref audioName, data, "AN");
            SerializeUitls.SetFloat(ref clickInterval, data, "AN");
            SerializeUitls.SetFloat(ref tweenDuration, data, "TD");
            SerializeUitls.SetFloat(ref scaleFactor, data, "SF");

            int aType = -1;

            SerializeUitls.SetInt(ref aType, data, "AT");
            if (aType != -1)
            {
                this.animationType = (ClickAnimation)aType;
            }
        }
Exemple #10
0
 public void DeSerialize(SerializeEntity data)
 {
     text                 = data["info"];
     fontStyle            = (FontStyle)System.Enum.Parse(typeof(FontStyle), data["FStyle"]);
     fontSize             = data["FSize"];
     lineSpacing          = data["LS"];
     supportRichText      = data["RT"];
     alignment            = (TextAnchor)System.Enum.Parse(typeof(TextAnchor), data["AG"]);
     alignByGeometry      = data["ABG"];
     horizontalOverflow   = (HorizontalWrapMode)System.Enum.Parse(typeof(HorizontalWrapMode), data["HO"]);
     verticalOverflow     = (VerticalWrapMode)System.Enum.Parse(typeof(VerticalWrapMode), data["VO"]);
     color                = SerializeUitls.D_Color(data["col"]);
     raycastTarget        = data["RayT"];
     resizeTextForBestFit = data["BF"];
     if (resizeTextForBestFit)
     {
         resizeTextMinSize = data["MinS"];
         resizeTextMaxSize = data["MaxS"];
     }
 }
Exemple #11
0
 public static void D_RawImage(this LitRawImage img, SerializeEntity data)
 {
     img.D_MaskableGraphic(data);
     img.texture = SerializeUitls.LoadObj <Texture>(data["path"]);
     img.uvRect  = SerializeUitls.D_Rect(data["UV"]);
 }
Exemple #12
0
 public static void D_Image(this Image img, SerializeEntity data)
 {
     img.D_MaskableGraphic(data);
     img.sprite         = SerializeUitls.LoadObj <Sprite>(data["path"]);
     img.preserveAspect = data["PA"];
 }
Exemple #13
0
 public static void D_MaskableGraphic(this MaskableGraphic mg, SerializeEntity data)
 {
     mg.color         = SerializeUitls.D_Color(data["col"]);
     mg.raycastTarget = data["RT"];
     mg.material      = SerializeUitls.LoadObj <Material>(data["m"]);
 }