Skip to main content

SlidingDoor

A class in Root.Township, the global namespace.

A Door that opens by sliding a moving part to an offset position instead of swinging.

Constructors​

MemberWhat it is
SlidingDoor()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

5 private and internal fields
MemberWhat it is
private float durationSeconds a slide takes.
private bool isTransitioningTrue while the slide coroutine is running.
private AnimationCurve movementCurveEasing curve. It is evaluated but the result is unused, so the slide is linear.
private Transform movingPartThe transform that slides.
private Vector3 offsetLocationLocal position of the part when open.

Methods​

MemberWhat it is
override void InitializeAsServer(SpawnData spawnData)Server: places the part at the open or closed position to match the saved state.
protected override void HandleChange()Starts the slide when the door's open state changes.
2 private and internal methods
MemberWhat it is
private IEnumerator ChangeOpen() (iterator)Coroutine that slides the part to the open or closed position, repeating if the state changed meanwhile.
private void OnValidate()Editor: places the part to match IsOpen outside play mode.