private static void AddProximityLight(ProximityLight light) { if (activeProximityLights.Count >= proximityLightCount) { Debug.LogWarningFormat("Max proximity light count ({0}) exceeded.", proximityLightCount); } activeProximityLights.Add(light); }
private static void UpdateProximityLights(bool forceUpdate = false) { if (lastProximityLightUpdate == -1) { Initialize(); } if (!forceUpdate && (Time.frameCount == lastProximityLightUpdate)) { return; } int lightIndex, queueIndex; for (lightIndex = queueIndex = 0; queueIndex < activeProximityLights.Count && lightIndex < proximityLightCount; ++queueIndex) { ProximityLight light = activeProximityLights[queueIndex]; if (light) { int dataIndex = lightIndex++ *proximityLightDataSize; proximityLightData[dataIndex] = new Vector4(light.transform.position.x, light.transform.position.y, light.transform.position.z, 1.0f); float pulseScaler = 1.0f + light.pulseTime; proximityLightData[dataIndex + 1] = new Vector4(light.Settings.NearRadius * pulseScaler, 1.0f / Mathf.Clamp(light.Settings.FarRadius * pulseScaler, 0.001f, 1.0f), 1.0f / Mathf.Clamp(light.Settings.NearDistance * pulseScaler, 0.001f, 1.0f), Mathf.Clamp01(light.Settings.MinNearSizePercentage)); proximityLightData[dataIndex + 2] = new Vector4(light.Settings.NearDistance * light.pulseTime, Mathf.Clamp01(1.0f - light.pulseFade), 0.0f, 0.0f); proximityLightData[dataIndex + 3] = light.Settings.CenterColor; proximityLightData[dataIndex + 4] = light.Settings.MiddleColor; proximityLightData[dataIndex + 5] = light.Settings.OuterColor; } } for (; lightIndex < proximityLightCount; ++lightIndex) { int dataIndex = lightIndex * proximityLightDataSize; proximityLightData[dataIndex] = Vector4.zero; } Shader.SetGlobalVectorArray(proximityLightDataID, proximityLightData); lastProximityLightUpdate = Time.frameCount; }
private static void RemoveProximityLight(ProximityLight light) { activeProximityLights.Remove(light); }
private static void AddProximityLight(ProximityLight light) { activeProximityLights.Add(light); }