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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
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