Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Getting Error CS1061

Discussion in 'Scripting' started by jaywulf, Sep 20, 2017.

  1. jaywulf

    jaywulf

    Joined:
    Sep 14, 2017
    Posts:
    2
    So i started using unity a few days ago and was following a tutorial and when i had to create a UI Text it came up with an error stating i was missing an assembly reference. Any ideas??
    I am also using Unity 2017.1.0f3 if it makes any difference

    Error:
    Assets/Scripts/PlayerController.cs(42,13): error CS1061: Type `UnityEngine.Texture' does not contain a definition for `Text' and no extension method `Text' of type `UnityEngine.Texture' could be found. Are you missing an assembly reference?

    My Code:
    Code (CSharp):
    1. ..
    2. using UnityEngine.UI;
    3.     ...
    4.     public Text countText;
    5.     ..
    6.     private int count;
    7.  
    8.     void Start ()
    9.     {
    10.          ...
    11.         count = 0;
    12.         SetCountText ();
    13.     }
    14.     ....
    15.     //Collision (destroy object tag)
    16.     void OnTriggerEnter(Collider other)
    17.     {
    18.         if (other.gameObject.CompareTag ("Pick Up"))
    19.         {
    20.             other.gameObject.SetActive (false);
    21.             count = count + 1;
    22.             SetCountText ();
    23.         }
    24.     }
    25.     void SetCountText ()
    26.     {
    27.         countText.Text = "Count: " + count.ToString ();
    28.     }
    29. }
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    countText.Text should be

    countText.text with the lower case. Caps are important. That might be enough to fix the error.

    Though it seems to think you are declaring a texture and trying to access the text part of it...hmm...
     
    jaywulf likes this.
  3. jaywulf

    jaywulf

    Joined:
    Sep 14, 2017
    Posts:
    2
    Thank you so much, cant believe it was such a small problem. Its working perfectly now.
    Thanks Again
     
    TaleOf4Gamers likes this.
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    Good to know it's fixed!