internal static AssetDescriptor CreateInstanceFromLocalPackage(string filepath) { Type t = GetTypeFor(filepath); AssetDescriptor desc = ScriptableObject.CreateInstance(t.FullName) as AssetDescriptor; if (t == typeof(AssetDescriptor)) { desc.unityPackagePath = filepath; } desc.name = Path.GetFileNameWithoutExtension(filepath); desc.packageType = AssetDescriptor.PackageType.LocalAsset; return(desc); }
/// <summary> /// Return the position of the asset described in this list. /// </summary> /// <param name="desc">Position in the list or -1 if no in the list.</param> /// <returns></returns> internal int GetPositionOf(AssetDescriptor desc) { for (int i = 0; i < Descriptors.Count; i++) { if (Descriptors[i].name == desc.name) { // TODO Check version return(i); } else if (Descriptors[i].name == desc.name) { return(i); } } return(-1); }
private void RefreshPackageList() { updatedPackageList = new List <AssetDescriptor>(); // Local Assets // TODO make the location of local asset cache configurable ProcessAssetsDirectory(WorkflowSettings.assetCacheDirectory); // 3D TBD Collection for (int idx = 0; idx < WorkflowSettings.openSourceGitURIs.Length; idx++) { updatedPackageList.Add(AssetDescriptor.CreateInstanceFromGitHub(WorkflowSettings.openSourceGitURIs[idx])); } // Internal Packages searchRequest = Client.SearchAll(); EditorApplication.update += PackageManagerListRequestProgress; }
void PackageManagerListRequestProgress() { if (searchRequest.IsCompleted) { if (searchRequest.Status == StatusCode.Success) { foreach (PackageInfo package in searchRequest.Result) { updatedPackageList.Add(AssetDescriptor.CreateInstanceFromPackageInfo(package)); } } else if (searchRequest.Status >= StatusCode.Failure) { Debug.LogError(searchRequest.Error.message); } EditorApplication.update -= PackageManagerListRequestProgress; CachedPackagesAndAssets = updatedPackageList.OrderBy(x => x.name).ToList(); } }
internal void Remove(string name) { for (int i = 0; i < Descriptors.Count; i++) { if (((Descriptors[i].IsLocalAsset || Descriptors[i].IsGitPackage) && Descriptors[i].name == name) || Descriptors[i].name == name) { AssetDescriptor desc = Descriptors[i]; Descriptors.RemoveAt(i); DescriptorIDs.RemoveAt(i); if (desc.isInstalled) { installedPackagesCache.Remove(desc); } else { notInstalledPackagesCache.Remove(desc); } availablePackagesCache.Add(desc); } } EditorUtility.SetDirty(this); }
internal bool Contains(AssetDescriptor desc) { return(GetPositionOf(desc) >= 0); }
public void OnEnable() { desc = (AssetDescriptor)target; }