public static AssetItem AssetItemFromJson(String jsonString) { AssetItem _item = new AssetItem(); if (string.IsNullOrEmpty(jsonString)) { return _item; } Hashtable _details = (Hashtable)JSON.JsonDecode(jsonString); return AssetItemFromHashTable(_details); }
public static AssetItem AssetItemFromHashTable(Hashtable details) { AssetItem _item = new AssetItem(); if (details == null) { return _item; } if (details.ContainsKey("Type")) _item.Type = (string)details["Type"]; if (details.ContainsKey("Name")) _item.Name = (string)details["Name"]; if (details.ContainsKey("Publisher")) _item.PublisherName = (string)details["Publisher"]; if (details.ContainsKey("Url")) _item.Url = (string)details["Url"]; if (details.ContainsKey("ThumbnailUrl")) _item.ThumbnailUrl = (string)details["ThumbnailUrl"]; if (details.ContainsKey("AssetStoreId")) { _item.AssetStoreId = (int)details["AssetStoreId"]; } if (details.ContainsKey("Version")) _item.LatestVersion = new VersionInfo((string)details["Version"]); if (details.ContainsKey("Ecosystem")) { _item.HasEcosystemContent = true; Hashtable _ecosystemDetails = (Hashtable)details["Ecosystem"]; if (_ecosystemDetails.ContainsKey("Categories")) { ArrayList _filters = (ArrayList)_ecosystemDetails["Categories"]; _item.EcosystemCategories = (String[]) _filters.ToArray( typeof( string ) ); } } return _item; }
void OnGUI_ScannerItem(AssetItem item,int rowIndex) { // get the row style string rowStyle ="Middle"; if (ProjectScanner.instance.AssetsCount==1) { rowStyle = "Alone"; }else if (rowIndex==0) { rowStyle = "First"; }else if (rowIndex == (ProjectScanner.instance.AssetsCount-1) ) { rowStyle = "Last"; } // define the row style based on the item properties. string rowStyleType = "Plain"; if (item.FoundInProject) { rowStyleType = "Green"; } GUILayout.BeginVertical(GUIContent.none,"Table Row "+rowStyleType+" "+rowStyle); GUILayout.BeginHorizontal(); string itemLabelSkin = ""; switch(item.Type) { case "PlayMaker": itemLabelSkin = "Label Round Green Small"; break; case "AssetStore": itemLabelSkin = "Label Round Violet Small"; break; case "Addon": itemLabelSkin = "Label Round Cyan Small"; break; default: itemLabelSkin = "Label Round Blue Small"; break; } GUILayout.Label(item.Type,itemLabelSkin,GUILayout.Width(70)); GUI.backgroundColor = Color.white; GUILayout.Label(item.Name,"Label Row "+rowStyleType,GUILayout.MinWidth(0)); GUILayout.FlexibleSpace(); if(mouseOverRowIndex==rowIndex ) { /* if (!ShowActionDetails) { if (GUILayout.Button("?","Button Small",GUILayout.Width(20))) { SelectedIndex = rowIndex; ShowActionDetails = true; Repaint(); } GUILayout.Space(5); } */ if (item.AssetStoreId>0) { if (GUILayout.Button("Asset Store","Button Small",GUILayout.Width(70))) { Application.OpenURL("com.unity3d.kharma:content/"+item.AssetStoreId); return; } } if (!string.IsNullOrEmpty(item.Url)) { if (GUILayout.Button("Website","Button Small",GUILayout.Width(70))) { Application.OpenURL(item.Url); return; } } /* if (false) { if (GUILayout.Button("Update","Button Small Red",GUILayout.Width(50))) { //DeleteItem(item); //ImportItem(item); Repaint (); GUIUtility.ExitGUI(); return; } if (GUILayout.Button("Delete","Button Small Red",GUILayout.Width(50))) { //DeleteItem(item); //Repaint (); GUIUtility.ExitGUI(); return; } GUILayout.Label("imported","Label Row "+rowStyleType,GUILayout.Width(50)); }else{ if (GUILayout.Button("Get","Button Small",GUILayout.Width(50))) { //ImportItem(item); Repaint (); GUIUtility.ExitGUI(); return; } } */ } GUILayout.EndHorizontal(); // tags GUILayout.BeginHorizontal(); if (item.FoundInProject) { GUILayout.Label(item.ProjectVersion.ToShortString(),"Tag Small "+rowStyleType); } //GUILayout.Label(category,"Tag Small "+rowStyleType); //GUILayout.Label(url,"Tag Small "+rowStyleType); /* if ((string)item.RawData["beta"]=="true") { GUI.contentColor = Color.yellow; GUILayout.Label("Beta","Tag Small "+rowStyleType); GUI.contentColor = Color.white; } */ GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); if(rowsArea!=null && rowIndex<rowsArea.Length) { rowsArea[rowIndex] = GUILayoutUtility.GetLastRect(); } }
void OnGUI_ScannerItem(AssetItem item,int rowIndex) { // get the row style string rowStyle ="Middle"; if (ProjectScanner.instance.AssetsCount==1) { rowStyle = "Alone"; }else if (rowIndex==0) { rowStyle = "First"; }else if (rowIndex == (ProjectScanner.instance.AssetsCount-1) ) { rowStyle = "Last"; } // define the row style based on the item properties. string rowStyleType = "Plain"; bool _needsUpdate = false; if (item.FoundInProject) { _needsUpdate = item.LatestVersion > item.ProjectVersion; if (_needsUpdate) { rowStyleType = "orange"; }else{ rowStyleType = "Green"; } } GUILayout.BeginVertical(GUIContent.none,"Table Row "+rowStyleType+" "+rowStyle); GUILayout.BeginHorizontal(); string itemLabelSkin = ""; switch(item.Type) { case "PlayMaker": itemLabelSkin = "Label Round Green Small"; break; case "AssetStore": itemLabelSkin = "Label Round Violet Small"; break; case "Addon": itemLabelSkin = "Label Round Cyan Small"; break; default: itemLabelSkin = "Label Round Blue Small"; break; } // GUILayout.Label(WebImageManager.GetWebImage(item.ThumbnailUrl,new Vector2(32,32)),"Icon"); GUILayout.Label(item.Type,itemLabelSkin,GUILayout.Width(70)); GUI.backgroundColor = Color.white; string _mainlabel = item.Name; if (item.FoundInProject && item.ProjectVersion.isDefined()) { _mainlabel +=" "+item.ProjectVersion; } if (_needsUpdate) { _mainlabel +=" <Color=#B20000>Update Pending</Color>"; } GUILayout.Label(_mainlabel,"Label Row "+rowStyleType,GUILayout.MinWidth(0)); GUILayout.FlexibleSpace(); if(mouseOverRowIndex==rowIndex ) { /* if (!ShowActionDetails) { if (GUILayout.Button("?","Button Small",GUILayout.Width(20))) { SelectedIndex = rowIndex; ShowActionDetails = true; Repaint(); } GUILayout.Space(5); } */ if (item.AssetStoreId>0) { if (GUILayout.Button("Asset Store","Button Small",GUILayout.Width(70))) { Application.OpenURL("com.unity3d.kharma:content/"+item.AssetStoreId); return; } } if (!string.IsNullOrEmpty(item.Url)) { if (GUILayout.Button("Website","Button Small",GUILayout.Width(70))) { Application.OpenURL(item.Url); return; } } /* if (false) { if (GUILayout.Button("Update","Button Small Red",GUILayout.Width(50))) { //DeleteItem(item); //ImportItem(item); Repaint (); GUIUtility.ExitGUI(); return; } if (GUILayout.Button("Delete","Button Small Red",GUILayout.Width(50))) { //DeleteItem(item); //Repaint (); GUIUtility.ExitGUI(); return; } GUILayout.Label("imported","Label Row "+rowStyleType,GUILayout.Width(50)); }else{ if (GUILayout.Button("Get","Button Small",GUILayout.Width(50))) { //ImportItem(item); Repaint (); GUIUtility.ExitGUI(); return; } } */ } if (item.HasEcosystemContent) { bool _Selected = ProjectScanner.instance.AssetsSelectedList.Contains(item.Name); bool _newSelection = GUILayout.Toggle(_Selected,"","Toggle",GUILayout.Width(15f)); if (_newSelection!=_Selected) { if (!_newSelection) { ProjectScanner.instance.AssetsSelectedList.Remove(item.Name); item.UnSelectAllCategories(); }else { ProjectScanner.instance.AssetsSelectedList.Add(item.Name); item.SelectAllCategories(); } } } GUILayout.EndHorizontal(); // tags GUILayout.BeginHorizontal(); GUILayout.Label(item.PublisherName,"Tag Small "+rowStyleType); if (item.LatestVersion.isDefined()) { GUILayout.Label(item.LatestVersion.ToShortString(),"Tag Small "+rowStyleType); } //GUILayout.Label(category,"Tag Small "+rowStyleType); //GUILayout.Label(url,"Tag Small "+rowStyleType); /* if ((string)item.RawData["beta"]=="true") { GUI.contentColor = Color.yellow; GUILayout.Label("Beta","Tag Small "+rowStyleType); GUI.contentColor = Color.white; } */ GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); if(rowsArea!=null && rowIndex<rowsArea.Length && Event.current.type == EventType.repaint) { rowsArea[rowIndex] = GUILayoutUtility.GetLastRect(); } }
void OnGUI_FilterButton(AssetItem item,string Category) { bool isOn = ArrayUtility.Contains(item.EcosystemSelectedCategories,Category); string ButtonFilterSkin = "Button Toggle "; if (isOn) { ButtonFilterSkin += "On"; }else{ ButtonFilterSkin += "Off"; } GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); GUILayout.Space(20f); bool _newIsOn = GUILayout.Toggle(isOn,""); if (_newIsOn!=isOn) { item.ToggleCategory(Category); filterTouched = true; } GUILayout.Label(Category,"Label Small"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); }
public static AssetItem AssetItemFromHashTable(Hashtable details) { AssetItem _item = new AssetItem(); if (details == null) { return _item; } if (details.ContainsKey("Type")) _item.Type = (string)details["Type"]; if (details.ContainsKey("Name")) _item.Name = (string)details["Name"]; if (details.ContainsKey("Publisher")) _item.PublisherName = (string)details["Publisher"]; if (details.ContainsKey("Url")) _item.Url = (string)details["Url"]; if (details.ContainsKey("AssetStoreId")) { _item.AssetStoreId = (int)details["AssetStoreId"]; } if (details.ContainsKey("Version")) _item.LatestVersion = VersionInfo.VersionInfoFromJson((string)details["Version"]); return _item; }