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
- Profiler - Taking you to the wrong section when using 'show'
- Draw Renderers custom pass doesn't work with SSGI
- WebCamTexture does not set the requested resolution when used in WebGL
- Editor default Stylesheet/Matching Selector buttons in Debugger don't do anything
- Graphics.DrawMeshNow stops rendering Render Texture after a few frames when viewed in the Player
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