SetActive works so why isn't there a SetInteractable?

This works

stockGridGreen[3].SetActive(false);

(stockGridGreen is a public GameObject stockGridGreen; array. So [3] is getting a specific one from that array.)

But it makes the object disappear. I just want to make it change color (go brighter) if a variable matches the requirements. So something like:

if (greenStockValue == 3)
{
stockGridGreen[3].SetInteractable(true);
}

I actually don’t need it to be interactable but I have found this to be an easy way to change game object colors because you just need to adjust the disabled and normal colors of the button in the inspector.

SetInteractable gets this error: …‘GameObject’ does not contain a definition for ‘SetInteractable’ and no accessible extension method ‘SetInteractable’ accepting a first argument of type ‘GameObject’ could be found (are you missing a using directive or an assembly reference?).

So SetActive is somehow built in to Unity and/or C# but SetInteractable isn’t?

How would I make “set interactable” work? Or make the game object change color depending on a condition being met.

Hi mate =) As I see you wants to change material color in array game object by conditions .Actually I heard SetInteractable function first time =/ .I think you should try get component function .

 public GameObject[] test;
    void Update()
    {
        if (condition) 
        {
            test[0].gameObject.GetComponent<Renderer>().material.SetColor("_Color", Color.cyan);
        }
    }

Material.SetColor

I hope it will help you on your problem .Have a good day =)

How do I make the game object change
color depending on a condition being
met?”

void Start ()
{
 
rR = GetComponent<Renderer>();

}
void Update ()
{
       If (conditionIsMet)
        {   
          rR.material.SetColor("_Color", Color.red);               
         }
}

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

public class StockValue : MonoBehaviour
{
    public GameObject[] stockGridGreen;
    /* public int greenStockPrice;
     public int redStockPrice;
     public int blueStockPrice;
     public int yellowStockPrice;*/

    public int greenStockValue;
   /* public Grid grid;*/
    void Start()
    {
        /*stockGridGreen[1].SetInteractable(false);*/
        /*stockGridGreen[3].SetActive(false);
        stockGridGreen[8].SetActive(false);
        stockGridGreen[11].SetActive(false);
*/
       /* rR = GetComponent<Renderer>();*/

        /*Debug.Log("I'm start in StockValue");*/
    }


    
    void Update()
    {
        if (greenStockValue== 3)
        {
            stockGridGreen[2].gameObject.GetComponent<Renderer>().material.SetColor("_Color", Color.cyan);
        }

        Debug.Log("green stock value is " + greenStockValue);
    }
    /*void Update()
      {
          If(greenStockValue == 3);
              {
              rR.material.SetColor("_Color", Color.red);
          }
      }*/

    public void SetStockGrid()
    {

       /* stockGridGreen[1].SetActive(true);

        Debug.Log("I'm setstockgrid in StockValue");*/

        /*stockGridGreen.interactable = false;*/
        /*stockGridGreen[].GetComponentInParent<Button>().interactable = true;*/

    }

   /* public void SetStockValue()
    {
       
        Debug.Log("green stock value is " + greenStockValue);

            if (greenStockValue == 3)
        {
            for (int i = 0; i < stockGridGreen.Length; i++)
            {
                stockGridGreen*.GetComponentInParent<Button>().interactable = true;*

}
}
}*/
}
[154051-stockchart.jpg|154051]*
There’s the code for what I’m trying to do. Left the commented-out code in there to show what I’ve been trying to get to work.
*
The numbers in the stock price need to change color to reflect what the value of the stock currently is. In code each color is in an array. GameObject[] stockGridGreen
The current code does not work and I get a “There is no ‘Renderer’ attached to the object…” message when I enter a 3 into the greenStockValue. I’ve looked up that issue but haven’t been able to figure out my specific issue yet.