void ShowButton(BeatButton button) { button.GetComponent <RectTransform>().SetParent(grid); //button.transform.parent = grid.transform.parent; var beat = beats[button.beatIndex]; var trans = button.GetComponent <RectTransform>(); var pos = buttonPrefab.anchoredPosition3D; var size = buttonPrefab.sizeDelta; pos.x = beat.Time / tickToPixelRatio; trans.anchoredPosition3D = pos; trans.sizeDelta = size; trans.gameObject.SetActive(true); button.GetComponentInChildren <Text>().text = beat.beatName; if (button.beatIndex == selectedButton) { button.GetComponent <Image>().color = Color.white; } else if (beat.beatType == 0) { button.GetComponent <Image>().color = defaultColor; } else { button.GetComponent <Image>().color = beatColor; } button.gameObject.SetActive(trackEnabled[beats[button.beatIndex].trackIndex]); }
void ProcessBeatInput(int beatType, string beatName) { if (shownButtons.ContainsKey(selectedButton)) { BeatButton beatButton = shownButtons[selectedButton]; Beat beat = beats[beatButton.beatIndex]; beat.beatType = beatType; beat.beatName = beatName; } }
public void OnClickButton(BeatButton button) { //if (selectedButton != -1 && shownButtons.ContainsKey(selectedButton)) //{ // shownButtons[selectedButton].GetComponent<Image>().color = defaultColor; //} selectedButton = button.beatIndex; button.GetComponent <Image>().color = Color.white; var beat = beats[button.beatIndex]; Debug.Log(string.Format("ticks = {0}, time = {1}", beat.Time, beat.Time / ticksPerSecond)); }
BeatButton AddButtons(int count) { if (buttons.Count + count > MAX_BUTTONS) { Debug.LogError("MAX BUTTONS REACHED"); return(null); } BeatButton firstOne = null; int startID = buttons.Count; for (int i = startID; i < startID + count; i++) { var newButton = NewButton(); buttons.Add(newButton); if (firstOne == null) { firstOne = newButton; } } return(firstOne); }
public void ReturnButton(BeatButton button) { button.beatIndex = -1; button.gameObject.SetActive(false); //Debug.Log(string.Format("free buttons = {0}, buttons = {1}", FreeButtons(), buttons.Count)); }