// Update is called every frame, if the // MonoBehaviour is enabled. void Update() { // make hologram flicker float newclip = (clippower - (ClipVariance / 2)) + (Random.value * ClipVariance); float rimrandom = Random.value; float rimchange = rimrandom * RimVariance; float newrim = rimpower - (RimVariance / 2); if (newclip < 0) { newclip = 0; } if (newrim < 0) { newrim = 0; } foreach (Material HoloMaterial in HoloMaterials) { HoloMaterial.SetFloat("_RimPower", newrim); HoloMaterial.SetFloat("_ClipPower", newclip); } // make light flicker if (FlickerLight != null) { if (rimchange < 0) { FlickerLight.intensity = intensity - (intensity * lightflicker * rimrandom); } else { FlickerLight.intensity = intensity + (intensity * lightflicker * rimrandom); } } }
// Update is called every frame, if the // MonoBehaviour is enabled. void Update() { float newbrightness = brightness; switch (State) { case HoloState.Off: return; case HoloState.On: break; case HoloState.PoweringDown: ProcessingTime += Time.deltaTime; if (ProcessingTime > 1.0f) { State = HoloState.Off; ProcessingTime = 0.0f; transform.localScale = OffScale; } else { float val = TurnOffCurve.Evaluate(ProcessingTime); TempScale.x = val; TempScale.z = val; transform.localScale = TempScale; newbrightness = val * brightness; } break; case HoloState.PoweringUp: ProcessingTime += Time.deltaTime; if (ProcessingTime > 1) { State = HoloState.On; ProcessingTime = 0.0f; transform.localScale = OnScale; } else { float val = TurnOnCurve.Evaluate(ProcessingTime); TempScale.x = val; TempScale.z = val; transform.localScale = TempScale; newbrightness = val * brightness; } break; } // make hologram flicker float newclip = (clippower - (ClipVariance / 2)) + (Random.value * ClipVariance); float rimrandom = Random.value; float rimchange = rimrandom * RimVariance; float newrim = rimpower - (RimVariance / 2); if (newclip < 0) { newclip = 0; } if (newrim < 0) { newrim = 0; } foreach (Material HoloMaterial in HoloMaterials) { HoloMaterial.SetFloat("_RimPower", newrim); HoloMaterial.SetFloat("_ClipPower", newclip); HoloMaterial.SetFloat("_Brightness", newbrightness); } // make light flicker if (FlickerLight != null) { if (rimchange < 0) { FlickerLight.intensity = intensity - (intensity * lightflicker * rimrandom); } else { FlickerLight.intensity = intensity + (intensity * lightflicker * rimrandom); } } }