public NotesMovingGrid GenerateNotes(List <uint> _grid, bool autolaunch = true) { // load prefab "Note" GameObject prefabNote = Resources.Load("prefabs/Note") as GameObject; GameObject prefabBonus = Resources.Load("prefabs/BonusNote") as GameObject; // NotesMovingGrid grid = GetFreeGrid(); for (int index = 0; index < _grid.Count; index++) { uint type = _grid [index]; //nothing to place if (type == 0) { continue; } int i = index / NB_COLUMNS; int j = index % NB_COLUMNS; float x = (j * CELL_WIDTH + CELL_WIDTH * 0.5f) * 0.01f; float y = (i * CELL_HEIGHT + CELL_HEIGHT * 0.5f) * 0.01f; Note note = null; if (type == 1) { note = grid.GetUnactiveNote(); if (note == null) { note = Instantiate(prefabNote).GetComponent <Note> (); grid.AddNote(note); } } else { note = grid.GetUnactiveBonus(); if (note == null) { note = Instantiate(prefabBonus).GetComponent <BonusNote> (); grid.AddNote(note); } } Utils.SetLocalPositionXY(note.transform, x, y); note.SetActive(true); } if (autolaunch) { LaunchGrid(grid); } return(grid); }