Hi, thank you for your previous reply, it is helpful.
And now I want to inherit StandardUISubtitlePanel to override some function, but I find the pulic field can't be showed in the inspector. I think it's the serializable problem. If the script is not loaded in the gameobject on the scenes, I can find the field by inspector, but when it is loaded in the gameobject the field is hidden. Can you give me some suggests.
Serializable about inheriting StandardUISubtitlePanel
Serializable about inheriting StandardUISubtitlePanel
- Attachments
-
- 3.png (64.66 KiB) Viewed 154 times
-
- 2.png (71.2 KiB) Viewed 154 times
-
- 1.png (11.45 KiB) Viewed 154 times
Re: Serializable about inheriting StandardUISubtitlePanel
Hi,
StandardUISubtitlePanel has a custom editor script, so you'll need to create a custom editor script for your subclass. For example, if your subclass looks like this:
Then, in a folder named Editor, create an editor script:
StandardUISubtitlePanel has a custom editor script, so you'll need to create a custom editor script for your subclass. For example, if your subclass looks like this:
Code: Select all
public class MySubtitlePanel : StandardUISubtitlePanel
{
public bool MyBool;
}
Code: Select all
using UnityEngine;
using UnityEditor; //<-- Include this line in editor scripts.
using PixelCrushers.DialogueSystem;
[CustomEditor(typeof(MySubtitlePanel), true]
public class MySubtitlePanelEditor : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI(); // Draw the regular StandardUISubtitlePanel fields.
// Draw fields that were added in MySubtitlePanel:
serializedObject.Update();
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(MySubtitlePanel.MyBool)));
serializedObject.ApplyModifiedProperties();
}
}