I have a struct I made called arrayTesting
[System.Serializable]
public struct arrayTesting
{
public int[] testt;
public int ah;
}
`
I made a variable with this struct as its type.
``
[HideInInspector] public arrayTesting tester;
```
I used [HideInInspector]
because I don’t want it to automatically show, I want it to only show up/serialize if a certain condition is true.
However when I try to serialize it with the custom inspector none of the values show up. It just shows the name of it “tester” in the inspector with no actual values next to it.
However if I remove the [HideInInspector] from it and it’s serialized by default, there are two of this same variable showing up and both of them work perfectly. The custom inspector one and the normal one, but I only want it to serialize under a specific condition and only once.
Also I tried this with different classes with arrays and it showed the number of elements not the actual value.
It was like
“element 0”
“element 1”
and just blank space next to it.
If it’s helpful here are the relevant parts of my custom inspector code
#region Custom Editor
#if UNITY_EDITOR
[CustomEditor(typeof(PlatformsManager))]
public class customEdit : Editor
{
public override void OnInspectorGUI()
{
PlatformsManager platformsManager = (PlatformsManager)target;
base.OnInspectorGUI();
Show("tester");
#endregion
serializedObject.ApplyModifiedProperties();
}
#region Shortcuts
void Header(string Message)
{
EditorGUILayout.Space(10);
EditorGUILayout.LabelField(Message, EditorStyles.boldLabel);
}
void Show(string variableName)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty(variableName));
}
#endregion
}
#endif
#endregion