Vixen
02b45cc4
csharp
public sealed class PrefabSource

What an inspected object was made from, so the inspector can mark and revert overrides.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Objects, not entities, and that is what keeps this out of the application. An inspector edits objects — whatever the shell decided an entity's row of editors is — and what it needs answered is "does this object's member differ from the one it was made from". So a caller pairs each inspected object with the object standing for the template, and everything else falls out of comparing one member on two objects.

TryFind is how the pairing is normally found: the instance's link names an entity in a prefab file, and the caller builds the same kind of wrapper over that entity's data as it builds over an entity in the world.

⚠ An object with no pairing is not overridden and has no prefab value. That is the ordinary answer for a scene object that never came from a prefab, and it is why CanRevertToPrefab is false there rather than the revert button quietly writing a default.

Fields and properties (1)

  • public int Count

    How many objects are paired.

Methods (5)

  • public void Link(object instance, object template)

    Says that an object was made from another one.

  • public bool Unlink(object instance)

    Forgets a pairing.

  • public void Clear()

    Forgets every pairing.

  • public bool IsOverridden(object target, InspectorMember member)

    Whether an object's member differs from the prefab it was made from.

  • public bool TryGetPrefabValue(object target, InspectorMember member, out object? value)

    The value the prefab has for a member.

Used by (1)

  • PrefabSourceTestsVixen.Editor.AssetEditors.Tests