Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Array of class with arrays in it, bug in inspector

Discussion in 'Editor & General Support' started by RickG00, Apr 5, 2021.

  1. RickG00

    RickG00

    Joined:
    Apr 1, 2021
    Posts:
    1
    Hi, I'm using Unity 2021.1.0f1 Personal.
    I was trying to create a script to randomize meshes:
    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class MeshRandomizer : MonoBehaviour
    7. {
    8.     [SerializeField]
    9.     private Transform Head;
    10.     [SerializeField]
    11.     private Transform Body;
    12.     [SerializeField]
    13.     private Transform Weapon;
    14.     [SerializeField]
    15.     private Transform Shield;
    16.  
    17.     [Serializable]
    18.     private class Tier
    19.     {
    20.         public bool Enabled;
    21.         public Mesh[] Heads;
    22.         public Mesh[] Bodies;
    23.         public Mesh[] Weapons;
    24.         public Mesh[] Shields;
    25.     }
    26.    
    27.     [SerializeField]
    28.     private Tier[] Tiers;
    29.     [SerializeField]
    30.     private Material Color;
    31.    
    32.     void Awake()
    33.     {
    34.         Head.GetComponent<Renderer>().material = Color;
    35.         Body.GetComponent<Renderer>().material = Color;
    36.         Weapon.GetComponent<Renderer>().material = Color;
    37.         Shield.GetComponent<Renderer>().material = Color;
    38.  
    39. //        Head.GetComponent<MeshFilter>().sharedMesh = Heads[Random.Range(0, Heads.Length)];
    40. //        Body.GetComponent<SkinnedMeshRenderer>().sharedMesh = Bodies[Random.Range(0, Bodies.Length)];
    41. //        Weapon.GetComponent<MeshFilter>().sharedMesh = Weapons[Random.Range(0, Weapons.Length)];
    42. //        Shield.GetComponent<MeshFilter>().sharedMesh = Shields[Random.Range(0, Shields.Length)];
    43.     }
    44.  
    45. }
    46.  
    Though, the problem is that the inspector doesn't push the other arrays down, so when I try to see the arrays in the inspector, they are behind the others
    Screenshot1.png
    Screenshot2.png
    Screenshot3.png
     
    Vryken likes this.
  2. Transarc

    Transarc

    Joined:
    Sep 19, 2020
    Posts:
    6
    I have the same bug