UnityEditor.AssetStoreContext.Package.Initialize C# (CSharp) Method

Initialize() public method

public Initialize ( UnityEditorInternal.JSONValue json ) : void
json UnityEditorInternal.JSONValue
return void
            public void Initialize(JSONValue json)
            {
                if (json.ContainsKey("title"))
                {
                    this.title = json["title"].AsString();
                }
                if (json.ContainsKey("id"))
                {
                    this.id = json["id"].AsString();
                }
                if (json.ContainsKey("version"))
                {
                    this.version = json["version"].AsString();
                }
                if (json.ContainsKey("version_id"))
                {
                    this.version_id = json["version_id"].AsString();
                }
                if (json.ContainsKey("local_icon"))
                {
                    this.local_icon = json["local_icon"].AsString();
                }
                if (json.ContainsKey("local_path"))
                {
                    this.local_path = json["local_path"].AsString();
                }
                if (json.ContainsKey("pubdate"))
                {
                    this.pubdate = json["pubdate"].AsString();
                }
                if (json.ContainsKey("description"))
                {
                    this.description = json["description"].AsString();
                }
                if (json.ContainsKey("publisher"))
                {
                    this.publisher = new AssetStoreContext.LabelAndId();
                    this.publisher.Initialize(json["publisher"]);
                }
                if (json.ContainsKey("category"))
                {
                    this.category = new AssetStoreContext.LabelAndId();
                    this.category.Initialize(json["category"]);
                }
                if (json.ContainsKey("link"))
                {
                    this.link = new AssetStoreContext.Link();
                    this.link.Initialize(json["link"]);
                }
            }

Usage Example

        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
            });
        }
All Usage Examples Of UnityEditor.AssetStoreContext.Package::Initialize
AssetStoreContext.Package