Exemplo n.º 1
0
    private void Start()
    {
        soundHandler = GetComponentInParent <UIButtonsSoundHandler>();

        foreach (ItemType type in filters)
        {
            GameObject buttonGao = Instantiate <GameObject>(buttonPrefab);
            Text       text      = buttonGao.GetComponentInChildren <Text>();

            text.text      = type.ToString().ToUpper();
            text.alignment = TextAnchor.MiddleCenter;
            text.fontStyle = FontStyle.Bold;

            buttonGao.transform.SetParent(content.transform, false);

            UIMouseEvents events = buttonGao.GetComponent <UIMouseEvents>();
            events.onMouseLeftUp.AddListener(Button_onClick);

            buttons.Add(buttonGao);
        }
    }
Exemplo n.º 2
0
    private void Start()
    {
        soundHandler = GetComponentInParent <UIButtonsSoundHandler>();

        if (buttonTemplatePrefab == null)
        {
            Debug.LogError("No button template defined on " + this.name);
            enabled = false;
        }

        if (content == null)
        {
            Debug.LogError("No content defined on " + this.name);
            enabled = false;
        }

        manager = GetComponentInParent <UIInventoryMenu>();
        if (manager != null)
        {
            manager.OnInventoryMenuStateChange += OnInventoryMenuStateChangeCallback;
        }
    }