0

can we select multiple UI buttons? Something like this : https://ibb.co/gSgDvqh

2 Answers 2

1

Did you check ToggleGroup? If it is not what you needed, you can simply create your own control.

Sign up to request clarification or add additional context in comments.

1 Comment

Well thank you, using toggle is much more convenient! Thanks :)
0

if you want create button like image , you can get bool parameter for each button for manage is click or not like that :

bool btn1Selected=false;
bool btn2Selected=false;

than in UIManager script add button and when button clicked , change UI of the button to selected image button.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class test : MonoBehaviour
{

    public bool btn1Selected;
    public bool btn2Selected;

    public Sprite selectedSprite;
    public Sprite notSelectedSprite;

    Button btn1, btn2;


    public void BtnClicked(int btnIndex)
    {
        if (btnIndex == 1)
        {
            if (btn1Selected)
                btn1.GetComponent<Button>().image.sprite = notSelectedSprite;
            else
                btn1.GetComponent<Button>().image.sprite = selectedSprite;

            btn1Selected = !btn1Selected;
        }
        else
        {
            if (btn2Selected)
                btn2.GetComponent<Button>().image.sprite = notSelectedSprite;
            else
                btn2.GetComponent<Button>().image.sprite = selectedSprite;

            btn2Selected = !btn2Selected;
        }
    }


}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.