public bool Prepare()
 {
     m_ResourceCollection.Clear();
     return(m_ResourceCollection.Load());
 }
        public bool Load()
        {
            if (!File.Exists(m_ConfigurationPath))
            {
                return(false);
            }

            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(m_ConfigurationPath);
                XmlNode xmlRoot     = xmlDocument.SelectSingleNode("UnityGameFramework");
                XmlNode xmlEditor   = xmlRoot.SelectSingleNode("ResourceEditor");
                XmlNode xmlSettings = xmlEditor.SelectSingleNode("Settings");

                XmlNodeList xmlNodeList = null;
                XmlNode     xmlNode     = null;

                xmlNodeList = xmlSettings.ChildNodes;
                for (int i = 0; i < xmlNodeList.Count; i++)
                {
                    xmlNode = xmlNodeList.Item(i);
                    switch (xmlNode.Name)
                    {
                    case "SourceAssetRootPath":
                        SourceAssetRootPath = xmlNode.InnerText;
                        break;

                    case "SourceAssetSearchPaths":
                        m_SourceAssetSearchRelativePaths.Clear();
                        XmlNodeList xmlNodeListInner = xmlNode.ChildNodes;
                        XmlNode     xmlNodeInner     = null;
                        for (int j = 0; j < xmlNodeListInner.Count; j++)
                        {
                            xmlNodeInner = xmlNodeListInner.Item(j);
                            if (xmlNodeInner.Name != "SourceAssetSearchPath")
                            {
                                continue;
                            }

                            m_SourceAssetSearchRelativePaths.Add(xmlNodeInner.Attributes.GetNamedItem("RelativePath").Value);
                        }
                        break;

                    case "SourceAssetUnionTypeFilter":
                        SourceAssetUnionTypeFilter = xmlNode.InnerText;
                        break;

                    case "SourceAssetUnionLabelFilter":
                        SourceAssetUnionLabelFilter = xmlNode.InnerText;
                        break;

                    case "SourceAssetExceptTypeFilter":
                        SourceAssetExceptTypeFilter = xmlNode.InnerText;
                        break;

                    case "SourceAssetExceptLabelFilter":
                        SourceAssetExceptLabelFilter = xmlNode.InnerText;
                        break;

                    case "AssetSorter":
                        AssetSorter = (AssetSorterType)Enum.Parse(typeof(AssetSorterType), xmlNode.InnerText);
                        break;
                    }
                }

                RefreshSourceAssetSearchPaths();
            }
            catch
            {
                File.Delete(m_ConfigurationPath);
                return(false);
            }

            ScanSourceAssets();

            m_ResourceCollection.Load();

            return(true);
        }
        public bool SyncToProject()
        {
            ResourceCollection resourceCollection = new ResourceCollection();

            resourceCollection.OnLoadingResource += delegate(int index, int count)
            {
                if (OnLoadingResource != null)
                {
                    OnLoadingResource(index, count);
                }
            };

            resourceCollection.OnLoadingAsset += delegate(int index, int count)
            {
                if (OnLoadingAsset != null)
                {
                    OnLoadingAsset(index, count);
                }
            };

            resourceCollection.OnLoadCompleted += delegate()
            {
                if (OnCompleted != null)
                {
                    OnCompleted();
                }
            };

            if (!resourceCollection.Load())
            {
                return(false);
            }

            int assetIndex = 0;
            int assetCount = resourceCollection.AssetCount;

            Resource[] resources = resourceCollection.GetResources();
            foreach (Resource resource in resources)
            {
                if (resource.IsLoadFromBinary)
                {
                    continue;
                }

                Asset[] assets = resource.GetAssets();
                foreach (Asset asset in assets)
                {
                    AssetImporter assetImporter = AssetImporter.GetAtPath(asset.Name);
                    if (assetImporter == null)
                    {
                        if (OnCompleted != null)
                        {
                            OnCompleted();
                        }

                        return(false);
                    }

                    assetImporter.assetBundleName    = resource.Name;
                    assetImporter.assetBundleVariant = resource.Variant;
                    assetImporter.SaveAndReimport();

                    if (OnResourceDataChanged != null)
                    {
                        OnResourceDataChanged(++assetIndex, assetCount, asset.Name);
                    }
                }
            }

            if (OnCompleted != null)
            {
                OnCompleted();
            }

            return(true);
        }