Ejemplo n.º 1
0
        private void AddHoverLight(HoverLight light)
        {
            if (activeHoverLights.Count >= hoverLightCount)
            {
                Debug.LogWarningFormat("Max hover light count ({0}) exceeded.", hoverLightCount);
            }

            activeHoverLights.Add(light);
        }
Ejemplo n.º 2
0
        private void UpdateHoverLights(bool forceUpdate = false)
        {
            if (lastHoverLightUpdate == -1)
            {
                Initialize();
            }

            if (!forceUpdate && (Time.frameCount == lastHoverLightUpdate))
            {
                return;
            }

            if (activeHoverLights.Count > 1)
            {
                Shader.EnableKeyword(multiHoverLightKeyword);
            }
            else
            {
                Shader.DisableKeyword(multiHoverLightKeyword);
            }

            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;
        }
Ejemplo n.º 3
0
 private void RemoveHoverLight(HoverLight light)
 {
     activeHoverLights.Remove(light);
 }