private static GameObject CreateButton(GameObject buttonPrefab, string label, System.Action onHit, Vector3 position, Vector3 scale) { GameObject buttonObject = Object.Instantiate(buttonPrefab, buttonPrefab.transform.parent); buttonObject.transform.localPosition = position; buttonObject.transform.localScale = scale; buttonObject.transform.localEulerAngles = new Vector3(0.0f, 0.0f, 0.0f); Object.Destroy(buttonObject.GetComponentInChildren <Localizer>()); TextMeshPro buttonText = buttonObject.GetComponentInChildren <TextMeshPro>(); buttonText.text = label; GunButton button = buttonObject.GetComponentInChildren <GunButton>(); button.destroyOnShot = false; button.disableOnShot = false; button.SetSelected(false); button.onHitEvent = new UnityEvent(); button.onHitEvent.AddListener(onHit); return(buttonObject.gameObject); }
private static GameObject CreateButton(GameObject buttonPrefab, string label, Action onHit, Vector3 position, Vector3 eulerRotation, Vector3 scale) { GameObject buttonObject = UnityEngine.Object.Instantiate(buttonPrefab); buttonObject.transform.rotation = Quaternion.Euler(eulerRotation); buttonObject.transform.position = position; buttonObject.transform.localScale = scale; UnityEngine.Object.Destroy(buttonObject.GetComponentInChildren <Localizer>()); TextMeshPro buttonText = buttonObject.GetComponentInChildren <TextMeshPro>(); buttonText.text = label; GunButton button = buttonObject.GetComponentInChildren <GunButton>(); button.destroyOnShot = false; button.disableOnShot = false; button.SetSelected(false); button.onHitEvent = new UnityEvent(); button.onHitEvent.AddListener(onHit); return(buttonObject.gameObject); }
public static void GoToMissingSongsPage() { needsSongListRefresh = false; songItemMenu.ShowPage(OptionsMenu.Page.Customization); if (backButton == null) { var button = GameObject.Find("menu/ShellPage_Settings/page/backParent/back"); backButton = button.GetComponentInChildren <GunButton>(); // set up "download all" button downloadAllButton = UnityEngine.Object.Instantiate(button, button.transform.parent); downloadAllButton.transform.localPosition = new Vector3(-0.8f, 2.0f, 0.0f); downloadAllButton.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); downloadAllButton.transform.localEulerAngles = new Vector3(0.0f, 0.0f, 0.0f); UnityEngine.Object.Destroy(downloadAllButton.GetComponentInChildren <Localizer>()); TextMeshPro buttonText = downloadAllButton.GetComponentInChildren <TextMeshPro>(); buttonText.text = "Download all"; Action onHit = new Action(() => { OnDownloadAll(); }); GunButton btn = downloadAllButton.GetComponentInChildren <GunButton>(); btn.destroyOnShot = false; btn.disableOnShot = false; btn.SetSelected(false); btn.onHitEvent = new UnityEvent(); btn.onHitEvent.AddListener(onHit); } else { downloadAllButton.SetActive(true); } missingSongsIDs = new List <string>(SongRequests.missingSongs.Keys); SetupList(); AddSongItems(songItemMenu); }