Search Unity

System.Serializable don't work with more than one class?

Discussion in 'Getting Started' started by Stradmann, Jan 29, 2019.

  1. Stradmann

    Stradmann

    Joined:
    Jun 11, 2018
    Posts:
    38
    Hi, I've two classes in my script apart from main class of script. These ones hold some variables I want to set in the inspector, but I only can see in the inspector the first class(MainMenuInterface) that have [System.Serializable]. I can't see in the inspector the variables of the second class(PauseMenuInterface). What can I do? How can I see two or more classes in the inspector?
    Code (CSharp):
    1. [System.Serializable]
    2. public class MainMenuInterface
    3. {
    4.     public GameObject mainMenuPanel;
    5.     public Button newGameButton;
    6.     public Button continueButton;
    7.     public Button quitButton;
    8.     public GameObject confirmationPanel;
    9.     public Button confirmButton;
    10.     public Button cancelButton;
    11. }
    12.  
    13. [System.Serializable]
    14. public class PauseMenuInterface
    15. {
    16.     public GameObject pauseMenuPanel;
    17.     public Button resumeGameButton;
    18.     public Button saveAndReturToMainMenuButton;
    19.     public Button saveAndQuitButton;
    20. }
    21.  
    22. public InterfaceController: MonoBehaviour
    23. {
    24.     ...
    25. }
    26.  
     
  2. You're doing something wrong.

    pi.PNG

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3.  
    4. [System.Serializable]
    5. public class MainMenuInterface
    6. {
    7.     public GameObject mainMenuPanel;
    8.     public Button newGameButton;
    9.     public Button continueButton;
    10.     public Button quitButton;
    11.     public GameObject confirmationPanel;
    12.     public Button confirmButton;
    13.     public Button cancelButton;
    14. }
    15.  
    16. [System.Serializable]
    17. public class PauseMenuInterface
    18. {
    19.     public GameObject pauseMenuPanel;
    20.     public Button resumeGameButton;
    21.     public Button saveAndReturToMainMenuButton;
    22.     public Button saveAndQuitButton;
    23. }
    24.  
    25. public class Test : MonoBehaviour
    26. {
    27.     public MainMenuInterface mi;
    28.     public PauseMenuInterface pi;
    29. }
    30.  
     
  3. Stradmann

    Stradmann

    Joined:
    Jun 11, 2018
    Posts:
    38
    I can't see any diference between my code an yours, why it works for you? I'm missing something? systemSerializable.jpg
     
  4. Stradmann

    Stradmann

    Joined:
    Jun 11, 2018
    Posts:
    38
    Ok... it's just that i din't finshed another part of the main class code... sorry... and thanks a lot!!
     
    Kiwasi and Lurking-Ninja like this.