- Home /
List Contains false after playmode
I have a problem with the List function, and cant figure out how to solve this.
for example the Database Script
 public class GameDatabase : ScriptableObject
 {
     public List<Character> Characters = new List<Character>() 
     {
         new Character("Character1"),
         new Character("Character2")
     };
     public List<Character> characterParty = new List<Character>();
     public static GameDatabase instance;
 }
the character class:
 [System.Serializable]
 public class Character
 {
     public Character(string inName) 
     {
         Name = inName;
     }
     public string Name = string.Empty;
 }
now the gamedatabaseEditor:
 public class GameDatabaseEditor : EditorWindow {
     [MenuItem ("Example/Game Database")]
     static void init() 
     {
         EditorWindow.GetWindow (typeof(GameDatabaseEditor));
     }
     static int party;
     static Character partyC;
     void OnGUI() {
         party = EditorGUILayout.Popup("Add Character:",party,GameDatabase.instance.Characters.Select<Character,string>(x => x.Name).ToArray());
         partyC = GameDatabase.instance.Characters[party];
         GUILayout.BeginHorizontal(GUILayout.Width(areawidth));
             GUILayout.FlexibleSpace();
             if(GUILayout.Button("Add")) {
                 if (!GameDatabase.instance.characterParty.Contains(partyC) && GameDatabase.instance.characterParty.Count <= 3) {
                     GameDatabase.instance.characterParty.Add(partyC);
                     party = 0;
                 }
             }
         GUILayout.EndHorizontal();
     }
 }
I save the GameDatabase to a asset and reload it after playmode, so not data gets lost. My problem is that all the characters and parties are saved after reload, but if i press the Add button in the editor, the same character will be added to party list. this problem only happens after restart or after playmode.
i hope you understand my problem, or my wired english hm
Your answer
 
 
             Follow this Question
Related Questions
Set int to object from list? 0 Answers
Editor Script not saving after first time playing 2 Answers
Save and Load Function 2 Answers
How i can PlayerPrefs List<>? 0 Answers
How to save a progress by user with diferent users 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                