Hi,
I've extended the Standard UI Menu Panel class to add a couple of custom functions. Included in this new script are a few public fields to assign, including a gameobject, transform and audio source.
However, when I inherit from Standard UI Menu Panel, all of my public fields from the derived script disappear, leaving only the inherited ones. If I remove the inheritance and inherit from Monobehaviour, my fields reappear. I'm not getting any warnings about hiding inherited members.
I can't seem to figure out the problem - is this standard behaviour or something specific to Dialogue System? Would really appreciate a pointer in the right direction! Thanks.
Fields disappearing when inheriting from Standard UI Menu Panel?
Re: Fields disappearing when inheriting from Standard UI Menu Panel?
Hi,
Are you talking about your custom fields not appearing in the inspector?
If so, this is because StandardUIMenuPanel uses a custom inspector script named StandardUIMenuPanelEditor. You can subclass it to show your custom fields. Create a new script in any folder named Editor, such as:
CustomMenuPanelEditor.cs
Are you talking about your custom fields not appearing in the inspector?
If so, this is because StandardUIMenuPanel uses a custom inspector script named StandardUIMenuPanelEditor. You can subclass it to show your custom fields. Create a new script in any folder named Editor, such as:
CustomMenuPanelEditor.cs
Code: Select all
using UnityEngine;
using UnityEditor;
using PixelCrushers.DialogueSystem;
[CustomEditor(typeof(CustomMenuPanel))]
public class CustomMenuPanelEditor : StandardUIMenuPanelEditor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
serializedObject.Update();
// Your code here to show your custom fields. Example:
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(CustomMenuPanel.myCustomField1)), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(CustomMenuPanel.myCustomField2)), true);
serializedObject.ApplyModifiedProperties();
}
}
Re: Fields disappearing when inheriting from Standard UI Menu Panel?
I'm referring to publicly exposing objects so I can assign them in the inspector - is that the same thing? Sorry, I'm a bit new to inspector stuff
Re: Fields disappearing when inheriting from Standard UI Menu Panel?
Yes, that's the same thing. For example, say you've made a subclass like this:
Then you'd need to create an Editor script like this to show the "numMenusShown" variable:
Code: Select all
public class CustomMenuPanel : StandardUIMenuPanel
{
public int numMenusShown; // Counts # of times ShowResponses is called this play session.
public override void ShowResponses(Subtitle subtitle, Response[] responses, Transform target)
{
base.ShowResponses(subtitle, responses, target);
numMenusShown++;
}
}
Code: Select all
using UnityEngine;
using UnityEditor;
using PixelCrushers.DialogueSystem;
[CustomEditor(typeof(CustomMenuPanel))]
public class CustomMenuPanelEditor : StandardUIMenuPanelEditor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
serializedObject.Update();
// Show the numMenusShown field:
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(CustomMenuPanel.numMenusShown)), true);
serializedObject.ApplyModifiedProperties();
}
}
Re: Fields disappearing when inheriting from Standard UI Menu Panel?
Understood, thanks!