public static IJsonNode Vector2Json(Vector2 arg) { IJsonNode ret = JsonHelper.CreateNode(); ret.SetDouble("x", System.Math.Round(arg.x, 4)); ret.SetDouble("y", System.Math.Round(arg.y, 4)); return(ret); }
public static IJsonNode ColorJson(Color arg) { IJsonNode ret = JsonHelper.CreateNode(); ret.SetDouble("r", System.Math.Round(arg.r, 4)); ret.SetDouble("g", System.Math.Round(arg.g, 4)); ret.SetDouble("b", System.Math.Round(arg.b, 4)); ret.SetDouble("a", System.Math.Round(arg.a, 4)); return(ret); }
public static IJsonNode AnimationCurveJson(AnimationCurve arg) { IJsonNode ret = JsonHelper.CreateNode(); IJsonNode jsonKeys = JsonHelper.CreateNode(); Keyframe[] keys = arg.keys; for (int i = 0, imax = keys.Length; i < imax; ++i) { Keyframe k = keys[i]; IJsonNode oneKey = JsonHelper.CreateNode(); ret.SetDouble("T", System.Math.Round(k.time, 4)); ret.SetDouble("V", System.Math.Round(k.value, 4)); ret.SetDouble("I", System.Math.Round(k.inTangent, 4)); ret.SetDouble("O", System.Math.Round(k.outTangent, 4)); ret.SetInt("M", k.tangentMode); jsonKeys.Add(oneKey); } ret.SetNode("keys", jsonKeys); ret.SetInt("pre", (int)arg.preWrapMode); ret.SetInt("post", (int)arg.postWrapMode); return(ret); }
/// <summary> /// 转成Json /// </summary> public IJsonNode DoJson() { IJsonNode json = JsonHelper.CreateNode(); if (m_tweenType != 0) { json.SetInt("tweenType", m_tweenType); } // end if json.SetInt("tweenElement", (int)m_tweenElement); if (!string.IsNullOrEmpty(m_name)) { json.SetString("name", m_name); } // end if json.SetDouble("duration", Math.Round(m_duration, 4)); if (m_delay > 0.00009f) { json.SetDouble("delay", Math.Round(m_delay, 4)); } // end if json.SetBool("snapping", m_isSnapping); if (m_animCurve != null && m_animCurve.keys != null && m_animCurve.keys.Length > 0) { json.SetNode("animCurve", JTweenUtils.AnimationCurveJson(m_animCurve)); } else { json.SetInt("animEase", (int)m_animEase); } // end if if (m_loopCount > 0) { json.SetInt("loopCount", m_loopCount); json.SetInt("loopType", (int)m_loopType); } // end if ToJson(ref json); return(json); }