public static class AssetOperationsRenaming, moving and deleting a file the project knows about.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
⚠ "Rename with reference fixup" is not a rewrite here, and understanding why is the whole of this file. Doc 08 chose a GUID in a prefixed scalar over a path, and doc 20 calls a naive rename "the fastest way to corrupt a project" — both are true, and together they say that the referrers need nothing done to them. A scene points at vx:9e8a44c9…, the GUID lives in the sidecar, and the sidecar travels with the file. The corruption a naive implementation causes is not a stale path: it is leaving the .meta behind, at which point the next scan finds an asset with no identity, mints a new one, and every reference in the project is dangling with nothing having reported an error.
So the invariant is one sentence — the sidecar moves with the asset, atomically enough that a failure leaves neither moved — and every method here is that sentence plus the bookkeeping to make the database agree afterwards.
⚠ Delete reports before it acts. ReferrersOf answers "what breaks if I delete this" already; the caller is expected to ask Breakage and put the answer in front of somebody. Deleting first and showing a list of newly-broken scenes afterwards is not a warning.
⚠ Not undoable, and deliberately. These are filesystem operations, not document edits: there is no stack they belong to — the project has none — and a rename that could be undone from a scene's stack would be an undo that reaches outside the document it belongs to. Delete is the one that hurts, and asking first is the mitigation that matches what every editor does. A trash folder is worth having and is EditorProject's to own rather than this file's.
Methods (5)
public static AssetOperation Rename(EditorProject project, AssetId asset, string name)Gives an asset a new name in the folder it is already in.
public static AssetOperation Move(EditorProject project, AssetId asset, string folder)Moves an asset into another folder, keeping its name.
public static AssetOperation Delete(EditorProject project, AssetId asset)Deletes an asset and the sidecar that carries its identity.
public static AssetOperation CreateFolder(EditorProject project, string parent, string name)Makes a folder inside another one.
public static IReadOnlyList<string> Breakage(EditorProject project, IReadOnlyList<AssetId> assets)What would be left pointing at nothing if these assets went.
Used by (6)
- AssetOperationTestsVixen.Editor.Core.Tests
- DropIntoSceneTestsVixen.Editor.App.Tests
- EditorApplicationVixen.Editor.App
- GridViewTestsVixen.Editor.App.Tests
- ProjectTreeStateTestsVixen.Editor.App.Tests
- ScenarioTestsVixen.Editor.App.Tests