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

Survival Shooter tutorial: part 8 error

Discussion in 'Community Learning & Teaching' started by fishZombie, Mar 13, 2015.

  1. fishZombie

    fishZombie

    Joined:
    Apr 28, 2014
    Posts:
    8
    Assets/Plugins/SPT_PathDrawing/Example Scene Assets/Scripts/HudScriptTest.cs(11,9): error CS0246: The type or namespace name `Text' could not be found. Are you missing a using directive or an assembly reference?


    It seems to have a problem with the line:
    Text text;
    and this:
    text = GetComponent <Text> ();

    The capitalized word Text is RED, and every mention of it, in the script is also RED.
    Is there a new way to address the text component?

    -b
     
  2. fishZombie

    fishZombie

    Joined:
    Apr 28, 2014
    Posts:
    8
    Fount this one out. when I make a script from scratch. it does not have this line at the top:
    using UnityEngine.UI;
    This was missing, and so the Text line was red.
     
  3. Socrates

    Socrates

    Joined:
    Mar 29, 2011
    Posts:
    786
    For future reference: Unless you are using a custom script template, you will always have to add in any "using" UI or other features in Unity or scripting packages you use. Only the base "UnityEngine" for Unity and "System.Collections" for C# are included in there by default. MonoDevelop marking the text in red is it's way of saying, "I don't know what this means." When you see it, you either misspelled something or you didn't include a "using" directive.

    Also, please use code tags when you post. It makes it so much easier to read what you're putting up and to help you in the future. Click the Insert button to find them.