Skip to guide
Rainbow Lab/Documentation

Outline Foundry

Scripting reference

Use the Foundry.Outlines namespace. FoundryOutline is the main component; OutlineStyle stores a shared OutlineAppearance. The runtime assembly is Foundry.Outlines.

Show and hide

csharp
using Foundry.Outlines;
using UnityEngine;

public sealed class SelectionHighlight : MonoBehaviour
{
    [SerializeField] FoundryOutline outline;

    public void Select() => outline.Show(0.15f);
    public void Deselect() => outline.Hide(0.2f);
    public void SetStrength(float amount) => outline.FadeTo(amount, 0.15f);
}

Show and Hide target Opacity 1 and 0. A zero duration changes immediately. FadeTo clamps its target to 0..1. The optional third argument selects unscaled time, which defaults to true. Use false to pause the transition with the game.

IsFading reports an active transition. TargetOpacity reports its target, or the current opacity while idle. CancelFade stops a transition at its current opacity. Disabling the component cancels its transition and removes its effect; re-enabling does not restart the cancelled transition.

Edit an independent appearance

Settings returns the linked style's appearance when a style is assigned. Make a copy and detach before changing settings for one object:

csharp
using Foundry.Outlines;
using UnityEngine;

public sealed class HighlightAppearance : MonoBehaviour
{
    [SerializeField] FoundryOutline outline;

    public void ApplyLocalColour(Color colour)
    {
        if (outline.style)
        {
            outline.appearance = outline.Settings.Copy();
            outline.style = null;
        }
        outline.appearance.colour = colour;
        outline.appearance.width = 4f;
    }
}

Assigning outline.style links a shared asset. Changing outline.Settings while it is linked changes that shared appearance. Per-object opacity, priority, child inclusion and renderer exclusions belong to the component, rather than the style.

Fill, rim and band

csharp
OutlineAppearance appearance = outline.appearance;
appearance.fillPlacement = OutlineFillPlacement.InnerRim;
appearance.innerWidth = 10f;
appearance.customFillColour = true;
appearance.fill = new Color(0.2f, 0.9f, 0.8f, 0.6f);
appearance.fillPattern = OutlineFillPattern.Stripes;
appearance.patternSpacing = 18f;
appearance.patternMotion = new Vector2(10f, 0f);

appearance.outerBand = true;
appearance.outerWidth = 2f;
appearance.outerColour = Color.black;

This fragment assumes an independent local appearance, as in the previous example. New appearances inherit the main colour. Enable the corresponding custom colour flag when setting separate fill, hidden or gap colours. The band always uses outerColour. To change inherited fill opacity, retain its RGB and change appearance.fill.a.

ResolvedFill, ResolvedHiddenColour, ResolvedHiddenFill, ResolvedOuterColour, ResolvedPatternBackground and ResolvedHiddenPatternBackground expose the effective colours used for rendering.

Visibility and distance

Set appearance.visibility to OutlineVisibility.Visible, Hidden or Always. Custom hidden controls are customHiddenColour, customHiddenFillColour and customHiddenPatternBackgroundColour, with their matching colour fields. Use scaleWithDistance/referenceDistance for the optional outside-stroke scaling and fadeWithDistance/fadeStart/fadeEnd for distance fading.

Runtime hierarchy changes

csharp
outline.includeChildren = true;
outline.exclusions = new Renderer[] { rendererToIgnore };
outline.RefreshRenderers();

Call RefreshRenderers after adding or removing Renderer components. Parenting changes are detected automatically. Keep a child FoundryOutline enabled when it should own its own part rather than joining the parent's silhouette.