How to disable and enable selected object using button.


hello.

I have these 3d objects on my screen. I want to select any of this object and disable it with button. I am stuck. Please help me. This is the script so far i write. Thank you

using UnityEngine;
using System.Collections;

public class disableEnable : MonoBehaviour {

    public GameObject Enable_Disable;

    public void Enable()
    {
        Enable_Disable.SetActive(true);
    }
    public void Disable()

    {
        Enable_Disable.SetActive(false);
    }
}

Look at the error in your console. You didn’t see Enable_Disable to anything.

The code is right. You just have to connect the buttons with the script. You can do that when you click on the button object and there is an “OnClick” Event or something like that. there you have to select the object the “disableEnable” script is on and then you can access it’s public methods

Issue is solved thank you