Change outline visuals at runtime

Change outline visuals at runtime

Linework Sample

This sample explains how to change outline properties at runtime.

The configuration of each outline is stored in a settings object.

  • FastOutlineSettings
  • SoftOutlineSettings
  • WideOutlineSettings
  • EdgeDetectionSettings
  • SurfaceFillSettings

To change the properties of an outline, get a reference to these settings in your script and modify the properties directly.

As an example, see this script which changes the Outline Color of a Wide Outline to a random color whenever the spacebar is pressed.

Jump to heading Steps

  1. Assign this script component to any GameObject.
using Linework.WideOutline;  
using UnityEngine;  
  
public class ChangeOutline : MonoBehaviour  
{  
    [SerializeField] private WideOutlineSettings wideOutlineSettings;  
  
    private void Update()  
    {        
	    if (Input.GetKeyDown(KeyCode.Space))  
        {            
	        var color = new Color(
	        Random.Range(0.0f, 1.0f), 
	        Random.Range(0.0f, 1.0f), 
	        Random.Range(0.0f, 1.0f)
	        );  
	        
	        wideOutlineSettings.Outlines[0].color = color;
        }    
	}
}
  1. Drag the WideOutlineSettings object from your assets into the inspector field.

Confused?

Need more information about any of this? Contact me.

Enjoying Linework?

Writing a review helps me out greatly! It helps the asset's visibility and supports me in the development of Linework! If you have a support question, check ⁠support instead. Thank you very much.

Write a review