Class Constructor Types

Hi thar, I’m kinda new to Unity (meaning I’ve been playing around on it for a few days) and I’m working on a carousel style main menu using 3D gui components with custom shaders and raycasting yadda yadda. And I’m really happy how its turned out but I’ve run into a problem when creating class objects for the menu items to store and manage height and movement.

When I debug it there’s a problem with the constructor for the menu item not accepting the variable types or rather its not detecting any constructors that match the input types, which I am pretty sure do match. Here is my code for the constructor and the call to it:

Constructor:

public function MenuItem(Item : GameObject, List : Array) {
	this.Item = Item;
	this.SubItems = List;
	this.ItemStatus = false;
		
	this.Height = List.length * 1;
	this.Alpha = 0f;
}

Call to constructor:

Items[0] = new MenuItem(MenuObjects[0].Find("Play"), [MenuObjects[0].Find("Continue")]);

I am a bit new to coding in unity, so some of my code may seem sloppy (I would appreciate tips on fixing that too :)) but other than this damned constructor and data types I’m not having to much difficulty.
I would greatly appreciate any help in resolving this issue :smile:

[MenuObjects[0].Find(“Continue”)] isn’t type Array, it’s type Transform[ ]. You pretty much never want to use Array anyway, but should stick with built-in arrays or generic Lists. As far as tips, the only things I can see from the code you posted is 1) use lowercase for variables, and uppercase for classes and functions, and 2) List.length * 1 doesn’t do anything that List.length doesn’t do.

–Eric

Thank you very much, though I still don’t have a full grasp on all the types at least I will be able to research some more based off your response. Also thank you for the tips for the built in lists and stuff I should have probably looked at them a bit more too. The 1 * length is a place holder by the way, just the spacer between play and new game and load game and stuff, it’ll probably be changed later or removed if the space is fine. Thanks again, also if anyone has any good beginners tutorials or resources that would be great too.