private void Awake() { if (Instance != null) { DestroyImmediate(this); //throw new System.Exception("you can only have one outline camera in the scene"); } Instance = this; }
void Start() { outline = GetComponent <Outline>(); if (HighlightOnGrabbable || HighlightOnRemoteGrabbable) { if (outline == null) { // Is there a renderer attached? if (GetComponent <Renderer>()) { outline = gameObject.AddComponent <Outline>(); outline.eraseRenderer = false; outline.enabled = false; } else { // Try in child object Renderer childRenderer = GetComponentInChildren <Renderer>(); if (childRenderer != null) { outline = childRenderer.gameObject.AddComponent <Outline>(); outline.eraseRenderer = false; outline.enabled = false; } } } } // Make sure camera can see outlines OutlineEffect oe = Camera.main.GetComponent <OutlineEffect>(); if (oe == null) { oe = Camera.main.gameObject.AddComponent <OutlineEffect>(); oe.lineThickness = 2; oe.lineIntensity = 1f; oe.fillAmount = 0; oe.lineColor0 = Color.white; oe.cornerOutlines = true; oe.scaleWithScreenSize = false; } }