Quick Outline for Unity

repository·master·Indexed 20 days ago

https://github.com/chrisnolet/quickoutline

A lightweight, world-space outline tool for Unity optimized for VR environments. It supports MSAA, Instanced Stereo rendering, and post-processing stacks. The tool provides an Outline component for configuring outline mode, color, and width, with options for precomputing outlines on large meshes to optimize performance.

Tokens
494
Snippets
1
Records
4
Agent score
22%

What's inside Quick Outline

  1. Add an outline to an object

    master

    You can add an outline to a Unity GameObject using two methods:

    Method 1: Editor (Drag-and-Drop)

    Drag and drop the Outline.cs script directly onto the target GameObject in the Unity Editor. The required outline materials will be loaded automatically at runtime.

    Method 2: Programmatic (C#)

    Add the Outline component via script and configure its properties. To toggle the outline visibility, use the enabled property rather than adding or removing the component to ensure optimal performance.

    var outline = gameObject.AddComponent<Outline>();
    
    outline.OutlineMode = Outline.Mode.OutlineAll;
    outline.OutlineColor = Color.yellow;
    outline.OutlineWidth = 5f;
    
    // To toggle visibility, use enabled:
    outline.enabled = true;
  2. Troubleshoot off-center outlines

    master

    If the outline appears off-center on your object, apply the following fixes:

    1. Model Import Settings: Select the model in your project and ensure 'Read/Write Enabled' is checked in the import settings.
    2. Player Settings: Go to your Player settings and disable 'Optimize Mesh Data'.
  3. Configure the Outline component properties

    master

    The Outline component allows you to customize the appearance of the outline via the following properties:

    • OutlineMode: Determines how the outline is rendered (e.g., Outline.Mode.OutlineAll).
    • OutlineColor: Sets the color of the outline.
    • OutlineWidth: Sets the thickness of the outline.
    • enabled: Use this boolean to toggle the outline on or off. It is recommended to use this instead of AddComponent or Destroy to avoid unnecessary overhead in Awake().