public void Cleanup() { UnityEngine.Object.DestroyImmediate(go); go = null; skeletons = null; skeletonObj.Dispose(); }
public ResourceObject Parse(ByteBuffer bb) { Schema.Skeletons skeleton = Schema.Skeletons.GetRootAsSkeletons(bb); GameObject[] goes = new GameObject[skeleton.JointsLength]; for (int i = 0; i < skeleton.JointsLength; i++) { Schema.Joint joint = skeleton.GetJoints(i); GameObject go = new GameObject(joint.Names); // 设置局部 Transform 一定要在设置父节点之后进行,否则会因为设置了父节点导致局部transform而改变 if (joint.Parent >= 0) { go.transform.parent = goes[joint.Parent].transform; } Vec3 pos = joint.Transform.Pos; go.transform.localPosition = new Vector3(pos.X, pos.Y, pos.Z); Quat quat = joint.Transform.Rot; go.transform.localRotation = new Quaternion(quat.X, quat.Y, quat.Z, quat.W); Vec3 scl = joint.Transform.Scl; go.transform.localScale = new Vector3(scl.X, scl.Y, scl.Z); goes[i] = go; } goes [0].hideFlags |= HideFlags.HideInHierarchy; //GameObject.DontDestroyOnLoad (goes [0]); return(new ResourceObjectSingle(goes[0])); }
public void Cleanup() { ab.Unload(true); go = null; ab = null; skeletons = null; }
public static Offset <Skeletons> CreateSkeletons(FlatBufferBuilder builder, VectorOffset jointsOffset = default(VectorOffset)) { builder.StartObject(1); Skeletons.AddJoints(builder, jointsOffset); return(Skeletons.EndSkeletons(builder)); }
public void Init() { ab = TestData.LoadBundle("skeletontest.bundle"); go = TestData.LoadFirstAsset <GameObject>(ab); Assert.IsNotNull(go); ByteBuffer result = SkeletonSaver.Save(go); skeletons = Schema.Skeletons.GetRootAsSkeletons(result); }
public void Init() { Context context = Context.Unknown; ByteBuffer bb = TestData.LoadResource("skeleton.doub", out context); Assert.IsNotNull(bb); Assert.AreNotEqual(context, Context.Unknown); skeletons = Schema.Skeletons.GetRootAsSkeletons(bb); SkeletonUnserializer unserializer = UnserializerFactory.Instance.Create(context) as SkeletonUnserializer; skeletonObj = unserializer.Parse(bb) as ResourceObjectSingle; go = new GameObject("Skeleton"); (skeletonObj.Unity3dObject as GameObject).transform.parent = go.transform; }
public static Skeletons GetRootAsSkeletons(ByteBuffer _bb, Skeletons obj) { return(obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }