I trust that there are amazing people here that can solve this problem
I have a List of GameObjects that have been made in my first script;
public List<GameObject> _recordinglist = new List<GameObject>();
Then a button creates a clone and adds to the _recordinglist
recordedObject = Instantiate(mynewPrefab, new Vector3(0, 0, 0), Quaternion.identity);
// adding to created list
_recordinglist.Add(recordedObject);
Now in the second Script
I have a working script that
changes the GameObject into other GameObjects. Eg Turning a Kick into a Clap with the click of different buttons where I would change the Game Object in the Inspector
However
Trying to do
GameObject = List[0];
Gives Errors even though it is initialised
Also I'm not sure how to click/cylce through the list with a button?
Some clear guidance for a relatively beginner coder would be greatly appreciated.
I have already asked in the Unity Forum, but it lead to confusion. I have also emailed directly and the answers aren't detailed enough. I have also checked around and haven't seen exactly what I need.
In other words,
I'm Trying to make
Recording1 = Recording2 or 3, 4, 5, 6, then start at 1 as I select through.
Instead of just Recording = Recording 2
Not sure I understood, but I think this is what you want:
GameObject r = _recordings[0]
(In the question you forgot to give the variable a name)
to iterate through the list:
int i = 0;
GameObject go = _recordings[i];
i = (i + 1) % _recordings.Length;
The modulus (%) symbol returns the division remainder, so it makes sure i
would just be set back to 0 when it gets to _recordings.Length
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.