Esempio n. 1
0
    void Update()
    {
        // Grab the SkyProfile from the current TimeOfDayController in your scene.
        SkyProfile profile = TimeOfDayController.instance.skyProfile;

        // Get the "group" that manages all the animation keyframes for the property you want to modify.
        // This method is templated since there are a few different types of keyframes supported. You
        // can also fetch groups using these group class types:
        //      GetGroup<NumberKeyframeGroup>(...)
        //      GetGroup<TextureKeyframeGroup>(...)
        //      GetGroup<BoolKeyframeGroup>(...)
        //      GetGroup<SpherePointKeyframeGroup>(...) // Used to position sun and moon with spherical coordinates
        ColorKeyframeGroup group = profile.GetGroup <ColorKeyframeGroup>(ProfilePropertyKeys.SkyMiddleColorKey);

        // A group contains an array of keyframs. If you're not using the Sky Timeline, just grab the first keyframe (there is always at least 1).
        ColorKeyframe keyframe = group.keyframes[0];

        // You can modify the keyframe at runtime by accessing it's properties.
        float rollingHue = (Time.timeSinceLevelLoad * speed) % 1.0f;

        keyframe.color = Color.HSVToRGB(rollingHue, .8f, .8f);

        // You can do this all in 1 line if you like, let's update the upper sky to match now.
        profile.GetGroup <ColorKeyframeGroup>(ProfilePropertyKeys.SkyUpperColorKey).keyframes[0].color = keyframe.color;

        // After you modify a SkyProfile, you'll need to update the sky so it refreshes (unless you have automatic time increment enabled).
        TimeOfDayController.instance.UpdateSkyForCurrentTime();
    }
Esempio n. 2
0
 public void RemoveColorKeyframe(ColorKeyframe keyframe)
 {
     Track.DeleteMarker(keyframe);
     UpdateView();
     UpdateProperties();
     TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
 }
Esempio n. 3
0
    private static Tuple <List <ColorKeyframe>, List <Waypoint> > ProcessKeyframes(SequenceTrack track, IEnumerable <IMarker> markers)
    {
        List <ColorKeyframe> colorKeyframes = new List <ColorKeyframe>();
        List <Waypoint>      waypoints      = new List <Waypoint>();

        List <IMarker> sortedMarkers = new List <IMarker>(markers);

        sortedMarkers.Sort(KeyframeUtil.KeyframeComparator);

        foreach (IMarker marker in sortedMarkers)
        {
            if (marker is ColorKeyframe)
            {
                colorKeyframes.Add(marker as ColorKeyframe);
                track.Length = Mathf.Max(track.Length, (float)marker.time);
            }

            if (marker is Waypoint)
            {
                waypoints.Add(marker as Waypoint);
                track.Length = Mathf.Max(track.Length, (float)marker.time);
            }
        }

        colorKeyframes.Sort(KeyframeUtil.KeyframeComparator);
        waypoints.Sort(KeyframeUtil.KeyframeComparator);

        if (waypoints.Count > 0 && waypoints[0].time > 0.0f)
        {
            Waypoint fakeWaypoint = ScriptableObject.CreateInstance <Waypoint>();
            fakeWaypoint.Position  = waypoints[0].Position;
            fakeWaypoint.JointType = JointType.Linear;
            fakeWaypoint.time      = 0.0;
            waypoints.Insert(0, fakeWaypoint);
        }

        if (colorKeyframes.Count > 0 && colorKeyframes[0].time > 0.0f)
        {
            ColorKeyframe fakeKeyframe = ScriptableObject.CreateInstance <ColorKeyframe>();
            fakeKeyframe.LightColor = colorKeyframes[0].LightColor;
            fakeKeyframe.time       = 0.0;
            colorKeyframes.Insert(0, fakeKeyframe);
        }

        int lastIndex = colorKeyframes.Count - 1;

        if (colorKeyframes.Count > 0 && colorKeyframes[lastIndex].time < track.Length)
        {
            ColorKeyframe lastKeyframe = ScriptableObject.CreateInstance <ColorKeyframe>();
            lastKeyframe.LightColor = colorKeyframes[lastIndex].LightColor;
            lastKeyframe.time       = track.Length;
            colorKeyframes.Add(lastKeyframe);
        }

        return(new Tuple <List <ColorKeyframe>, List <Waypoint> >(colorKeyframes, waypoints));
    }
Esempio n. 4
0
    private static void ProcessStart(List <byte> bytes, List <ColorKeyframe> keyframes)
    {
        if (keyframes.Count == 0)
        {
            return;
        }

        ColorKeyframe firstKeyframe = keyframes[0];

        AddTiming(bytes, 0.01f, firstKeyframe.LightColor);
    }
Esempio n. 5
0
            public static ColorKeyframe Read(BinaryReader br)
            {
                ColorKeyframe ret = new ColorKeyframe();

                ret.Keyframe      = BaseKeyframeData.Read(br);
                ret.MultiplyRed   = br.ReadInt16();
                ret.MultiplyGreen = br.ReadInt16();
                ret.MultiplyBlue  = br.ReadInt16();
                ret.AddRed        = br.ReadInt16();
                ret.AddGreen      = br.ReadInt16();
                ret.AddBlue       = br.ReadInt16();
                return(ret);
            }
Esempio n. 6
0
    public void UpdateProperties()
    {
        this.Time = (float)TimelineUtilities.Director.time;

        this.ColorKeyframes = Track.GetMarkers()
                              .Where(item => item is ColorKeyframe)
                              .Select((item, index) =>
        {
            ColorKeyframe keyframe = item as ColorKeyframe;
            keyframe.MarkerIndex   = index;
            return(keyframe);
        }).ToList();

        this.ColorKeyframes.Sort(KeyframeUtil.KeyframeComparator);

        this.Waypoints = Track.GetMarkers().Where(item => item is Waypoint).Select(item => item as Waypoint).ToList();
        this.Waypoints.Sort(KeyframeUtil.KeyframeComparator);
    }
Esempio n. 7
0
    public void SetColorKeyframe(Color lightColor, float time)
    {
        List <ColorKeyframe> keyframes = this.ColorKeyframes;

        if (keyframes == null)
        {
            return;
        }

        ColorKeyframe keyframe = GetKeyframe(keyframes, time) as ColorKeyframe;

        if (keyframe == null)
        {
            keyframe = Track.CreateMarker <ColorKeyframe>(time);
            TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
            UpdateProperties();
        }

        keyframe.LightColor = lightColor;
        UpdateView();
    }
Esempio n. 8
0
    private static void ProcessKeyframe(List <byte> bytes, ColorKeyframe current, ColorKeyframe next)
    {
        float duration = (float)(next.time - current.time);

        AddTiming(bytes, duration, next.LightColor);
    }