Context: I am making a 2d platforming game ive created a canvas it has a Text script attached, it shows in game. The piece of code bellow cant find the Text type used by the canvas . (im new to this stuff its assignment work an this has stopped me) Unity cant find the ‘definition for Text type’ even though i am using UnityEngine.UI i don’t know what to do.
(ScoreManager.cs)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ScoreManager : MonoBehaviour {
public Text scoreText;
public float scoreCount;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
scoreText.Text = "Food: " + scoreCount;
}
}
(Pickup.cs)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pickup : MonoBehaviour {
public int scoreToGive;
private ScoreManager theScoreManager;
void Start () {
theScoreManager = FindObjectOfType();
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.name == “CharacterRobotBoy”)
{
theScoreManager.scoreCount += scoreToGive;
Destroy(gameObject);
}
}
}