Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
EthicalCell's avatar
EthicalCell
Honored Guest
4 years ago

Unity 2021.2.5 Arrays Uneditable in Inspector [Mac]

I'm following along with the "Build Your First VR App" Tutorial, and I'm running into an issue where an array that I created called "WallMaterial" in a Script is blank uneditable. The code for the script and an image of the inspector are below. Does anyone have a solution? Is it a bug in the Unity version? I am using Unity 2021.2.5 for Mac.

 

 

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

public class ColorController : MonoBehaviour
{

    public Material[] wallMaterial;
    Renderer rend;

    //Appears in the Inspector view from where you can assign the textbox
    public Text displayText;
    // Start is called before the first frame update
    void Start()
    {
        //Assigns the component's renderer instance
        rend = GetComponent<Renderer>();
        rend.enabled = true;
        displayText.text = "";
    }

    //Called when the ball collides with the wall
    private void OnCollisionEnter(Collision collision)
    {
        //Checks if the player ball has collided with the wall.
        if(collision.gameObject.name == "player-ball")
        {
            displayText.text = "Ouch!";
            rend.sharedMaterial = wallMaterial[0];
        }
    }

    private void OnCollisionExit(Collision collision)
    {
        if(collision.gameObject.name == "player-ball")
        {
            rend.sharedMaterial = wallMaterial[1];
            displayText.text = "Keep Rolling...";
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

 

 

Replies have been turned off for this discussion