// --------------------------- // all routines play button sound and wait some time // then they do an action depending on the calling method IEnumerator SceneLoadRoutine(buttonAction action) { // play button sound AudioSource.PlayClipAtPoint(buttonSound, Camera.main.transform.position, buttonSoundVolume); yield return(new WaitForSeconds(buttonWaitTime)); switch (action) { case buttonAction.LoadMainMenu: { SceneManager.LoadScene(0); break; } case buttonAction.LoadGame: { SceneManager.LoadScene(1); break; } case buttonAction.Exit: { Application.Quit(); break; } } }
/// <summary> /// Position is the CENTER of the button /// </summary> public Button(Texture2D tex, Vector2 pos, buttonAction action, Screen screen) { this.tex = tex; this.pos = pos; this.action = action; screen.buttons.Add(this); Vector2 p = this.pos - new Vector2(this.tex.Width, this.tex.Height) * .5f; // translate up and left my 1/2 the size for hitbox this.rect = new Rectangle((int)p.X, (int)p.Y, this.tex.Width, this.tex.Height); }
//switchで関数の中身を変更する public void buttonSettings() { switch (type) { case buttonType.loadScene: newAction = loadScene; break; case buttonType.applicationQuit: newAction = quit; break; case buttonType.Pause: newAction = pause; break; } }
public void SetUpLevelButtons(buttonAction action) { levelButtons = new ButtonScript[COLUMNS * ROWS]; float offsetX = levelBox.GetComponent <RectTransform>().sizeDelta.x / COLUMNS; float offsetY = levelBox.GetComponent <RectTransform>().sizeDelta.y / ROWS; for (int y = 0; y < ROWS; y++) { for (int x = 0; x < COLUMNS; x++) { int index = y * COLUMNS + x; GameObject g = Instantiate(levelButtonPrefab); g.transform.SetParent(levelBox.transform); g.GetComponent <RectTransform>().anchoredPosition = new Vector2(x * offsetX, -y * offsetY); g.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1); levelButtons[index] = g.GetComponent <ButtonScript>(); levelButtons[index].SetText((index + 1).ToString()); levelButtons[index].SetAction(action, index); } } }
// Use this for initialization void Start() { keyScript = gameObject.AddComponent <KeyScript>(); tileManagerScript = gameObject.AddComponent <TileManagerScript>(); mapManagerScript = gameObject.AddComponent <MapManagerScript>(); controllScript = gameObject.AddComponent <ControllScript>(); controllScript.enabled = false; keyScript.LoadKey(); if (!mapManagerScript.IsDataFile("/mapki.dat")) { SaveMapsScript s = gameObject.AddComponent <SaveMapsScript>(); mapManagerScript.LoadMaps(s.PrepareData()); } else { mapManagerScript.LoadMaps("/mapki.dat"); } buttonAction action = SetUpGame; gameMenuScript.SetUpLevelButtons(action); gameMenuScript.UpdateLevelButtons(keyScript.GetKeyValue()); }
private void butVagon_Click(object sender, EventArgs e) { currentAction = buttonAction.vagon; move = false; }
private void CirclBut_Click(object sender, EventArgs e) { currentAction = buttonAction.circle; move = false; }
private void RectBut_Click(object sender, EventArgs e) { currentAction = buttonAction.rectangle; move = false; }
private void butTrain_Click(object sender, EventArgs e) { currentAction = buttonAction.train; count = Convert.ToInt32(countVag.Text); }
private void butMoving_Click(object sender, EventArgs e) { currentAction = buttonAction.move; }
public void SetAction(buttonAction action, int value) { button.onClick.AddListener(delegate { action.Invoke(value); }); }
private void ResetViewToDefaults(ViewController destinationView) { if(destinationView.NavigationBarExists) { SetLeftButtonText(defaultLeftButtonText); SetRightButtonText(defaultRightButtonText); SetTitle(""); leftButtonAction = null; rightButtonAction = null; } }
public void SetRightButtonAction(buttonAction action) { this.rightButtonAction = action; }
public void SetLeftButtonAction(buttonAction action) { this.leftButtonAction = action; }