This post explains how to replace a component's script with a subclass. A frequent example is making a subclass of StandardDialogueUI that overrides some methods to add extra functionality. If you were to simply remove the dialogue UI's Standard Dialogue UI component and add your subclass as a new component, you'd lose all the UI element assignments that were assigned to the Standard Dialogue UI component.
Fortunately, it's possible to replace the component's script in place and retain those assignments. To do so:
1. Change the Inspector window to Debug mode by clicking the triple dot button in the upper right. This will open a menu with options Normal and Debug. Select Debug.
2. Inspect the GameObject whose component's script you want to change.
3. Drag the new script into the component's Script field.
Note: This technique is not possible when editing prefabs in Unity 2022+. In 2022+, you can unpack the prefab, change the script, and then save the prefab again.