public Color GetColorPropertyValue(string propertyKey, float timeOfDay)
        {
            ColorKeyframeGroup group = GetGroup <ColorKeyframeGroup>(propertyKey);

            if (group == null)
            {
                Debug.LogError("Can't find color group with property key: " + propertyKey);
                return(Color.white);
            }

            return(group.ColorForTime(timeOfDay));
        }
Beispiel #2
0
        private static List <Vector4> FormatColorGradientForShader(ColorKeyframeGroup group)
        {
            List <Vector4> colors = new List <Vector4>(group.keyframes.Count);

            if (group.keyframes.Count == 0)
            {
                return(colors);
            }

            // Start at zero if no keyframe.
            List <float> majorTimePoints = new List <float>();

            if (group.keyframes[0].time > .00001f)
            {
                majorTimePoints.Add(0);
            }

            foreach (ColorKeyframe keyframe in group.keyframes)
            {
                majorTimePoints.Add(keyframe.time);
            }

            // End at 1 if no keyframe
            if (group.keyframes[group.keyframes.Count - 1].time < .99999f)
            {
                majorTimePoints.Add(1.0f);
            }

            for (int i = 0; i < (majorTimePoints.Count - 1); i++)
            {
                float currentTime = majorTimePoints[i];
                float nextTime    = majorTimePoints[i + 1];

                float timeStep = (nextTime - currentTime) / k_LineSmoothing;
                for (int j = 0; j <= k_LineSmoothing; j++)
                {
                    float time      = currentTime + (j * timeStep);
                    Color timeColor = group.ColorForTime(time);

                    colors.Add(new Vector4(time, timeColor.r, timeColor.g, timeColor.b));
                }
            }

            return(colors);
        }