Search Issue Tracker
By Design
Votes
3
Found in
2019.4
2019.4.8f1
2020.1
2020.2
Issue ID
1277326
Regression
No
Public Variables from Custom public class is not visible in the Inspector when it is declared in non-MonoBehaviour Class
Steps to reproduce:
1. Open the attached project "Case_1277326"
2. Open "SampleScene"
3. In the Hierarchy window Expand select Canvas->GameObject
4. In the Inspector window notice that there is not "onItemChanged" class
Expected results: public class "onItemChanged" is visible in the Inspector window
Actual results: public class "onItemChanged" is not visible in the Inspector window
Reproducible with: 2019.4.9f1, 2020.1.6f1, 2020.2.0b2
Unable to test with: Due to classes derived not from Monobehaviour are not allowed on GameObjects
Note:
-If the Script is imported to the Project with MonoBehaviour main class and then changed to ScrollRect it will not reproduce the issue but could throw errors, then reimporting it fixes the errors but the issue starts to occurs
-Screenshots of expected and actual are below
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Some UXML Template Asset foldouts appear enabled when all fields inside are disabled
- URP Terrain Demo crash on burst_signal_handler after Generating lighting
- Project window button icons are poorly visible and their shades differ in Light theme
- Automatic LOD fails and SRP Batcher incompatibility occurs when using spline-based quad-topology meshes
- Editor crashes on D3D12GetInterface when repeatedly enabling and disabling 256 text components
Resolution Note:
This is how inspector framework works.
In this specific case, MonoBehaviour inherits from ScrollRect and because of that Inspector appearance/drawing is controlled by ScrollRectEditor.
You can draw your custom properties by extending ScrollRectEditor:
[CustomEditor(typeof(NewBehaviourScript))]
public class NewBehaviourScriptEditor : ScrollRectEditor
{
private SerializedProperty onItemChangedProp;
protected override void OnEnable()
{
base.OnEnable();
onItemChangedProp = serializedObject.FindProperty("onItemChanged");
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
EditorGUILayout.PropertyField(onItemChangedProp);
serializedObject.ApplyModifiedProperties();
}
}
You can find more information on creating custom editors in here: https://docs.unity3d.com/Manual/editor-CustomEditors.html