コード例 #1
0
        private void ToTransform(string tagName, JsonData root, DTransform dTransform)
        {
            var transJson = new JsonData();

            root[tagName]         = transJson;
            transJson["Position"] = DTransform.VectorToString(dTransform.position);
            transJson["Angle"]    = DTransform.VectorToString(dTransform.angle);
            transJson["Scale"]    = DTransform.VectorToString(dTransform.scale);
        }
コード例 #2
0
        public DTransform transform; //变换信息

        public virtual JsonData Serialize()
        {
            var partJson = new JsonData();

            partJson["Type"]     = partType.ToString();
            partJson["Name"]     = name;
            partJson["Source"]   = source;
            partJson["Parent"]   = parent;
            partJson["Position"] = DTransform.VectorToString(transform.position);
            partJson["Angle"]    = DTransform.VectorToString(transform.angle);
            partJson["Scale"]    = DTransform.VectorToString(transform.scale);
            return(partJson);
        }
コード例 #3
0
        public bool Deserialize(JsonData json)
        {
            try
            {
                buildTransform  = DTransform.ParseTransform(json["BuildTransform"]);
                motionTransform = DTransform.ParseTransform(json["MotionTransform"]);
                ParsePartDatas(json["Parts"]);

                return(true);
            }
            catch (Exception ex)
            {
                DebugUtility.LogException(ex);
                return(false);
            }
        }
コード例 #4
0
        public virtual void Deserialize(JsonData json)
        {
            name   = (string)json["Name"];
            source = (string)json["Source"];
            parent = (string)json["Parent"];

            transform = new DTransform();
            var pos = (string)json["Position"];

            transform.position = DTransform.StringToVector(pos);
            var angle = (string)json["Angle"];

            transform.angle = DTransform.StringToVector(angle);
            var scale = (string)json["Scale"];

            transform.scale = DTransform.StringToVector(scale);
        }
コード例 #5
0
        public static DTransform ParseTransform(JsonData transJson)
        {
            var transform = new DTransform();

            if (transJson == null)
            {
                transform.position = Vector3.zero;
                transform.angle    = Vector3.zero;
                transform.scale    = Vector3.one;
                return(transform);
            }

            transform.position = StringToVector((string)transJson["Position"]);
            transform.angle    = StringToVector((string)transJson["Angle"]);
            transform.scale    = StringToVector((string)transJson["Scale"]);

            return(transform);
        }