Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Game Data Editor using an EditorWindow

Discussion in '2D' started by dfcs1107, Aug 13, 2020.

  1. dfcs1107

    dfcs1107

    Joined:
    Oct 18, 2019
    Posts:
    3
    Hello guys! I am starting my unity development self-learning journey. Since I am a beginner I have many questions. I am using an EditorWindow to edit my game data, to load and save it.

    Code (CSharp):
    1. if (gameData!=null)
    2.         {
    3.             SerializedObject serializedObject = new SerializedObject(this);
    4.             SerializedProperty serializedProperty = serializedObject.FindProperty("gameData");
    5.  
    6.             EditorGUILayout.PropertyField(serializedProperty, true);
    7.  
    8.             serializedObject.ApplyModifiedProperties();
    9.  
    10.             if (GUILayout.Button("Save data"))
    11.             {
    12.                 SaveGameData();
    13.             }
    14.  
    15.             if (GUILayout.Button("Load data"))
    16.             {
    17.                 LoadGameData();
    18.             }
    Unfortunately, I can't understand why in my editor window I just can manage attributes of my classes.
    For example, if I have a class Question with this:
    Code (CSharp):
    1. public AnswerOptionText[] Answers ;
    -> The answers appear in my editor window.

    Code (CSharp):
    1. public AnswerOptionText[] Answers { get; set; }
    -> The answers doesn't appear in my editor window.

    I need to use class properties, is there any way to use it and manage it on my editor window?
    If someone can help me I would be very grateful. Thanks.
     
  2. kukurenaiz

    kukurenaiz

    Joined:
    Sep 12, 2017
    Posts:
    57
    Last edited: Aug 13, 2020
    dfcs1107 likes this.
  3. dfcs1107

    dfcs1107

    Joined:
    Oct 18, 2019
    Posts:
    3
    It is working now! Problem solved, thanks a lot!
     
    kukurenaiz likes this.