Untitled
var light = hit.collider.gameObject.AddComponent<Light2D>(); light.SetShapePath(new Vector3[4] { new Vector3(-0.5f, -0.5f), new Vector3(0.5f, -0.5f), new Vector3(0.5f, 0.5f), new Vector3(-0.5f, 0.5f) }); light.lightType = Light2D.LightType.Freeform; light.shadowIntensity = 0.1f; light.falloffIntensity = 0; light.shapeLightFalloffSize = 0; light.intensity = 0; // Start with 0 intensity StartCoroutine(FadeInLight(light, 1f, 2f)); IEnumerator FadeInLight(Light2D light, float targetIntensity, float duration) { float initialIntensity = light.intensity; float elapsed = 0f; while (elapsed < duration) { elapsed += Time.deltaTime; light.intensity = Mathf.Lerp(initialIntensity, targetIntensity, elapsed / duration); yield return null; PopupTextWorld.Popup("x", transform.position, Vector3.up * 2, 1f); } PopupTextWorld.Popup("x done", transform.position, Vector3.up * 2, 1f); light.intensity = targetIntensity; }
Leave a Comment