private void DrawCardInfo(DatabaseCard card) { EditorGUILayout.BeginHorizontal(); card.frontSprite = EditorGUILayout.ObjectField(card.frontSprite, typeof(Sprite), false, GUILayout.Width(60), GUILayout.Height(60)) as Sprite; card.backSprite = EditorGUILayout.ObjectField(card.backSprite, typeof(Sprite), false, GUILayout.Width(60), GUILayout.Height(60)) as Sprite; EditorGUILayout.Space(); GUILayout.FlexibleSpace(); card.quantity = Mathf.Max(0, EditorGUILayout.IntField(card.quantity, GUILayout.MaxWidth(50))); EditorGUILayout.Space(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Duplicate", GUILayout.ExpandWidth(false))) { DatabaseCard c = new DatabaseCard(card.frontSprite, card.backSprite, card.quantity); // Use `Insert` instead of `Add`, so when duplicating, the new card is shown below the original one _databaseCards.Insert(_databaseCards.IndexOf(card) + 1, c); } if (GUILayout.Button("Delete", GUILayout.ExpandWidth(false))) { _databaseCards.Remove(card); } EditorGUILayout.EndHorizontal(); }
public static DatabaseCard Search(string cardUrl, string language) { if (String.IsNullOrEmpty(language)) { return(null); } //string cardUrl = "http://yugioh.wikia.com/wiki/" + data.searchID; int langNum = language.Value(); DatabaseCard Card = new DatabaseCard(); HtmlDocument cardPage = null; try { cardPage = new HtmlWeb().Load(cardUrl); } catch { return(null); } if (cardPage == null) { return(null); } System.Threading.Thread.Sleep(15); //Card.Name = Set.Name(ref cardPage, langNum); //if (!Card.Name.IsEmpty()) // data.encodedName = Card.Name.UriEscape(); System.Threading.Thread.Sleep(15); new Task[] { Task.Run(() => { Card.Name = Set.Name(ref cardPage, langNum); }), Task.Run(() => { string[] Effect = Set.Effect(ref cardPage, language); if (!String.IsNullOrEmpty(Effect[0])) { Card.CardText = Effect[0]; } if (!String.IsNullOrEmpty(Effect[1])) { Card.PendulumEffect = Effect[1]; } }), Task.Run(() => { Card.Appearance = Set.Appearance(ref cardPage); }), Task.Run(() => { Card.Packs = Set.Packs(ref cardPage, langNum, language); }) }.WaitAll(); return(Card); }
private void DrawToolbar() { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); if (GUILayout.Button("New Card", EditorStyles.toolbarButton)) { DatabaseCard c = new DatabaseCard(defaultFrontSprite, defaultBackSprite, defaultQuantity); _databaseCards.Add(c); } if (GUILayout.Button("Delete All Cards", EditorStyles.toolbarButton)) { if (EditorUtility.DisplayDialog( "Delete all cards?", "Are you sure you want to delete all the cards in the database?", "Delete All", "Nope")) { _databaseCards.Clear(); } } EditorGUILayout.Space(); GUILayout.FlexibleSpace(); // Only in edit mode EditorGUI.BeginDisabledGroup(EditorApplication.isPlaying); if (GUILayout.Button("Delete Cards in Scene", EditorStyles.toolbarButton)) { DeleteAllCardsInScene(); } if (GUILayout.Button("Update Scene", EditorStyles.toolbarButton)) { DeleteAndInstantiateCardsInScene(); } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); }