We will build an ObjectOutliner class to handle the outlining for us. Follow along as we build the pieces to turn the outline on and off as the user selects an object:
- Create a new C# script called ObjectOutliner in the Assets/ARCoreDesign/Scripts folder.
- Replace all of the pregenerated script with the following:
namespace Packt.ARCoreDesign{ using System.Collections; using System.Collections.Generic; using UnityEngine; public class ObjectOutliner : MonoBehaviour { public int MaterialSlot; public Material DefaultMaterial; public Material OutlineMaterial; public bool outlineOn; public void Outline() { outlineOn = !outlineOn; var renderer = GetComponent<MeshRenderer>(); Material[] mats = renderer.materials; ...