![]() When I create a list it is empty, then I levels.Add(floor) this will add an object to the list. Sorry for so many questions, just trying to get my head around new concepts. How would you go about controlling all of this with UI sliders? Rotation starts from second cube (item 1).Ĥ. ![]() Also when rotating the objects last object doesn't move? I want an opposite behaviour, first one doesn't moves. Is there a way to declare gameObject from the list just one time? Currently I have to do it every time I want to associate gameObject with object in the list. Does list.Count keep track of changes outside of the function?Ģ. Something wrong with counting list items relative to objects. But I still have questions, and I assume the code could be optimised a bit better.ġ. In case you are unfamiliar (forgive me if i wrongly assume you are new to programming), that would look something like this: If you want to rotate all the plates, you need to iterate over the list using a for loop. Now, each time you add a new plate, it gets added to the list. Start by adding your "floor" object to the list, simply by calling floorPlates.Add(floor). Keep in mind tho, that we start counting at 0, so the first element you add to your list gets added to index 0. Since you'll add your elements in the right order, your tower basically represents the order of elements in the list. The same goes for removing an object, you can either call Remove(someGameObjectInTheList), or remove the object from some index in that list using RemoveAt(i), to remove the element at the i'th position in the list. You can add objects of the type you defined for the list ("List" is a list of GameObjects) by calling Add(someGameObject) on the list. Lists are basically just dynamically resized Arrays, which are part of the C# language (and most other programming languages as well). Click to expand.This has nothing to do with Unity or the API at all.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |