Area
Rendering
What problem are you trying to solve?
Currently, when a user creates a Python script, attaches it to a GameObject, and later changes the class name inside the script (e.g., from PlayerMovement to NewPlayerMovement), the component reference on the GameObject is lost. The editor shows a missing script error, and the user has to manually reattach the renamed component.
Proposed solution
The engine should automatically detect the class name change and update the component reference on the GameObject accordingly. The script should remain attached without requiring manual reattachment.
Alternatives considered
- Require manual reattachment – Current behavior. Simple to implement but breaks workflow and is error-prone.
- Warn the user and suggest reattachment – Adds a dialog but still requires manual action. Better than silent failure but not a true fix.
- Use GUID-based tracking – Store a stable identifier (e.g., in a
.meta file next to the script). The engine uses this GUID to find the script regardless of class name changes. This is the most robust solution and matches how Unity handles script renaming.
- Use file path as primary key – Simpler than GUID but breaks if the file is moved or renamed. Partial solution.
Additional context
- The current system uses the class name as the component identifier, which is fragile.
- A GUID-based approach would require:
- Generating a GUID when a new script is created.
- Storing it in a
.meta file (or in script metadata).
- Updating the scene file to reference the GUID instead of the class name.
- When the engine loads a script, it resolves the GUID to the current class name.
- This change touches the asset pipeline (
AssetDatabase), serialization, and the component instantiation system.
- It also enables better refactoring support (e.g., moving/renaming script files without breaking references).
- This feature is especially important for larger projects or team workflows where renaming is common.
Area
Rendering
What problem are you trying to solve?
Currently, when a user creates a Python script, attaches it to a GameObject, and later changes the class name inside the script (e.g., from
PlayerMovementtoNewPlayerMovement), the component reference on the GameObject is lost. The editor shows a missing script error, and the user has to manually reattach the renamed component.Proposed solution
The engine should automatically detect the class name change and update the component reference on the GameObject accordingly. The script should remain attached without requiring manual reattachment.
Alternatives considered
.metafile next to the script). The engine uses this GUID to find the script regardless of class name changes. This is the most robust solution and matches how Unity handles script renaming.Additional context
.metafile (or in script metadata).AssetDatabase), serialization, and the component instantiation system.