Exemplo n.º 1
0
    protected override void AwakeImpl()
    {
        base.AwakeImpl();

        Transform tr = null;

        if (buttonCaption == null)
        {
            tr = transform.FindChild("Caption");
            if (tr != null)
            {
                buttonCaption = tr.GetComponent <NvUILabel>();
            }
        }

        if (buttonCaption != null)
        {
            buttonCaption.text = m_caption;
        }

        if (buttonBackground == null)
        {
            tr = transform.FindChild("Background");
            if (tr != null)
            {
                buttonBackground = tr.GetComponent <NvUIImagelist>();
            }
        }

        if (buttonBackground != null)
        {
            foreach (ButtonStyle style in m_skin.normalStyle)
            {
                NvUIImage image = buttonBackground.addImage(style.atlas, style.spriteName);
                image.transform.localPosition = style.Offset;

                if (image != null)
                {
                    image.spriteColor = m_skin.normalColor;
                }
            }
        }

        if (buttonCollider != null && buttonBackground != null)
        {
            NvUIImage image = buttonBackground.getImage(0);
            if (image == null)
            {
                Debug.LogWarning("NvUIButton (" + name + "): the button has no properly configured skin, check it!");
            }
            else
            {
                buttonCollider.transform.localScale = image.transform.localScale;
            }
        }
    }
Exemplo n.º 2
0
    protected override void AwakeImpl()
    {
        base.AwakeImpl();

        Transform tr = null;
        if ( buttonCaption == null )
        {
            tr = transform.FindChild("Caption");
            if ( tr != null )
            {
                buttonCaption = tr.GetComponent<NvUILabel>();
            }
        }

        if ( buttonCaption != null )
        {
            buttonCaption.text = m_caption;
        }

        if ( buttonBackground == null )
        {
            tr = transform.FindChild("Background");
            if ( tr != null )
            {
                buttonBackground = tr.GetComponent<NvUIImagelist>();
            }
        }

        if ( buttonBackground != null )
        {
            foreach ( ButtonStyle style in m_skin.normalStyle )
            {
                NvUIImage image = buttonBackground.addImage( style.atlas, style.spriteName );
                image.transform.localPosition = style.Offset;

                if ( image != null )
                {
                    image.spriteColor = m_skin.normalColor;
                }
            }
        }

        if ( buttonCollider != null && buttonBackground != null )
        {
            NvUIImage image = buttonBackground.getImage(0);
            if ( image == null )
            {
                Debug.LogWarning("NvUIButton (" + name + "): the button has no properly configured skin, check it!");
            }
            else
            {
                buttonCollider.transform.localScale = image.transform.localScale;
            }
        }
    }