Editor: "New Script" button on the Script inspector

Stage-10 editor-UX follow-up. The Script component's inspector section
now ends with a name field + " New Script" button (Enter in the field
also submits): it writes a fresh .rhai from the tested template into
assets/scripts/ via create_script_file (sanitized stem, collisions
suffixed), registers it in the asset database, saves the manifest, and
assigns it to the component's `source` through the normal edit path —
so the assignment is one undoable SetFieldCmd. Disabled with a hint
while no project is open; failures land in the Console via the log.

GUI piece — needs an eye-check before promotion to main.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Homer
2026-07-10 20:33:23 +02:00
parent d6cb9947b2
commit 4f1e9a48d7
3 changed files with 79 additions and 0 deletions
+4
View File
@@ -685,6 +685,10 @@ console)**. Each is GUI → `dev` + eye-check.
auto-assign it to the component, without leaving the editor — today scripts
must be authored as files outside the editor. The `.rhai` loader +
`AssetKind::Script` already exist; this writes a template file + registers it.
**🚧 On `dev` (2026-07-10), awaiting eye-check**: name field + button at the
bottom of the Script section; template/sanitize/collision helpers are
unit-tested on `main` (`editor/src/assets.rs`), assignment goes through
`SetFieldCmd` (undoable).
- **Open a script in an editor** (Stage 10 follow-up). Double-click / button to
open a `.rhai` in an in-editor text view or launch `$EDITOR` / a configured
external editor; edits flow back through the existing live reload.