Class WorkshopDirtyState

Namespace
TDMaker.Editor
Assembly
TDMaker.Editor.dll

Remembers the last saved (clean) state of the assets an editor window edits, so that Undo back to that state clears the "modified" mark again (Unity keeps an asset dirty after Undo), and so that unsaved edits can be discarded on request. Snapshots are taken once per clean period (when an asset is first seen not dirty), not every frame.

public sealed class WorkshopDirtyState
Inheritance
WorkshopDirtyState
Inherited Members

Constructors

WorkshopDirtyState()

public WorkshopDirtyState()

Methods

Clear()

Forgets every snapshot.

public void Clear()

Discard(Object)

Restores asset to its last clean snapshot and clears its dirty flag. Returns false when no clean state is known (the asset was already modified when the window first saw it); the edits then stay in memory.

public bool Discard(Object asset)

Parameters

asset Object

Returns

bool

HasSnapshot(Object)

Whether a clean state of asset is known.

public bool HasSnapshot(Object asset)

Parameters

asset Object

Returns

bool

IsModified(Object)

Whether asset has edits that are not on disk.

public static bool IsModified(Object asset)

Parameters

asset Object

Returns

bool

Observe(Object)

Records the clean state of asset when it is not dirty (call before it gets edited).

public void Observe(Object asset)

Parameters

asset Object

Reconcile(IEnumerable<Object>)

After Undo / Redo: every dirty asset whose data equals its saved snapshot is marked clean again. Returns how many assets were cleared.

public int Reconcile(IEnumerable<Object> assets)

Parameters

assets IEnumerable<Object>

Returns

int

ReconcileAll()

Reconciles every asset this tracker has seen.

public int ReconcileAll()

Returns

int

Save(Object)

Writes asset to disk and takes its new clean snapshot.

public void Save(Object asset)

Parameters

asset Object