public void LateUpdate() { Color volumetricColour; if (SGT_GasGiant.ColourToPoint(Camera.main.transform.position, transform.position, 1.0f, false, false, out volumetricColour) == true) { if (probeMaterial == null) { probeMaterial = SGT_Helper.CreateMaterial("Hidden/SGT/Fog/Variant", probeRenderQueue); } probeMaterial.SetColor("fogColour", volumetricColour); SGT_Helper.InsertSharedMaterial(GetComponent <Renderer>(), probeMaterial, probeRecursive); SGT_Helper.SetRenderQueue(probeMaterial, probeRenderQueue); } else { if (probeMaterial != null) { SGT_Helper.RemoveSharedMaterial(GetComponent <Renderer>(), probeMaterial, probeRecursive); probeMaterial = SGT_Helper.DestroyObject(probeMaterial); } } }
public void Awake() { if (ThisHasBeenDuplicated("probeMaterial") == true) { SGT_Helper.RemoveSharedMaterial(GetComponent <Renderer>(), probeMaterial, probeRecursive); probeMaterial = SGT_Helper.CloneObject(probeMaterial); SGT_Helper.SetRenderQueue(probeMaterial, probeRenderQueue); } }