Exemple #1
0
        /// <summary>
        /// Serialize mono curve to string content.
        /// </summary>
        /// <returns></returns>
        protected override string SerializeCurve()
        {
            var anchors = new List <BezierAnchor>()
            {
                curve.from, curve.to
            };

            return(ListJsonUtility.ToJson(anchors));
        }
Exemple #2
0
        /// <summary>
        /// Deserialize mono curve from string content.
        /// </summary>
        /// <param name="contents"></param>
        /// <returns></returns>
        protected override bool DeserializeCurve(string contents)
        {
            try
            {
                var anchors = ListJsonUtility.FromJson <HermiteAnchor>(contents);
                if (anchors == null)
                {
                    Debug.LogError("The anchors is null.");
                    return(false);
                }

                curve.anchors = anchors;
                curve.Rebuild();
                return(true);
            }
            catch (Exception ex)
            {
                Debug.LogErrorFormat("{0}\r\n{1}", ex.Message, ex.StackTrace);
                return(false);
            }
        }
Exemple #3
0
        /// <summary>
        /// Deserialize mono curve from string content.
        /// </summary>
        /// <param name="contents"></param>
        /// <returns></returns>
        protected override bool DeserializeCurve(string contents)
        {
            try
            {
                var anchors = ListJsonUtility.FromJson <BezierAnchor>(contents);
                if (anchors == null || anchors.Count < 2)
                {
                    Debug.LogError("The anchors is null or count is less than 2.");
                    return(false);
                }

                curve.from = anchors[0];
                curve.to   = anchors[1];
                curve.Rebuild();
                return(true);
            }
            catch (Exception ex)
            {
                Debug.LogErrorFormat("{0}\r\n{1}", ex.Message, ex.StackTrace);
                return(false);
            }
        }
Exemple #4
0
 /// <summary>
 /// Serialize mono curve to string content.
 /// </summary>
 /// <returns></returns>
 protected override string SerializeCurve()
 {
     return(ListJsonUtility.ToJson(curve.anchors));
 }