Web View UGUI

🖼️ WebViewUGUI Class

A UI element with panning and zooming capabilities for viewing a skill web in Unity’s UGUI system.

Namespace: Esper.SkillWeb.UI.UGUI Access: public Type: class Inherits: RuntimeWebViewer Implements: IScrollHandler, IBeginDragHandler, IDragHandler, IEndDragHandler


📦 Fields

Access
Field
Type
Description

public

enableTesting

bool

Enables testing mode.

public

startingSkillPoints

int

Starting skill points for test purposes.

protected [SerializeField]

skillNodeTinyPrefab

SkillNodeUGUI

Prefab for tiny skill node.

protected [SerializeField]

skillNodeSmallPrefab

SkillNodeUGUI

Prefab for small skill node.

protected [SerializeField]

skillNodeMediumPrefab

SkillNodeUGUI

Prefab for medium skill node.

protected [SerializeField]

skillNodeLargePrefab

SkillNodeUGUI

Prefab for large skill node.

protected [SerializeField]

skillNodeGiantPrefab

SkillNodeUGUI

Prefab for giant skill node.

protected [SerializeField]

connectionPrefabs

ConnectionUGUI[]

Prefabs for connections.

public

content

RectTransform

Main content container.

public

graphContent

RectTransform

UI object that is panned and zoomed.

public

bounds

RectTransform

Bounds of the graph.

public

clampInsideScreen

bool

If true, bounds use screen size; otherwise content size.

protected

canvas

Canvas

Main canvas reference.

public

loadedSkillNodes

Dictionary<int, SkillNodeUGUI>

Loaded skill node UI objects.

public

loadedConnections

Dictionary<Connection, ConnectionUGUI>

Loaded skill connection objects.

protected

lastMousePosition

Vector2

Last mouse position before dragging.

public [NonSerialized]

targetScale

Vector3

Target zoom scale.

public [NonSerialized]

targetPosition

Vector2

Target position for zooming.

protected

startingScale

Vector3

Starting scale for reset.

protected

startingPosition

Vector2

Starting position for reset.

protected

boundsSize

Vector2

Size of panning bounds.

public [NonSerialized]

move

Vector2

Constant offset applied to target position.

public [NonSerialized]

zoomDelta

float

Constant zoom delta.

protected

controlDisabled

bool

If graph control is disabled.

public

onBeginDrag

UnityEvent

Callback when dragging begins.

public

onDrag

UnityEvent<Vector2>

Callback when dragging occurs (delta).

public

onEndDrag

UnityEvent

Callback when dragging ends.

public

onZoom

UnityEvent

Callback when zoom occurs.


🔍 Properties

Access
Property
Type
Description

public

IsOpen

bool

True if content is active.

public static

Active

WebViewUGUI

Currently active web view.

public static [Obsolete]

Instance

WebViewUGUI

Deprecated; use Active instead.


🧰 Methods

Access
Method
Returns
Description

private

Awake()

void

Initializes canvas, sets target scale, marks active.

private

Start()

void

Loads web if webName set, applies testing skill points.

private

Update()

void

Handles zoom/pan interpolation and hovercard updates.

public static

Find(string webName, bool log = true)

WebViewUGUI

Finds a WebViewUGUI in scene by name.

public

SetActive()

void

Sets this view as active.

public virtual

Open()

void

Enables the web view.

public virtual

Close()

void

Disables the web view and hides selector.

public virtual

Toggle()

void

Toggles open/close state.

public

Unload()

void

Clears loaded nodes and connections, resets scale/position.

public

Load(WebGraph webGraph)

void

Loads a web graph into the view.

public

Load(Web web)

void

Loads a web object into the view.

public

Load()

void

Loads current web reference.

protected

CreateUI()

void

Builds UI for nodes and connections.

public

UpdateAllStates()

void

Updates all skill node states.

public

ResetAllSkills()

void

Resets all skills in the web.

public

CreateVisualConnectionLine(Vector2 position, int nodeID, int prefabIndex = 0)

void

Creates a visual-only connection line to a node by ID.

public

CreateVisualConnectionLine(Vector2 position, SkillNodeUGUI node, int prefabIndex = 0)

void

Creates a visual-only connection line to a node object.

public

ResetView()

void

Resets the view to starting scale/position.

public

Move(Vector2 dir)

void

Pans the graph in a direction.

public

Snap(SkillNodeUGUI skillNodeUGUI)

void

Snaps view to a specific skill node.

public

UpgradeFocused()

void

Upgrades currently focused skill.

public

DowngradeFocused()

void

Downgrades currently focused skill.

protected

ControlDelayCoroutine(float delay)

IEnumerator

Coroutine disabling control temporarily.

public

GetFocused()

SkillNodeUGUI

Returns currently focused node.

public

Focus(SkillNodeUGUI node, bool showSelector = true)

void

Focuses on a specific node.

public

RemoveFocus()

void

Clears focus and hides selector.

public

Focus(Vector2 dir, bool showSelector = true)

void

Focuses closest node in a direction.

public

GetZoom()

float

Returns current zoom value.

public

SetZoom(float zoom)

void

Sets zoom with clamping.

public

SetZoomInstant(float zoom)

void

Sets zoom instantly.

public

SetConstantZoom(float zoomStrength)

void

Applies constant zoom.

public

Zoom(Vector2 position, float scrollDelta, bool normalize = true)

void

Zooms towards a screen position.

public

OnScroll(PointerEventData eventData)

void

Handles scroll wheel zoom and hides selector.

public

OnBeginDrag(PointerEventData eventData)

void

Starts drag panning, records mouse position, hides selector, invokes callback.

public

OnDrag(PointerEventData eventData)

void

Updates target position while dragging, invokes drag callback.

public

OnEndDrag(PointerEventData eventData)

void

Ends drag and invokes callback.

public

SetPositionInstant(Vector2 newPosition)

void

Instantly sets target position with clamping.

private

UpdateBounds(Vector2 targetPosition)

void

Updates panning bounds based on target position.

private

SetTargetPosition(Vector2 newPosition)

void

Attempts to set target position, applies clamping.

private

ClampScale(Vector3 scale)

Vector3

Clamps the scale within the min and max ranges.

private

FocusCoroutine(SkillNodeUGUI skillNodeUGUI)

IEnumerator

Focuses on a skill node.

private

ResetViewCoroutine()

IEnumerator

Resets the view.

Last updated