public static void Build(tk2dSpriteCollection data)
        {
            if (data.linkedSpriteCollections.Count > 0 && !data.disableTrimming)
            {
                return;
            }

            string errors     = "";
            int    errorCount = 0;
            string root       = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(data)) + "/Linked";

            foreach (tk2dLinkedSpriteCollection link in data.linkedSpriteCollections)
            {
                if (link.spriteCollection == null)
                {
                    if (!System.IO.Directory.Exists(root))
                    {
                        System.IO.Directory.CreateDirectory(root);
                    }
                    link.spriteCollection = tk2dSpriteCollectionEditor.CreateSpriteCollection(root, data.name + link.name);
                }

                tk2dEditor.SpriteCollectionEditor.SpriteCollectionProxy proxy = new tk2dEditor.SpriteCollectionEditor.SpriteCollectionProxy(data, false);
                proxy.CopyBuiltFromSource(link.spriteCollection);
                proxy.linkedSpriteCollections.Clear();                 // stop recursion
                string thisErrors = "";

                foreach (tk2dSpriteCollectionDefinition tp in proxy.textureParams)
                {
                    if (tp.texture != null)
                    {
                        Texture2D repl = FindReplacementTexture(tp.texture, link.name);
                        if (repl == null)
                        {
                            thisErrors += string.Format("Unable to find replacement for texture '{0}' for link '{1}'\n", tp.texture.name, link.name);
                            ++errorCount;
                        }
                        tp.texture = repl;
                    }
                }

                if (thisErrors.Length == 0)
                {
                    proxy.CopyToTarget(link.spriteCollection);
                    link.spriteCollection.linkParent = data;
                    EditorUtility.SetDirty(link.spriteCollection);

                    tk2dSpriteCollectionBuilder.Rebuild(link.spriteCollection);
                }
                else
                {
                    errors += thisErrors;
                }
            }

            if (errors.Length > 0)
            {
                Debug.LogError("There were " + errorCount.ToString() + " errors building the sprite collection\n" + errors);
            }
        }
        public static void Build(tk2dSpriteCollection data)
        {
            if (data.linkedSpriteCollections.Count > 0 && !data.disableTrimming) {
                return;
            }

            string errors = "";
            int errorCount = 0;
            string root = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(data)) + "/Linked";
            foreach (tk2dLinkedSpriteCollection link in data.linkedSpriteCollections) {
                if (link.spriteCollection == null) {
                    if (!System.IO.Directory.Exists(root)) {
                        System.IO.Directory.CreateDirectory(root);
                    }
                    link.spriteCollection = tk2dSpriteCollectionEditor.CreateSpriteCollection(root, data.name + link.name);
                }

                tk2dEditor.SpriteCollectionEditor.SpriteCollectionProxy proxy = new tk2dEditor.SpriteCollectionEditor.SpriteCollectionProxy(data, false);
                proxy.CopyBuiltFromSource(link.spriteCollection);
                proxy.linkedSpriteCollections.Clear(); // stop recursion
                string thisErrors = "";

                foreach (tk2dSpriteCollectionDefinition tp in proxy.textureParams) {
                    if (tp.texture != null) {
                        Texture2D repl = FindReplacementTexture(tp.texture, link.name);
                        if (repl == null) {
                            thisErrors += string.Format("Unable to find replacement for texture '{0}' for link '{1}'\n", tp.texture.name, link.name);
                            ++errorCount;
                        }
                        tp.texture = repl;
                    }
                }

                if (thisErrors.Length == 0) {
                    proxy.CopyToTarget(link.spriteCollection);
                    link.spriteCollection.linkParent = data;
                    EditorUtility.SetDirty(link.spriteCollection);

                    tk2dSpriteCollectionBuilder.Rebuild(link.spriteCollection);
                }
                else {
                    errors += thisErrors;
                }
            }

            if (errors.Length > 0) {
                Debug.LogError("There were " + errorCount.ToString() + " errors building the sprite collection\n" + errors);
            }
        }