Reputation: 23
enter image description hereI have followed the tutorial on how to make a game of Brackeys from YouTube and I'm stuck on video no. 7 and I can't figure out how to resolve the problem. Please help.
The code is at 7:36
using UnityEngine;
using UnityEngine UI;
public class Score : MonoBehaviour
{
public Transform player;
public Text scoreText;
void Update()
{
scoreText.text = player.position.z.ToString("0");
}
}
Upvotes: 2
Views: 1022
Reputation: 31
The error is in the second line of your code:
using UnityEngine;
using UnityEngine UI;
Should be changed to:
using UnityEngine;
using UnityEngine.UI;
You need a period to access another Namespace within the UnityEngine Namespace.
Upvotes: 3
Reputation: 977
First, check the second line of your code. using UnityEngine UI;
appears to missing a period between UnityEngine
and UI
. I believe this is the core of your problem and is causing the other two errors to pop up. The line should be using UnityEngine.UI;
.
Regardless, here is an explanation on how to figure out the route of a problem like this.
Please see the following two links for information regarding your two error codes. Remember that these are always available via a quick Google search:
Hope this helps!
Edit: thinking a minute more on the logic here and it's 100% the second line. Imagine how the compiler would interpret this. What it really see's when you miss that period is "two lines"
using UnityEngine
UI;
So it's looking at this and saying two things:
using UnityEngine
Kinda interesting when you think about why it is telling you that you have both of those errors.
Upvotes: 3