Vixen
dd8b0a81
csharp
public sealed class PrefabSource

What an inspected object was made from, answered out of the instance's own claims.

Read the guide page for this →

Remarks

Row 6 of doc 47 § 7, and the reason it was not wiring. The presentation — the bolded row, the enabled Revert item — has existed since the inspector was written and had never been shown a pairing in the running editor, because nothing assigned InspectorView.Prefab. This is what does, and two decisions had to be made first rather than silently.

⚠⚠ Overridden means "the instance claims it", read from Prefabs. The previous implementation compared the inspected object's value with the template's, which is model (A) of doc 47 § 3 and is rejected there: a comparison cannot see an override to 0, nor an override to a value that happens to equal the template's, so the row would quietly stop being marked and the revert button would grey out on exactly the edits an author most wants back. The file has the right answer written down — overrides: is a list of names — and this reads it.

⚠ The editor application's SceneEntity's position and rotation are world space and SceneEntityData's are relative to the parent. The two objects a pairing joins do not mean the same thing by "position", so TryGetPrefabValue takes the template's value through the instance's parent before handing it back — otherwise a revert would write a local value into a world-space setter and put the entity somewhere nobody asked for. It is a correctness bug that would have looked like a UI glitch. Scale needs no conversion: both sides are relative to the parent, which is why SceneEntity.Scale reads LocalScale.

Objects, not entities, because that is what an inspector edits. The shell pairs each object it shows with the entity it belongs to and, for a component, the alias that names it — see Link — and everything else is a member path built from that.

Fields and properties (1)

  • public int Count

    How many objects are paired.

Methods (8)

  • public PrefabSource(SceneDocument document, AssetDatabase assets)

    Pairs an inspector's objects with the scene they belong to.

  • public void Link(object target, Entity entity, string alias = "")

    Says which entity an inspected object stands for, and which part of it.

  • public bool Unlink(object target)

    Forgets a pairing.

  • public void Clear()

    Forgets every pairing, and every template read for one.

  • public bool IsOverridden(object target, InspectorMember member)

    Whether an object's member is the instance's own rather than the prefab's.

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

    The value the prefab has for a member, in the space the object reads it in.

  • public bool Claim(object target, InspectorMember member)
  • public bool Release(object target, InspectorMember member)

Used by (3)

  • ComponentsViewVixen.Editor.App
  • EditorApplicationVixen.Editor.App
  • PrefabInspectorTestsVixen.Editor.AssetEditors.Tests