Beispiel #1
0
    //Relaese Handling
    private void ScreenClickEndedHandle()
    {
        if (lastClickedBtn == null)
        {
            return;
        }

        Button_Al btnComp = lastClickedBtn.GetComponent <Button_Al> ();

        if (btnComp == null)
        {
            return;
        }

        btnComp.isBegan = false;

        if (btnComp.resetIconOnRelease)
        {
            if (btnComp.normalIcon != null)
            {
                btnComp.spriteRendererComp.sprite = btnComp.normalIcon;
            }
        }

        if (!string.IsNullOrEmpty(btnComp.message))
        {
            eventOb.SendMessage(btnComp.message, btnComp.messageObject);                                     //call the given method which is inside Events.Cs
        }
        else
        {
            Debug.LogWarning("empty message on <i>" + lastClickedBtn.name + "</i>click");                                     //you missed to add event name
        }

        lastClickedBtn = null;
    }
Beispiel #2
0
    //General Handling
    private void ScreenClickHandle(GameObject ob, bool isTouchBegain)
    {
        string objname = "";                        // name of button that ray hit it

        if (ob != null)
        {
            objname = ob.name;
        }

        foreach (GameObject btn in buttons)
        {
            if (btn == null)
            {
                continue;
            }
            Button_Al btnComp = btn.GetComponent <Button_Al> ();
            if (btnComp == null)
            {
                continue;
            }

            if (objname == btn.name)
            {
                if (!btnComp.isBegan)
                {
                    btnComp.isBegan = true;
                    lastClickedBtn  = btn;
                    if (btnComp.hoverIcon != null)
                    {
                        btnComp.spriteRendererComp.sprite = btnComp.hoverIcon;
                    }

                    if (btnComp.clickReleaseSFx != null)
                    {
                        AudioSource.PlayClipAtPoint(btnComp.clickReleaseSFx, Vector3.zero);
                    }
                }
            }
            else
            {
                if (!isTouchBegain && btnComp.isBegan)
                {
                    lastClickedBtn  = null;
                    btnComp.isBegan = false;
                    if (btnComp.normalIcon != null)
                    {
                        btnComp.spriteRendererComp.sprite = btnComp.normalIcon;
                    }
                }
            }
        }
    }