textComponent is not appearing in Inspector as shown in the video

I am using VS 2019 and 2019.3.8f1.

My code matches exactly what is shown in the lecture, but I don’t see the Text component being added in the Inspector.:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class AdventureGame : MonoBehaviour
{
    [SerializeField] Text textComponent;
    
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

This topic seems to have had the same problem, but the “answer” posted is no help in figuring out what fixed it. I'm not getting text component please help

In talking to a friend that knows Unity we still couldn’t figure out why this was failing. He wrote the same code using 2019.3.6f1 and it worked fine. He sent that to me and it looked fine when I loaded it into my 2019.3.9f1 version.

So at his suggestion I closed out my Unity session and re-opened it. Now the component showed correctly.

So the question still remains: Why is it not working like in the demo?

It will be a big hindrance if I have to close it and re=open every time I add a component in the C# script like this.

Mike

Hi,

Is your script saved correctly? Have you tried to restart Unity? Have you tried to remove and to reassign the script?

There seems to be a message in your console which claims there were compiler error. Since your script looks fine, I suspect there could be an issue with Visual Studio. Please watch lecture “Fixing Visual Studio Problems” (currently #4).

Hi Nina,

Now that you mention it I see the message at the bottom of the screen. I had missed that. Not sure why it is there, because when I exited Unity and brought the project back up in Unity it was fine. The changes had certainly been saved and my code matched exactly what was being shown in the video.

I have noticed that I am not getting completion of the text as I type it for most things, so I intend to look at the settings to see if that is somehow turned off. That might also be preventing it from flagging errors when I look at it in VS2019.

Mike

That sounds like a problem with Visual Studio. Please watch lecture “Fixing Visual Studio Problems” (currently #4).

Is the project otherwise working now?

Yes, it was an issue with VS. The video helped me to fix it. I had re-installed VS on a new system, so I had to review the video to figure it out.

Thanks.

Mike

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms