Пример #1
0
        private void AddHoverLight(HoverLight light)
        {
            if (activeHoverLights.Count >= hoverLightCount)
            {
                Debug.LogWarningFormat("Max hover light count ({0}) exceeded.", hoverLightCount);
            }

            activeHoverLights.Add(light);
        }
Пример #2
0
        private void UpdateHoverLights(bool forceUpdate = false)
        {
            if (lastHoverLightUpdate == -1)
            {
                Initialize();
            }

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

            Shader.EnableKeyword(multiHoverLightKeyword);

            /*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,
                                                            1.0f);
                    hoverLightData[dataIndex + 1] = new Vector4(light.Color.r,
                                                                light.Color.g,
                                                                light.Color.b,
                                                                1.0f / Mathf.Clamp(light.Radius, 0.001f, 1.0f));
                }
                else
                {
                    hoverLightData[dataIndex] = Vector4.zero;
                }
            }

            Shader.SetGlobalVectorArray(_HoverLightDataID, hoverLightData);

            lastHoverLightUpdate = Time.frameCount;
        }
Пример #3
0
 private void RemoveHoverLight(HoverLight light)
 {
     activeHoverLights.Remove(light);
 }