Skip to main content

InteractableInspector

A class in Root.Township, the global namespace.

Debug bubble shown in the world for inspecting a prefab's components, methods and values in game. Pooled, client side, and released when you move more than 5 m away.

Constructors​

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

Fields​

16 private and internal fields
MemberWhat it is
private AnimationCurve angleToVariationCurve that maps hand twist angle to how far the value is rotated.
private bool btnInteractInspector button that calls Interact from the editor.
private Renderer bubbleRendererRenderer of the bubble, coloured by inspector type.
private bool canRotateCopied from the inspector: whether twisting the hand rotates the value.
private Coroutine checkingCoroutineThe running CheckInteraction, or null.
private Material componentMaterialBubble material for component inspectors.
private static Dictionary<Interactor, InteractableInspector> currentListStatic map of which bubble each interactor is currently using, so one hand drives one bubble at a time.
private InspectorBase inspectorThe InspectorBase this bubble shows, set by RegisterInspector.
private Interactable interactableThe Interactable on this object.
private Material interactorMaterialBubble material for interactor inspectors.
private Material methodMaterialBubble material for method inspectors.
private NetworkPrefab prefabThe inspected prefab, whose destruction cleans up the bubble.
private Component rootThe component being inspected.
private Transform rootTransformTransform of root, used for the distance check.
private TextPopup textThe pooled text popup that shows the name.
private Material valueMaterialBubble material for value inspectors.

Methods​

MemberWhat it is
void Clean()Unhooks everything, releases its text and returns the bubble to the pool.
void RegisterInspector(InspectorBase inspector, Component root)Sets which component, method, value or interactor this bubble shows and colours it by type.
void RegisterPrefab(NetworkPrefab prefab)Cleans the bubble up when that prefab's entity is destroyed.
8 private and internal methods
MemberWhat it is
private void Awake()Caches the Interactable and bubble renderer, hooks the interaction filter and the pool's Requested event.
private IEnumerator CheckInteraction(Interactor interactor) (iterator)Coroutine while Interact is held: dragging moves the bubble (inspector.Move), twisting rotates (inspector.Rotate), holding still and releasing calls Interact.
private void DistanceRelease(PlayerController player, Vector3 oldPosition, Vector3 newPosition, LocomotionFunction function)Client: releases the bubble and its label once the local player is more than 5 m from the inspected object.
private void FilterInteraction(Interactor interactor, Interactable interactable, ref bool result)Interaction filter that blocks the normal interaction and starts CheckInteraction instead, one per interactor.
private void Interact()Runs the inspector's action on the inspected component.
private void OnRequested(PooledObject pooledObject)Pool callback: spawns the text label and starts watching the local player's distance. Releases itself if there's no local player.
private void TargetDestroyed(NetworkEntity entity, bool isUnload)Calls Clean when the inspected prefab's entity is destroyed.
private void UpdateName(string addition = "")Sets the label text to the inspector's name plus an optional suffix.

Used in​

Members of other types that take, return or hold a InteractableInspector: