Class ScyllaSplitView
A two-pane split view that remembers where the user left the splitter.
Implements
Inherited Members
Namespace: Scylla.Core.Editor
Assembly: ScyllaCore.Editor.dll
Syntax
public sealed class ScyllaSplitView : TwoPaneSplitView, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, ICustomStyle
Remarks
Unity's UnityEngine.UIElements.TwoPaneSplitView does everything here except persist, and persisting it correctly is the part that is easy to get wrong.
The trap: fixedPaneInitialDimension looks like the property to
save, and is not. It is read-only and keeps reporting the value passed to the
constructor, so saving it back stores the default over and over and a dragged splitter
never survives. The live size has to be read from the fixed pane's
resolvedStyle instead, which is what this class does, and which is why the
width is captured on detach rather than read on demand: a detached pane has no
resolved layout left to read.
The stored value is applied through the base constructor, because the fixed pane does not exist until panes are added and there is no later hook that runs before first layout.
The containment styles are applied here too. Both places that previously built a split view by hand set a different subset of them to solve the same overflow problem, and neither wrote down which ones mattered.
Constructors
ScyllaSplitView(int, float, TwoPaneSplitViewOrientation, string, float)
Initializes a split view, restoring the stored splitter position when there is one.
Declaration
public ScyllaSplitView(int fixedPaneIndex, float defaultDimension, TwoPaneSplitViewOrientation orientation, string prefKey = null, float minDimension = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | fixedPaneIndex | Which pane keeps its size, |
| float | defaultDimension | Size of the fixed pane before the user has moved it. |
| TwoPaneSplitViewOrientation | orientation | Whether the panes sit side by side or stacked. |
| string | prefKey | Preference key suffix for the splitter position, namespaced by
ScyllaEditorPrefs. Pass |
| float | minDimension | Floor applied to a restored position. Guards against reopening with a pane too small to find, whether from an old preference or a window resized very narrow last session. |
Properties
DefaultDimension
Gets the dimension used when nothing has been stored yet.
Declaration
public float DefaultDimension { get; }
Property Value
| Type | Description |
|---|---|
| float |
PrefKey
Gets the preference key suffix the splitter position is stored under, or null
when this view does not persist.
Declaration
public string PrefKey { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
SavePosition()
Writes the current splitter position to preferences.
Declaration
public void SavePosition()
Remarks
Called automatically when the view leaves the panel, which covers a window close and a domain reload. Call it directly only to checkpoint mid-session.
Does nothing when the layout has not resolved, so a view that is created and torn down without ever being shown cannot overwrite a good stored value with a zero.