private static void AddHoverLight(HoverLight light) { if (activeHoverLights.Count >= hoverLightCount) { Debug.LogWarningFormat("Max hover light count ({0}) exceeded.", hoverLightCount); } activeHoverLights.Add(light); }
private static void UpdateHoverLights(bool forceUpdate = false) { if (lastHoverLightUpdate == -1) { Initialize(); } if (!forceUpdate && (Time.frameCount == lastHoverLightUpdate)) { return; } if (activeHoverLights.Count > 1) { Shader.EnableKeyword("_MULTI_HOVER_LIGHT"); } else { Shader.DisableKeyword("_MULTI_HOVER_LIGHT"); } for (int i = 0; i < hoverLightCount; ++i) { HoverLight light = (i >= activeHoverLights.Count) ? null : activeHoverLights[i]; int dataIndex = i * hoverLightDataSize; if (light) { hoverLightData[dataIndex] = new Vector4(light.transform.position.x, light.transform.position.y, light.transform.position.z, light.Radius); hoverLightData[dataIndex + 1] = new Vector4(light.Color.r, light.Color.g, light.Color.b, 1.0f); } else { hoverLightData[dataIndex] = Vector4.zero; hoverLightData[dataIndex + 1] = Vector4.zero; } } Shader.SetGlobalVectorArray(_HoverLightDataID, hoverLightData); lastHoverLightUpdate = Time.frameCount; }
private Bounds OnGetFrameBounds() { HoverLight light = target as HoverLight; return(new Bounds(light.transform.position, Vector3.one * light.Radius)); }
private static void RemoveHoverLight(HoverLight light) { activeHoverLights.Remove(light); }