/// <summary> /// Restore a previously serialized Mesh Filter component. /// </summary> static public void Deserialize(this MeshFilter filter, DataNode data) { DataNode mesh = data.GetChild("Mesh"); if (mesh != null) { filter.sharedMesh = mesh.DeserializeMesh(); } }
/// <summary> /// Deserialize a previously serialized renderer. /// </summary> static void Deserialize(this SkinnedMeshRenderer ren, DataNode data) { GameObject go = ren.gameObject; ren.rootBone = go.StringToReference(data.GetChild <string>("root")) as Transform; string[] boneList = data.GetChild <string[]>("bones"); if (boneList != null) { Transform[] bones = new Transform[boneList.Length]; for (int i = 0; i < bones.Length; ++i) { bones[i] = go.StringToReference(boneList[i]) as Transform; if (bones[i] == null) { Debug.LogWarning("Bone not found: " + boneList[i], go); } } ren.bones = bones; } DataNode meshNode = data.GetChild("Mesh"); if (meshNode != null) { ren.sharedMesh = meshNode.DeserializeMesh(); } ren.quality = data.GetChild <SkinQuality>("quality", ren.quality); ren.updateWhenOffscreen = data.GetChild <bool>("offscreen", ren.updateWhenOffscreen); Vector3 center = data.GetChild <Vector3>("center", ren.localBounds.center); Vector3 size = data.GetChild <Vector3>("size", ren.localBounds.size); ren.localBounds = new Bounds(center, size); Deserialize((Renderer)ren, data); }
/// <summary> /// Deserialize a previously serialized game object. /// </summary> static public void Deserialize(this GameObject go, DataNode root, bool includeChildren = true) { DataNode resNode = root.GetChild("Resources"); if (resNode != null) { for (int i = 0; i < resNode.children.size; ++i) { DataNode child = resNode.children[i]; if (child.name == "Texture") { child.DeserializeTexture(); } else if (child.name == "Material") { child.DeserializeMaterial(); } else if (child.name == "Mesh") { child.DeserializeMesh(); } } } if (includeChildren) { go.DeserializeHierarchy(root); for (int i = 0; i < mSerList.size; ++i) { mSerList[i].go.DeserializeComponents(mSerList[i].node); } mSerList.Clear(); } else { go.DeserializeComponents(root); } }