public bool AssignAsset(string guid, string name, string variant) { if (m_ResourceCollection.AssignAsset(guid, name, variant)) { if (OnAssetAssigned != null) { OnAssetAssigned(new SourceAsset[] { GetSourceAsset(guid) }); } return(true); } return(false); }
public bool SyncFromProject() { ResourceCollection resourceCollection = new ResourceCollection(); string[] assetBundleNames = GetUsedAssetBundleNames(); foreach (string assetBundleName in assetBundleNames) { string name = assetBundleName; string variant = null; int dotPosition = assetBundleName.LastIndexOf('.'); if (dotPosition > 0 && dotPosition < assetBundleName.Length - 1) { name = assetBundleName.Substring(0, dotPosition); variant = assetBundleName.Substring(dotPosition + 1); } if (!resourceCollection.AddResource(name, variant, null, LoadType.LoadFromFile, false)) { return(false); } string[] assetNames = GetAssetPathsFromAssetBundle(assetBundleName); foreach (string assetName in assetNames) { string guid = AssetDatabase.AssetPathToGUID(assetName); if (string.IsNullOrEmpty(guid)) { return(false); } if (!resourceCollection.AssignAsset(guid, name, variant)) { return(false); } } } return(resourceCollection.Save()); }