UI: 'GetComponent' not showing up in Inspector.
Hello,
I'm trying to build a Game Over Screen with the newer UI, and I followed the same steps that I used while setting up my Title Menu, but for some reason I'm having an issue. In the Inspector where the 'GetComponent' will usually have spaces to drag in buttons and a canvas, there is just a space displaying the 'GameOver' Script.
Here's the one I have that's working, for reference: 
And here is the one that I'm having issues with: 
I'm really not to great with code, but perhaps I haven't told my script to expose them to the inspector? If I've done something completely wrong in my code, please let me know so I can improve! Here is a copy of my code:
 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 
 public class GameOverUI : MonoBehaviour {
 
     int score = 0;
     private bool retry;
 
     public Canvas gameOver;
     public Button retryLevel;
     public Button returnMain;
 
    
     void Start ()
     {
         score = PlayerPrefs.GetInt("Score");
         gameOver = gameOver.GetComponent<Canvas>();
         retryLevel = retryLevel.GetComponent<Button>();
         returnMain = returnMain.GetComponent<Button>();
         gameOver.enabled = true;
     }
     
     public void RetryLevel()
     {
         Application.LoadLevel(1);                    //Level that is my game
     }
     public void ReturnToMainMenu()
     {
         Application.LoadLevel(0);                    //Level that is the Title Menu
     }
 }
 
 
               Also, you will probably see I have a variable declared for 'score' that isn't used in the code. I have a high score that grows based on time that's passed, and amount of power-ups picked up, and would like to add that to my 'Game Over' screen, but am not sure how. Any advice there would be great also!
Answer by Cepheid · Nov 09, 2015 at 12:17 AM
Have you tried removing and re-adding the script or even restarting the Unity editor? Sometimes the Inspector has some weird serialization issues which are usually fixed for me by re-opening the editor or re-adding a script. I say this because, when I copy and pasted your code into my own test project. The fields appeared in the Inspector just fine. Here's an example:

Wow, it really was just as simple as that... Is this a common problem with Unity? Are there other areas that this problem pops up that I should keep an eye out for?
Your answer
 
             Follow this Question
Related Questions
Responsive UI 0 Answers
Dynamic Menu C# 0 Answers
How do I keep two UI text unity3d on the scene 2 Answers
Reset Text 1 Answer