public ResourceObject Parse(ByteBuffer bb) { UnityEngine.AnimationClip clip = new UnityEngine.AnimationClip(); Schema.AnimationClip _clip = Schema.AnimationClip.GetRootAsAnimationClip(bb); clip.frameRate = _clip.FrameRate; clip.wrapMode = (UnityEngine.WrapMode)_clip.WrapMode; clip.legacy = true; for (int i = 0; i < _clip.BindingsLength; i++) { Schema.CurveBinding bind = _clip.GetBindings(i); Schema.AnimationCurve _curve = bind.Curve; UnityEngine.AnimationCurve curve = new UnityEngine.AnimationCurve(); for (int j = 0; j < _curve.KeyFramesLength; j++) { Schema.KeyFrame _kf = _curve.GetKeyFrames(j); UnityEngine.Keyframe kf = new UnityEngine.Keyframe(_kf.Time, _kf.Value, _kf.InTangent, _kf.OutTangent); kf.tangentMode = _kf.TangentMode; curve.AddKey(kf); } curve.preWrapMode = (UnityEngine.WrapMode)_curve.PreWrapMode; curve.postWrapMode = (UnityEngine.WrapMode)_curve.PostWrapMode; var assembly = Assembly.Load("UnityEngine"); Type type = assembly.GetType(bind.Type); clip.SetCurve(bind.Path, type, bind.PropertyName, curve); } return(new ResourceObjectSingle(clip)); }
public void EqualSource() { Assert.AreEqual(originClip.frameRate, clip.FrameRate); Assert.AreEqual(originClip.wrapMode, (UnityEngine.WrapMode)clip.WrapMode); EditorCurveBinding[] bindings = AnimationUtility.GetCurveBindings(originClip); Assert.AreEqual(clip.BindingsLength, bindings.Length); for (int i = 0; i < bindings.Length; i++) { Schema.CurveBinding bind = clip.GetBindings(i); Assert.AreEqual(bind.PropertyName, bindings[i].propertyName); Assert.AreEqual(bind.Path, bindings[i].path); Assert.AreEqual(bind.Type, bindings[i].type.FullName); Schema.AnimationCurve curv = bind.GetCurve(new Schema.AnimationCurve()); UnityEngine.AnimationCurve originCurve = AnimationUtility.GetEditorCurve(originClip, bindings[i]); Assert.AreEqual(curv.PreWrapMode, (Schema.WrapMode)originCurve.preWrapMode); Assert.AreEqual(curv.PostWrapMode, (Schema.WrapMode)originCurve.postWrapMode); Assert.AreEqual(curv.KeyFramesLength, originCurve.keys.Length); for (int j = 0; j < curv.KeyFramesLength; j++) { Schema.KeyFrame keyFrame = curv.GetKeyFrames(j); UnityEngine.Keyframe originKeyframe = originCurve.keys[j]; Assert.AreEqual(keyFrame.InTangent, originKeyframe.inTangent); Assert.AreEqual(keyFrame.OutTangent, originKeyframe.outTangent); Assert.AreEqual(keyFrame.TangentMode, originKeyframe.tangentMode); Assert.AreEqual(keyFrame.Time, originKeyframe.time); Assert.AreEqual(keyFrame.Value, originKeyframe.value); } } }
public static Offset <CurveBinding> CreateCurveBinding(FlatBufferBuilder builder, StringOffset propertyNameOffset = default(StringOffset), StringOffset pathOffset = default(StringOffset), StringOffset typeOffset = default(StringOffset), Offset <AnimationCurve> curveOffset = default(Offset <AnimationCurve>)) { builder.StartObject(4); CurveBinding.AddCurve(builder, curveOffset); CurveBinding.AddType(builder, typeOffset); CurveBinding.AddPath(builder, pathOffset); CurveBinding.AddPropertyName(builder, propertyNameOffset); return(CurveBinding.EndCurveBinding(builder)); }
public static CurveBinding GetRootAsCurveBinding(ByteBuffer _bb, CurveBinding obj) { return(obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public CurveBinding GetBindings(CurveBinding obj, int j) { int o = __offset(8); return(o != 0 ? obj.__init(__indirect(__vector(o) + j * 4), bb) : null); }