Scripting API
Everything you can set in the Inspector can also be set from code, and every component exposes its state. This section gives an overview and covers the parts that are not tied to one component. The members of each component are listed on its page in Components.
The full source code is included and documented with XML comments, so your IDE shows a description for every public type and member.
| Page | What it covers |
|---|---|
| Vision System | The update loop, the order of events in a frame, team queries, quality, plane conversions |
| Low-level API | Computing visibility yourself, without components: solver, queries, obstacles, the awareness model |
Assemblies and namespaces
| Assembly | Namespace | Contents |
|---|---|---|
Renvix.VisionFog.Core | Renvix.VisionFog.Core | The visibility solver and point queries. Pure math, Burst-compatible |
Renvix.VisionFog.Runtime | Renvix.VisionFog | Vision Source, Vision Target, Vision Perception, Detection Profile, Vision Occluder, VisionSystem, VisionQuality, VisionPlane |
Renvix.VisionFog.Presentation | Fog Of War, Fog Hider, Vision Cone Renderer | |
Renvix.VisionFog.Occluders | Reading obstacles from 2D and 3D physics | |
Renvix.VisionFog.URP | Renvix.VisionFog.URP | The renderer feature |
The assemblies are referenced automatically by scripts in the default Assembly-CSharp. If your scripts are in their own assembly definition, add Renvix.VisionFog.Runtime to its references, plus Renvix.VisionFog.Core for the low-level API and Unity.Mathematics and Unity.Collections if you use plane coordinates or native arrays.
Main types
| Type | Namespace | Page |
|---|---|---|
VisionSource | Renvix.VisionFog | Vision Source |
VisionOccluder | Renvix.VisionFog | Vision Occluder |
VisionTarget | Renvix.VisionFog | Vision Target |
VisionPerception, AwarenessLevel | Renvix.VisionFog | Vision Perception |
DetectionProfile | Renvix.VisionFog | Detection Profile |
VisionConeRenderer | Renvix.VisionFog.Presentation | Vision Cone Renderer |
FogOfWar | Renvix.VisionFog.Presentation | Fog Of War |
FogHider | Renvix.VisionFog.Presentation | Fog Hider |
VisionSystem, VisionQuality, VisionPlane | Renvix.VisionFog | Vision System |
Common tasks
| Task | Code |
|---|---|
| Can this source see a point? | source.CanSee(point) |
| Does any source of a team see a point? | VisionSystem.IsVisibleToTeam(team, point) |
| What does a guard know about the player? | perception.TryGetTracked(playerTarget, out var tracked) |
| React when a guard detects someone | perception.BecameAlerted += (observer, target) => ... |
| Make the player harder to notice | playerTarget.Visibility = 0.5f |
| Change the view at runtime | source.FieldOfView = 45f; source.Radius = 12f; |
| Glass that shatters | occluder.SeeThrough = 1f |
| Is an enemy visible to the player? | enemyHider.IsVisible |
| Reset or reveal the map | fog.ResetExplored(), fog.RevealAll() |
| Fog textures for a minimap | fog.VisibleTexture, fog.ExploredTexture, see Minimap |
| Lower the quality on weak devices | VisionQuality.Level = VisionQualityLevel.Low |
| Get a result right after teleporting | source.ForceUpdate() |