Error CS0118

Assets\Infima Games\Low Poly Shooter Pack\Code\Demo\DisplayMaterialName.cs(43,13): error CS0118: ‘TextMeshProUGUI’ is a type but is used like a variable
This is my code :

// Copyright 2021, Infima Games. All Rights Reserved.

using TMPro;
using UnityEngine;

namespace InfimaGames.LowPolyShooterPack
{
///


/// Displays a material’s name in the world.
///

public class DisplayMaterialName : MonoBehaviour
{
#region FIELDS SERIALIZED

[Header(“Settings”)]

[Tooltip(“Mesh.”)]
[SerializeField]
private Renderer mesh;

[Tooltip(“Text.”)]
[SerializeField]
private TextMeshProUGUI materialText;

#endregion

#region FIELDS

///


/// Material.
///

private Material meshMaterial;

#endregion

#region UNITY

private void Start()
{
//Get current material name from the mesh.
string sharedMaterialName = mesh.sharedMaterial.name;
//Output current material name to the UI text.
TextMeshProUGUI = sharedMaterialName;
}

#endregion
}
}

help me please

When posting code on the Scripting forum, make sure to use Code Tags so people can read your code easily. You can edit your post and add it.

The error tells you what’s wrong, you used a type like a variable. I don’t even know what you’re trying to do, so I can’t help you unless you explain it.

On another note, I’d suggest following some basic coding tutorials instead, C# has strict rules on how the syntax works, and if you don’t know those you’re not going to get anywhere.

2 Likes

I pasted the OP into chatGPT verbatim, here’s the generated reply:

3 Likes

(Man, ChatGPT didn’t even give OP a hard time about memorizing error codes. What is the world coming to?)

8 Likes

Well played, well played. :slight_smile: