void Update() { if (PhotonNetwork.IsConnectedAndReady == false) { RandomButton.GetComponent <Button>().interactable = false; RandomButton.GetComponentInChildren <TextMeshProUGUI>().color = Color.black; CustomButton.GetComponent <Button>().interactable = false; CustomButton.GetComponentInChildren <TextMeshProUGUI>().color = Color.black; } if (PhotonNetwork.IsConnected == false) { PhotonNetwork.ConnectUsingSettings(); } if (PhotonNetwork.PlayerList.Length == 2) { SceneManager.LoadScene("Game"); } if (roomid_input.GetComponent <TextMeshProUGUI>().text.Length > 3) { letsgo_btn.GetComponent <Button>().interactable = true; letsgo_btn.GetComponentInChildren <TextMeshProUGUI>().color = Color.white; } else { letsgo_btn.GetComponent <Button>().interactable = false; letsgo_btn.GetComponentInChildren <TextMeshProUGUI>().color = Color.black; } }
void activate() { RandomButton.GetComponent <Button>().interactable = true; RandomButton.GetComponentInChildren <TextMeshProUGUI>().color = Color.white; CustomButton.GetComponent <Button>().interactable = true; CustomButton.GetComponentInChildren <TextMeshProUGUI>().color = Color.white; }
void AddChipButton(Chip chip) { if (hideList.Contains(chip.chipName)) { //Debug.Log("Hiding") return; } CustomButton button = Instantiate(buttonPrefab); button.gameObject.name = "Create (" + chip.chipName + ")"; // Set button text var buttonTextUI = button.GetComponentInChildren <TMP_Text> (); buttonTextUI.text = chip.chipName; // Set button size var buttonRect = button.GetComponent <RectTransform> (); buttonRect.sizeDelta = new Vector2(buttonTextUI.preferredWidth + buttonWidthPadding, buttonRect.sizeDelta.y); // Set button position buttonRect.SetParent(buttonHolder, false); //buttonRect.localPosition = new Vector3 (rightmostButtonEdgeX + buttonSpacing + buttonRect.sizeDelta.x / 2f, 0, 0); rightmostButtonEdgeX = buttonRect.localPosition.x + buttonRect.sizeDelta.x / 2f; // Set button event //button.onClick.AddListener (() => manager.SpawnChip (chip)); button.AddListener(() => manager.SpawnChip(chip)); customButton.Add(button); }
public void InitializeMagicList(MagicId[] _availableMagic) { m_ListContainer.SetActive(true); m_SelectedMagic.gameObject.SetActive(false); m_SelectedMagic.onCancel.RemoveAllListeners(); m_SelectedMagic.onCancel.AddListener(() => { ShowMagicList(); }); int btnId = 0; foreach (MagicId id in _availableMagic) { if (btnId == m_BtnMagic.Length) { break; } MagicDescription desc = MagicManager.GetInstance().GetDescription(id); if (desc == null) { Debug.LogError(string.Format("Can't find magic description with id {0}", id)); continue; } CustomButton btn = m_BtnMagic[btnId]; btn.GetComponentInChildren <Text>().text = desc.m_DisplayName; btn.onCancel.RemoveAllListeners(); btn.onCancel.AddListener(() => { Close(); }); MagicId capturedId = id; //necessary for the lambda to work btn.onClick.RemoveAllListeners(); btn.onClick.AddListener(() => { Clicked(capturedId); }); btn.gameObject.SetActive(true); PawnStatistics stats = GameTurnManager.GetInstance().GetCurrentPawnStatistics(); if (desc.m_Power.CanBeUsed(stats)) { btn.IsUnselectable = false; } else { btn.IsUnselectable = true; } btn.Send(WidgetEvent.Unselect); ++btnId; } for (int i = btnId; i < m_BtnMagic.Length; ++i) { m_BtnMagic[i].gameObject.SetActive(false); } m_BtnMagic[0].Send(WidgetEvent.Select); }
void Start() { details.GetComponent <TextMeshProUGUI>().text = "Please wait or try again"; if (PhotonNetwork.IsConnectedAndReady) { RandomButton.GetComponent <Button>().interactable = true; RandomButton.GetComponentInChildren <TextMeshProUGUI>().color = Color.white; CustomButton.GetComponent <Button>().interactable = true; CustomButton.GetComponentInChildren <TextMeshProUGUI>().color = Color.white; } }
private IEnumerator RevealAnswerPercentage(CustomButton answer, float percentage, float endY) { answer.GetComponent <Collider2D>().enabled = false; SpriteRenderer percentageBar = answer.GetComponentInChildren <SpriteRenderer>(); Text percentageText = answer.GetComponentInChildren <Text>(); percentageText.text = percentage + "%"; float elapsedTime = 0; Color tempColor; Vector3 startPosition = answer.transform.localPosition; Vector3 endPosition = new Vector3(startPosition.x, endY, startPosition.z); Vector3 startScale = percentageBar.transform.localScale; Vector3 endScale = new Vector3(startScale.x * percentage / 100, startScale.y, startScale.z); while (elapsedTime < revealTime) { percentageBar.transform.localScale = Vector3.Lerp(startScale, endScale, elapsedTime / revealTime); answer.transform.localPosition = Vector3.Lerp(startPosition, endPosition, elapsedTime / revealTime); tempColor = percentageText.color; tempColor.a = Mathf.Lerp(0, 1, elapsedTime / revealTime); percentageText.color = tempColor; elapsedTime += Time.deltaTime; yield return(new WaitForEndOfFrame()); } answer.transform.localPosition = endPosition; percentageBar.transform.localScale = endScale; tempColor = percentageText.color; tempColor.a = 1; percentageText.color = tempColor; yield break; }