D
D
Dmitry Korolev2016-04-16 04:37:03
C++ / C#
Dmitry Korolev, 2016-04-16 04:37:03

How to include the next array element in an array?

I'm making a player, how can I turn on the next and previous track?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MrDywar Pichugin, 2016-04-17
@adressmoeistranici

0) Read the entire manual.
docs.unity3d.com/ru/current/Manual
1) Do not write like this

if (myBoolean == true) { ... }
достаточно будет
if (myBoolean) { ... }

2) Do not use a lot of if, it will be easier to work with switch.
3) Wrap the work with the array in methods, inside which there will be checks and organization of transitions between tracks.
private void PlayNext() { /* играть следующую песню */ }
private void PlayPrevious() { /* играть предыдущую песню */ }
private void PlayRandom() { /* играть случайную песню */ }
private void Play(int songNumber) { /* играть песню по ее номеру*/ }

4) Store links to songs in an array (already done in AudioClip[] clips).
And pass them as an argument to AudioSource .PlayOneShot( XXX ).
5) Create fields for autoPlayNext, etc.
6) Study free video tutorials on the development of standard solutions, many issues have already been resolved. And help will help you keep in mind the available APIs with which you can solve your problems.

H
HiIamRobot, 2016-04-16
@HiIamRobot

Mass[i] - current song. Change i +/-1 value on button click? Or I misunderstood something..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question