public void CreateButton(DulibaHUD.ButtonInfo newButton) { //DestroyButton(newButton.button); /* * SingleButton button = Instantiate(singleButtonPrefab, transform).GetComponent<SingleButton>(); * button.transform.localPosition = new Vector3(deathPoint.localPosition.x, 125f * buttons.Count - 187.5f); * button.SetTargetPosition(new Vector3(0f, 125f * buttons.Count - 187.5f)); * * button.SetText(newButton.name, newButton.quantity, newButton.button, newButton.image); * button.buttonInfo = newButton; * * if (!newButton.enabled) * { * button.transform.GetChild(0).GetComponent<Image>().color = new Color(.5f, .5f, .5f, .75f); * button.image.color = new Color(1f, 1f, 1f, .75f); * } * else * { * button.transform.GetChild(0).GetComponent<Image>().color = Color.white; * button.image.color = Color.white; * }*/ newButtons.Add(newButton); //buttons.Add(button); //count++; /* * Button uiButton = button.gameObject.AddComponent<Button>(); * uiButton.targetGraphic = button.transform.GetChild(0).GetComponent<Image>(); * * EventTrigger trigger = button.gameObject.AddComponent<EventTrigger>(); * var pointerDown = new EventTrigger.Entry(); * pointerDown.eventID = EventTriggerType.PointerDown; * pointerDown.callback.AddListener((e) => FindObjectOfType<DulibaInput>().ButtonPressedDown(letter == "L" ? "a1" : "n1")); * trigger.triggers.Add(pointerDown); * * trigger = button.gameObject.AddComponent<EventTrigger>(); * pointerDown = new EventTrigger.Entry(); * pointerDown.eventID = EventTriggerType.PointerUp; * pointerDown.callback.AddListener((e) => FindObjectOfType<DulibaInput>().ButtonPressedUp(letter == "L" ? "a1" : "n1")); * trigger.triggers.Add(pointerDown);*/ }
public void UpdateButton(DulibaHUD.ButtonInfo newButton) { foreach (var b in buttons) { if (b.buttonInfo.button == newButton.button) { b.SetText(newButton.name, newButton.quantity, newButton.button, newButton.image); b.buttonInfo = newButton; if (!newButton.enabled) { b.transform.GetChild(0).GetComponent <Image>().color = new Color(.5f, .5f, .5f, .75f); b.image.color = new Color(1f, 1f, 1f, .75f); } else { b.transform.GetChild(0).GetComponent <Image>().color = Color.white; b.image.color = Color.white; } break; } } }