cancel
Showing results for 
Search instead for 
Did you mean: 

Unity 2021.2.5 Arrays Uneditable in Inspector [Mac]

EthicalCell
Honored Guest

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.

 

Screen Shot 2021-12-10 at 9.14.32 AM.png

 

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()
    {
        
    }
}

0 REPLIES 0