error CS0246: The type or namespace name `components' could

I am not sure I can understand anything from that error?

  1. You didn’t even give us the full error.
  2. If you give some sample code I bet the very next comment will fix what it is your trying to do. It is very likely incorrect naming of an Instance when it’s expecting a Class name (but I can’t be sure).

This is the button menu script
In that script I create buttons in column and from 4 of them I need to enable or disable a mesh.
I just don’t get it how to locate the mesh and hide / unhide it?
I am aware of a boolean that I can use to switch the state of the mesh, but the syntax to the mesh object is something I don’t get.

384304–13253–$mainmenuformbague_167.cs (4.29 KB)

Easiest way to toggle the rendering of a mesh is this:

renderer.enabled = x;

Where x is a boolean.

Your error comes from:

public components gameObject;

I don’t quite know what this is trying to do.

if it’s trying to create an array of Gameobjects the proper syntax would be:

public GameObject[ ] components;

gameObject is a reference in MonoBehaviour to a GameObject class. Note that all classes(and functions) start with upper case. The [ ] represents that you want to have an array of that object. components is the name of your GameObject array (which is confusing because Components and GameObjects are different things).

A few lines down is:

//.FindGameObjectsWithTag(“perle_bagu”)

This should be:

components = GameObject.FindObjectsWithTag(“perle_bagu”);

You use GameObject because that function is static and owned by the class as a whole and not a specific instance of the class. Then you have to say where you want the list of GameObjects to go. In this case, you want them to go into the GameObject array called components that you just made.

Next is:

//print(“This is component component[2]” ); // does not work too much red in the debugger

should be:

Debug.Log("This is Component " + components[2]);

Debug.Log is Unities specific version of print. It allows extra functionlity and requires no includes.

Second using “” means that it prints out that exact string and so it would have printed “component[2]” instead of what component[2] contained. You need to separate them by adding the “” part with the data part and it puts one after the other.

Also the GameObject array was called components. accessing a single one you still need to keep the identical name and pluralize it. components is what you want, you’ve not created anything called component.

There are a number of missing brackets here, and other unclear intentions. I suggest you get either a C# book, or follow some tutorials on the web before continuing. Nothing too extensive, but there seems to be a couple missing basic concepts that should be covered pretty quickly in a tutorial.

The error you listed meant that there is no such class called components. If you get it again it means you need to double check the object type that you are creating, because it’s either a typo or incorrect syntax as that class name doesn’t exist.

unity3d use .dll?
can you do with this?