User Manual

API Reference

Namespace

using UniversalOutlineSystem;

Class: UniversalOutline

The main component. Attach this to any GameObject with a Renderer.

Public Enums

OutlineMode

  • VertexExpansion: Expands outline along vertex normals
  • MetricScale: Scales outline uniformly in world space

Public Methods

void Show()

Enables and displays the outline effect.

Example:

UniversalOutline outline = GetComponent<UniversalOutline>();
outline.Show();

void Hide()

Disables and hides the outline effect. The outline renderer is cleared but the component remains active.

Example:

outline.Hide();

void Toggle()

Toggles the outline visibility. If visible, hides it. If hidden, shows it.

Example:

if (Input.GetKeyDown(KeyCode.Space))
{
    outline.Toggle();
}

void SetColor(Color color)

Sets a solid outline color and disables gradient mode.

Parameters:

  • color: The new solid color for the outline

Example:

outline.SetColor(Color.yellow);

void SetGradient(Color top, Color bottom)

Sets gradient colors and enables gradient mode.

Parameters:

  • top: Color at the top of the object
  • bottom: Color at the bottom of the object

Example:

outline.SetGradient(Color.cyan, Color.blue);

void SetWidth(float width)

Adjusts the outline width.

Parameters:

  • width: The new outline width (clamped 0-0.3 internally)

Example:

outline.SetWidth(0.1f);

void SetPulse(bool active)

Enables or disables the pulse width animation.

Parameters:

  • active: true to enable pulsing, false to disable

Example:

outline.SetPulse(true);

void SetGradientScroll(bool active)

Enables or disables the gradient scrolling animation.

Note: Gradient scrolling requires gradient mode to be enabled.

Parameters:

  • active: true to enable scrolling, false to disable

Example:

outline.SetGradientScroll(true);

Common Usage Patterns

Pattern 1: Simple Selection Feedback

UniversalOutline outline;

void OnMouseEnter()
{
    outline = GetComponent<UniversalOutline>();
    if (outline != null)
        outline.Show();
}

void OnMouseExit()
{
    if (outline != null)
        outline.Hide();
}

Pattern 2: Color-Coded States

UniversalOutline outline;

void SetHealthState(float healthPercent)
{
    outline = GetComponent<UniversalOutline>();
    
    if (healthPercent > 0.5f)
        outline.SetColor(Color.green);
    else if (healthPercent > 0.2f)
        outline.SetColor(Color.yellow);
    else
        outline.SetColor(Color.red);
    
    outline.Show();
}

Pattern 3: Dynamic Power-Up Effect

UniversalOutline outline;

void OnPowerUpCollected()
{
    outline = GetComponent<UniversalOutline>();
    outline.SetGradient(Color.yellow, Color.red);
    outline.SetPulse(true);
    outline.SetGradientScroll(true);
    outline.Show();
    
    StartCoroutine(RemoveEffectAfterDelay(5f));
}

IEnumerator RemoveEffectAfterDelay(float delay)
{
    yield return new WaitForSeconds(delay);
    outline.Hide();
}

Pattern 4: Team-Based Outlines

UniversalOutline outline;

void SetTeamColor(int teamID)
{
    outline = GetComponent<UniversalOutline>();
    
    switch (teamID)
    {
        case 0: outline.SetColor(Color.blue); break;
        case 1: outline.SetColor(Color.red); break;
        case 2: outline.SetColor(Color.green); break;
        case 3: outline.SetColor(Color.yellow); break;
    }
    
    outline.Show();
}

Internal Classes

These are in the UniversalOutlineSystem.Internal namespace and typically don’t need to be accessed directly:

  • Outline2DRenderer: Handles 2D sprite outline rendering
  • Outline3DRenderer: Handles 3D mesh outline rendering
  • OutlineMaterialProvider: Manages shader materials for outlines

Performance Tips

  1. Cache the UniversalOutline component reference instead of calling GetComponent repeatedly
  2. Use Show()/Hide() instead of enabling/disabling the component for better performance
  3. The system uses Material Property Blocks, so multiple objects can share the same outline material without issues
  4. Avoid calling SetColor() or SetWidth() every frame unless animating. Use the built-in pulse animation instead