Renvix Assets

UI and the Fog

With the Renderer Feature, the fog is drawn over the finished scene, just before post-processing. Everything that is part of the scene is under the fog: sprites, meshes, particles and also UI on Screen Space - Camera and World Space canvases. This is what you want for the game world, but not for the HUD.

HUD above the fog

Put the HUD, menus and the minimap on a canvas with Render Mode: Screen Space - Overlay. Overlay canvases are drawn after the whole camera, so they are always above the fog.

The sorting order of sprites does not help here. With the renderer feature, even a sprite with a very high Order in Layer is drawn before the fog. Sorting only matters for the fallback overlay that is used without the feature.

Health bars and labels over units

Health bars, names and ? / ! signs above characters belong to the world: they should be hidden in the fog together with their owner.

A Fog Hider hides renderers under its object: sprites, meshes and TextMeshPro text, the 3D one, not the UI one. A Canvas is not a renderer, so a World Space canvas with a health bar is not hidden by the Fog Hider and would show where the enemy is.

Two ways to handle this:

  • Use renderers for world labels. A health bar made of sprites, or a TextMeshPro (not TextMeshProUGUI) label, is a child renderer and is hidden with the unit. The demo's AwarenessIndicator.cs creates its ? / ! sign this way.
  • Hide the canvas from code using the hider's state:
using Renvix.VisionFog.Presentation;
using UnityEngine;

public class HideCanvasInFog : MonoBehaviour
{
    [SerializeField] FogHider hider;
    [SerializeField] CanvasGroup canvasGroup;

    void LateUpdate() => canvasGroup.alpha = hider.IsVisible ? 1f : 0f;
}

Damage numbers and effects

Effects spawned at a position, such as damage numbers, hit sparks or blood decals, are not children of a hidden unit. If they are spawned in the fog, they are covered by the fog anyway, so usually nothing needs to be done. For effects drawn on an overlay canvas, check the position first:

if (VisionSystem.IsVisibleToTeam(0, hitPoint))
    ShowDamageNumber(hitPoint, damage);