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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Can't access on Text-Object in Script...

Discussion in 'Getting Started' started by Mystical_XP, Jul 19, 2022.

  1. Mystical_XP

    Mystical_XP

    Joined:
    Oct 9, 2020
    Posts:
    2
    Hey Guys, how I already describe, I try to access a Text-Object in my hierarchy with a srcipt.
    But I already did it befor with only saying after the class... "public Text mytext", but that didnt woks actually...
    I dont know why... I use the Unity-Version: Unity 2020.3.24f Personal

    My final destination is to change a Text to show how many ammo do you have in your weapon...

    Maby you are able to solve my problem, that will help alot :|

    I already seached in the Internet... i just find noting that helped. :c

    Thanks for reading :)

    I can read also german comments
     

    Attached Files:

  2. Mystical_XP

    Mystical_XP

    Joined:
    Oct 9, 2020
    Posts:
    2
    A better Version of my code cause I forgot to Implement the Error and show what for an Type of Error results.

    The console says: The type or namespace name 'text' was not found (a using directive or an assembly reference may be missing).
     

    Attached Files:

  3. unity_c4XUw_uyL-8BJw

    unity_c4XUw_uyL-8BJw

    Joined:
    Jul 19, 2021
    Posts:
    1
    replace the header
    using UnityEditor.UIElements ->
    using UnityEngine.UI