Beispiel #1
0
        public override void Sync(Component c)
        {
            base.Sync(c);

            name = "cc.MeshRenderer";
            var meshRenderer = c as MeshRenderer;

            var filter = comp.GetComponent <MeshFilter>();

            if (filter && filter.sharedMesh)
            {
                if (filter.sharedMesh.name.StartsWith("Combined Mesh"))
                {
                    if (meshRenderer)
                    {
                        var path = "CombinedMesh/" + filter.name + "_" + (meshRenderer.subMeshStartIndex) + "_" + (meshRenderer.subMeshStartIndex + meshRenderer.sharedMaterials.Length - 1);

                        var asset = new SyncMeshData();
                        asset.uuid = path;
                        asset.path = path;

                        asset.shouldCheckSrc = false;

                        asset.Sync(filter.sharedMesh, meshRenderer.subMeshStartIndex, meshRenderer.sharedMaterials.Length);

                        SyncAssetData.AddAssetData(asset);
                    }
                }
                else
                {
                    var meshData = SyncAssetData.GetAssetData <SyncMeshData>(filter.sharedMesh);
                    if (meshData != null)
                    {
                        this.mesh = meshData.uuid;
                    }
                }
            }
        }
Beispiel #2
0
        public override void Sync(Component c)
        {
            base.Sync(c);
            name = "cc.SkinnedMeshRenderer";

            SkinnedMeshRenderer renderer = c as SkinnedMeshRenderer;

            var meshData = SyncAssetData.GetAssetData <SyncMeshData>(renderer.sharedMesh);

            if (meshData != null)
            {
                mesh = meshData.uuid;
            }

            if (meshData != null)
            {
                var path = Path.Combine(Path.GetDirectoryName(meshData.path), Path.GetFileNameWithoutExtension(meshData.path), renderer.transform.name + ".skeleton");

                var asset = new SyncSkeletonData();
                asset.uuid = path;
                asset.path = path;

                asset.shouldCheckSrc = false;
                asset.virtualAsset   = true;
                asset.Sync(null, renderer);

                SyncAssetData.AddAssetData(asset);

                skeleton = path;
            }

            var rootBone = Hierarchy.GetRootBone(renderer);

            // CocosSyncTool.Instance.SyncNode(rootBone);
            rootBonePath = Hierarchy.GetPath(rootBone, null);
        }