GetPackageList() private method

private GetPackageList ( ) : UnityEditor.PackageInfo[]
return UnityEditor.PackageInfo[]
        public static bool OpenPackageInternal(string id)
        {
            Match match = AssetStoreContext.s_GeneratedIDRegExp.Match(id);

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

            if (match.Success && File.Exists(match.Groups[1].Value))
            {
                AssetDatabase.ImportPackage(match.Groups[1].Value, true);
                return(true);
            }
            PackageInfo[] packageList = PackageInfo.GetPackageList();
            for (int i = 0; i < packageList.Length; i++)
            {
                PackageInfo packageInfo = packageList[i];
                if (packageInfo.jsonInfo != string.Empty)
                {
                    JSONValue jSONValue = JSONParser.SimpleParse(packageInfo.jsonInfo);
                    string    text      = (!jSONValue.Get("id").IsNull()) ? jSONValue["id"].AsString(true) : null;
                    if (text != null && text == id && File.Exists(packageInfo.packagePath))
                    {
                        AssetDatabase.ImportPackage(packageInfo.packagePath, true);
                        return(true);
                    }
                }
            }
            Debug.LogError("Unknown package ID " + id);
            return(false);
        }
示例#3
0
        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);
        }
        public static bool OpenPackageInternal(string id)
        {
            Match match = s_GeneratedIDRegExp.Match(id);

            if (match.Success && File.Exists(match.Groups[1].Value)) // If id looks like a path name, just try to open that
            {
                AssetDatabase.ImportPackage(match.Groups[1].Value, true);
                return(true);
            }
            else
            {
                foreach (PackageInfo package in PackageInfo.GetPackageList())
                {
                    if (package.jsonInfo != "")
                    {
                        JSONValue item   = JSONParser.SimpleParse(package.jsonInfo);
                        string    itemID = item.Get("id").IsNull() ? null : item["id"].AsString(true);
                        if (itemID != null && itemID == id && File.Exists(package.packagePath))
                        {
                            AssetDatabase.ImportPackage(package.packagePath, true);
                            return(true);
                        }
                    }
                }
            }
            Debug.LogError("Unknown package ID " + id);
            return(false);
        }
        public PackageList GetPackageList()
        {
            Dictionary <string, Package> dictionary = new Dictionary <string, Package>();

            PackageInfo[] packageList = PackageInfo.GetPackageList();
            foreach (PackageInfo info in packageList)
            {
                Package package = new Package();
                if (info.jsonInfo == "")
                {
                    package.title = Path.GetFileNameWithoutExtension(info.packagePath);
                    package.id    = info.packagePath;
                    if (this.IsBuiltinStandardAsset(info.packagePath))
                    {
                        LabelAndId id = new LabelAndId {
                            label = "Unity Technologies",
                            id    = "1"
                        };
                        package.publisher = id;
                        id = new LabelAndId {
                            label = "Prefab Packages",
                            id    = "4"
                        };
                        package.category = id;
                        package.version  = "3.5.0.0";
                    }
                }
                else
                {
                    JSONValue json = JSONParser.SimpleParse(info.jsonInfo);
                    if (json.IsNull())
                    {
                        continue;
                    }
                    package.Initialize(json);
                    if (package.id == null)
                    {
                        JSONValue value3 = json.Get("link.id");
                        if (!value3.IsNull())
                        {
                            package.id = value3.AsString();
                        }
                        else
                        {
                            package.id = info.packagePath;
                        }
                    }
                }
                package.local_icon = info.iconURL;
                package.local_path = info.packagePath;
                if (((!dictionary.ContainsKey(package.id) || (dictionary[package.id].version_id == null)) || (dictionary[package.id].version_id == "-1")) || (((package.version_id != null) && (package.version_id != "-1")) && (int.Parse(dictionary[package.id].version_id) <= int.Parse(package.version_id))))
                {
                    dictionary[package.id] = package;
                }
            }
            Package[] packageArray = dictionary.Values.ToArray <Package>();
            return(new PackageList {
                results = packageArray
            });
        }
        public AssetStoreContext.PackageList GetPackageList()
        {
            Dictionary <string, AssetStoreContext.Package> dictionary = new Dictionary <string, AssetStoreContext.Package>();

            foreach (PackageInfo package1 in PackageInfo.GetPackageList())
            {
                AssetStoreContext.Package package2 = new AssetStoreContext.Package();
                if (package1.jsonInfo == string.Empty)
                {
                    package2.title = Path.GetFileNameWithoutExtension(package1.packagePath);
                    package2.id    = package1.packagePath;
                    if (this.IsBuiltinStandardAsset(package1.packagePath))
                    {
                        package2.publisher = new AssetStoreContext.LabelAndId()
                        {
                            label = "Unity Technologies",
                            id    = "1"
                        };
                        package2.category = new AssetStoreContext.LabelAndId()
                        {
                            label = "Prefab Packages",
                            id    = "4"
                        };
                        package2.version = "3.5.0.0";
                    }
                }
                else
                {
                    JSONValue json = JSONParser.SimpleParse(package1.jsonInfo);
                    if (!json.IsNull())
                    {
                        package2.Initialize(json);
                        if (package2.id == null)
                        {
                            JSONValue jsonValue = json.Get("link.id");
                            package2.id = jsonValue.IsNull() ? package1.packagePath : jsonValue.AsString();
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                package2.local_icon = package1.iconURL;
                package2.local_path = package1.packagePath;
                if (!dictionary.ContainsKey(package2.id) || dictionary[package2.id].version_id == null || dictionary[package2.id].version_id == "-1" || package2.version_id != null && package2.version_id != "-1" && int.Parse(dictionary[package2.id].version_id) <= int.Parse(package2.version_id))
                {
                    dictionary[package2.id] = package2;
                }
            }
            AssetStoreContext.Package[] array = dictionary.Values.ToArray <AssetStoreContext.Package>();
            return(new AssetStoreContext.PackageList()
            {
                results = array
            });
        }
        public AssetStoreContext.PackageList GetPackageList()
        {
            Dictionary <string, AssetStoreContext.Package> dictionary = new Dictionary <string, AssetStoreContext.Package>();

            PackageInfo[] packageList = PackageInfo.GetPackageList();
            PackageInfo[] array       = packageList;
            int           i           = 0;

            while (i < array.Length)
            {
                PackageInfo packageInfo           = array[i];
                AssetStoreContext.Package package = new AssetStoreContext.Package();
                if (packageInfo.jsonInfo == string.Empty)
                {
                    package.title = Path.GetFileNameWithoutExtension(packageInfo.packagePath);
                    package.id    = packageInfo.packagePath;
                    if (this.IsBuiltinStandardAsset(packageInfo.packagePath))
                    {
                        package.publisher = new AssetStoreContext.LabelAndId
                        {
                            label = "Unity Technologies",
                            id    = "1"
                        };
                        package.category = new AssetStoreContext.LabelAndId
                        {
                            label = "Prefab Packages",
                            id    = "4"
                        };
                        package.version = "3.5.0.0";
                    }
                    goto IL_144;
                }
                JSONValue json = JSONParser.SimpleParse(packageInfo.jsonInfo);
                if (!json.IsNull())
                {
                    package.Initialize(json);
                    if (package.id != null)
                    {
                        goto IL_144;
                    }
                    JSONValue jSONValue = json.Get("link.id");
                    if (!jSONValue.IsNull())
                    {
                        package.id = jSONValue.AsString();
                        goto IL_144;
                    }
                    package.id = packageInfo.packagePath;
                    goto IL_144;
                }
IL_203:
                i++;
                continue;
IL_144:
                package.local_icon = packageInfo.iconURL;
                package.local_path = packageInfo.packagePath;
                if (!dictionary.ContainsKey(package.id) || dictionary[package.id].version_id == null || dictionary[package.id].version_id == "-1" || (package.version_id != null && package.version_id != "-1" && int.Parse(dictionary[package.id].version_id) <= int.Parse(package.version_id)))
                {
                    dictionary[package.id] = package;
                    goto IL_203;
                }
                goto IL_203;
            }
            AssetStoreContext.Package[] results = dictionary.Values.ToArray <AssetStoreContext.Package>();
            return(new AssetStoreContext.PackageList
            {
                results = results
            });
        }
        public PackageList GetPackageList()
        {
            var packages     = new Dictionary <string, Package>();
            var packageInfos = PackageInfo.GetPackageList();

            foreach (PackageInfo info in packageInfos)
            {
                Package package = new Package();
                if (info.jsonInfo == "")
                {
                    package.title = System.IO.Path.GetFileNameWithoutExtension(info.packagePath);
                    package.id    = info.packagePath;

                    if (IsBuiltinStandardAsset(info.packagePath))
                    {
                        package.publisher = new LabelAndId {
                            label = "Unity Technologies", id = "1"
                        };
                        package.category = new LabelAndId {
                            label = "Prefab Packages", id = "4"
                        };
                        package.version = "3.5.0.0";
                    }
                }
                else
                {
                    var jsonData = JSONParser.SimpleParse(info.jsonInfo);
                    if (jsonData.IsNull())
                    {
                        continue;
                    }

                    package.Initialize(jsonData);

                    if (package.id == null)
                    {
                        var linkId = jsonData.Get("link.id");
                        if (!linkId.IsNull())
                        {
                            package.id = linkId.AsString();
                        }
                        else
                        {
                            package.id = info.packagePath;
                        }
                    }
                }

                package.local_icon = info.iconURL;
                package.local_path = info.packagePath;

                // If no package with the same ID is in the dictionary yet or if the current package
                // is newer than what we currently have in the dictionary, add the package to the
                // dictionary.
                if (!packages.ContainsKey(package.id) ||
                    packages[package.id].version_id == null ||
                    packages[package.id].version_id == "-1" ||
                    (package.version_id != null && package.version_id != "-1" && Int32.Parse(packages[package.id].version_id) <= Int32.Parse(package.version_id)))
                {
                    packages[package.id] = package;
                }
            }

            var results = packages.Values.ToArray();

            return(new PackageList {
                results = results
            });
        }