unity-game-enginesyntax-error2d-games

Unity: error CS0246: The type or namespace name 'image' could not be found (are you missing a using directive or an assembly reference?)"


I was trying to make an ammunition counting system with images of bullets that disappear as the character fires the bullets. I was following this tutorial:

It seems okay but now I get this error:

"Assets \ Scripts \ GameFlow.cs (72,28): error CS0246: The type or namespace name 'image' could not be found (are you missing a directive or an assembly reference?)"

I can not see the problem. I thought I'd solve by putting "using UnityEngine.UI;" but the problem keeps. Anyone know how I can solve it? Thank you.

The code in the Script are:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class GameFlow : MonoBehaviour
{
public static float remainingShots = 6;
public Transform shot1;
public Transform shot2;
public Transform shot3;
public Transform shot4;
public Transform shot5;
public Transform shot6;

// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
  if (remainingShots > 0)
  {
    shot1.GetComponent<image> ().enabled = true;
  }
  else
  {
    shot1.GetComponent<image> ().enabled = false;
  }

  if (remainingShots > 1)
  {
    shot2.GetComponent<image> ().enabled = true;
  }
  else
  {
    shot2.GetComponent<image> ().enabled = false;
  }

  if (remainingShots > 2)
  {
    shot3.GetComponent<image> ().enabled = true;
  }
  else
  {
    shot3.GetComponent<image> ().enabled = false;
  }

  if (remainingShots > 3)
  {
    shot4.GetComponent<image> ().enabled = true;
  }
  else
  {
    shot4.GetComponent<image> ().enabled = false;
  }

  if (remainingShots > 4)
  {
    shot5.GetComponent<image> ().enabled = true;
  }
  else
  {
    shot5.GetComponent<image> ().enabled = false;
  }

  if (remainingShots > 5)
  {
    shot6.GetComponent<image> ().enabled = true;
  }
  else
  {
    shot6.GetComponent<image> ().enabled = false;
  }


  if(Input.GetButtonDown("Fire1"))
  {
  remainingShots -= 1;
  }
}
}

Solution

  • "Assets \ Scripts \ GameFlow.cs (72,28): error CS0246: The type or namespace name 'image' could not be found (are you missing a directive or an assembly reference?)"

    Change all your 'image' types to 'Image'.