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:
57799-good-example.png

And here is the one that I’m having issues with:
57800-bad-example.png

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!

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:

alt text