private void CreateCardCallback(object obj) { var card = new Card(); var cardType = obj as CardType; card.cardTypeId = cardType.id; if (cardType != null) { foreach (var property in cardType.properties) { if (property is IntProperty) { var propertyCopy = new IntProperty(); propertyCopy.name = property.name; propertyCopy.value = (property as IntProperty).value; card.properties.Add(propertyCopy); } else if (property is StringProperty) { var propertyCopy = new StringProperty(); propertyCopy.name = property.name; propertyCopy.value = (property as StringProperty).value; card.properties.Add(propertyCopy); } } foreach (var stat in cardType.stats) { var statCopy = new Stat(); statCopy.statId = stat.id; statCopy.name = stat.name; statCopy.baseValue = stat.baseValue; statCopy.originalValue = stat.originalValue; statCopy.minValue = stat.minValue; statCopy.maxValue = stat.maxValue; card.stats.Add(statCopy); } } currentCardSet.cards.Add(card); }
private void DrawProperty(Property property) { var oldLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 100; GUILayout.BeginVertical(); property.Draw(); if (GUILayout.Button("Copy to cards", GUILayout.MaxWidth(100))) { foreach (var set in gameConfig.cardSets) { foreach (var card in set.cards.FindAll(x => x.cardTypeId == currentCardType.id)) { if (property is IntProperty) { var propertyCopy = new IntProperty(); propertyCopy.name = property.name; propertyCopy.value = (property as IntProperty).value; card.properties.Add(propertyCopy); } else if (property is StringProperty) { var propertyCopy = new StringProperty(); propertyCopy.name = property.name; propertyCopy.value = (property as StringProperty).value; card.properties.Add(propertyCopy); } } } } GUILayout.EndVertical(); EditorGUIUtility.labelWidth = oldLabelWidth; }