UnityEditor.AssetStoreContext.OpenPackageInternal C# (CSharp) Method

OpenPackageInternal() public static method

public static OpenPackageInternal ( string id ) : bool
id string
return bool
        public static bool OpenPackageInternal(string id)
        {
            Match match = s_GeneratedIDRegExp.Match(id);
            if (match.Success && File.Exists(match.Groups[1].Value))
            {
                AssetDatabase.ImportPackage(match.Groups[1].Value, true);
                return true;
            }
            foreach (PackageInfo info in PackageInfo.GetPackageList())
            {
                if (info.jsonInfo != string.Empty)
                {
                    JSONValue value2 = JSONParser.SimpleParse(info.jsonInfo);
                    string str = !value2.Get("id").IsNull() ? value2["id"].AsString(true) : null;
                    if (((str != null) && (str == id)) && File.Exists(info.packagePath))
                    {
                        AssetDatabase.ImportPackage(info.packagePath, true);
                        return true;
                    }
                }
            }
            Debug.LogError("Unknown package ID " + id);
            return false;
        }

Usage Example

示例#1
0
        void DownloadPackage()
        {
            AssetStoreAsset.PreviewInfo item = m_Asset.previewInfo;
            m_Purchasing          = PurchaseStatus.Downloading;
            item.downloadProgress = 0;
            item.buildProgress    = -1f;

            AssetStoreContext.Download(m_Asset.packageID.ToString(), item.packageUrl, item.encryptionKey, item.packageName,
                                       item.publisherName, item.categoryName, delegate(string id, string status, int bytes, int total) {
                if (this == null)
                {
                    return;                   // aborted
                }
                item.downloadProgress = -1f;
                if (status != "ok")
                {
                    Debug.LogErrorFormat("Error downloading package {0} ({1})", item.packageName, id);
                    Debug.LogError(status);
                    Close();
                    return;
                }

                if (m_Asset == null || m_Purchasing != PurchaseStatus.Downloading || id != m_Asset.packageID.ToString())
                {
                    // Aborted
                    Close();
                }

                if (!AssetStoreContext.OpenPackageInternal(id))
                {
                    Debug.LogErrorFormat("Error importing package {0} ({1})", item.packageName, id);
                }
                Close();
            });
        }
All Usage Examples Of UnityEditor.AssetStoreContext::OpenPackageInternal