Esempio n. 1
0
    public virtual void Draw(DirectorControlState state)
    {
        Behaviour behaviour = this.wrapper.Behaviour;

        if (behaviour != null)
        {
            Color ocolor = Color.white;
            if (base.IsSelected)
            {
                GUI.color = (new Color(0.5f, 0.6f, 0.905f, 1f));
            }
            else
            {
                ocolor = GUI.color;
            }
            Rect controlPosition = this.controlPosition;
            controlPosition.height = (17f);
            GUI.Box(controlPosition, GUIContent.none, TimelineTrackControl.styles.EventItemStyle);
            if (this.trackControl.isExpanded)
            {
                float introduced4 = this.controlPosition.width;
                GUI.Box(new Rect(this.controlPosition.x, controlPosition.yMax, introduced4, this.controlPosition.height - controlPosition.height), GUIContent.none, TimelineTrackControl.styles.EventItemBottomStyle);
            }
            GUI.color = ocolor;
            Rect   labelPosition = new Rect(this.controlPosition.x + 16f, this.controlPosition.y, 128f, this.controlPosition.height);
            string name          = behaviour.name;
            this.DrawRenameLabel(name, labelPosition, null);
        }
    }
    public override void Draw(DirectorControlState state)
    {
        CinemaAudio audioItem = Wrapper.Behaviour as CinemaAudio;
        if (audioItem == null) return;
        AudioSource audioSource = audioItem.GetComponent<AudioSource>();
        
        if (Selection.activeGameObject == audioItem.gameObject)
        {
            GUI.Box(controlPosition, string.Empty, TimelineTrackControl.styles.AudioTrackItemSelectedStyle);
        }
        else
        {
            GUI.Box(controlPosition, string.Empty, TimelineTrackControl.styles.AudioTrackItemStyle);
        }

        if (audioSource != null && audioSource.clip != null)
        {
            GUILayout.BeginArea(controlPosition);
            if (texture == null || audioItemName != audioSource.clip.name)
            {
                audioItemName = audioSource.clip.name;
                texture = AssetPreview.GetAssetPreview(audioSource.clip);
            }

            float inTimeOffset = (audioItem.InTime) * state.Scale.x;
            float outTimeOffset = (audioItem.ItemLength - audioItem.OutTime) * state.Scale.x;
            Rect texturePosition = new Rect(-inTimeOffset + 2, 0, controlPosition.width - 4 + inTimeOffset + outTimeOffset, controlPosition.height);

            if (texture != null)
            {
                GUI.DrawTexture(texturePosition, texture, ScaleMode.StretchToFill);
            }
            GUILayout.EndArea();
        }
    }
    public override void ResizeControlPosition(DirectorControlState state, Rect trackPosition)
    {
        CinemaActionWrapper wrapper = base.Wrapper as CinemaActionWrapper;

        if (wrapper == null)
        {
            return;
        }
        if (base.isRenaming)
        {
            return;
        }
        float num  = (wrapper.Firetime * state.Scale.x) + state.Translation.x;
        float num2 = ((wrapper.Firetime + wrapper.Duration) * state.Scale.x) + state.Translation.x;

        this.controlPosition = new Rect(num, 0f, num2 - num, trackPosition.height);
        SkillParticleActionItem action = Wrapper.Behaviour as SkillParticleActionItem;

        if (action == null)
        {
            return;
        }
        if (ParentEmitter != null)
        {
            int level = ParentEmitter.GetLevel();
            controlPosition = new Rect(controlPosition.x, trackPosition.height - trackPosition.height / level, controlPosition.width, trackPosition.height / level);
        }
    }
Esempio n. 4
0
    public virtual void Draw(DirectorControlState state)
    {
        Behaviour behaviour = this.wrapper.Behaviour;

        if (behaviour == null)
        {
            return;
        }
        Color arg_BF_0 = GUI.color;

        if (base.IsSelected)
        {
            GUI.color = (new Color(0.5f, 0.6f, 0.905f, 1f));
        }
        Rect rect = this.controlPosition;

        rect.height = (17f);
        GUI.Box(rect, GUIContent.none, TimelineTrackControl.styles.EventItemStyle);
        if (this.trackControl.isExpanded)
        {
            GUI.Box(new Rect(this.controlPosition.x, rect.yMax, this.controlPosition.width, this.controlPosition.height - rect.height), GUIContent.none, TimelineTrackControl.styles.EventItemBottomStyle);
        }
        GUI.color = (arg_BF_0);
        Rect   labelPosition = new Rect(this.controlPosition.x + 16f, this.controlPosition.y, 128f, this.controlPosition.height);
        string name          = behaviour.name;

        this.DrawRenameLabel(name, labelPosition, null);
    }
    public override void PostUpdate(DirectorControlState state, bool inArea, EventType type)
    {
        CinemaActorClipCurve clipCurve = Wrapper.Behaviour as CinemaActorClipCurve;

        if (clipCurve == null)
        {
            return;
        }

        hasUndoRedoBeenPerformed = (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed");
        if ((HaveCurvesChanged || hasUndoRedoBeenPerformed) && state.IsInPreviewMode)
        {
            clipCurve.SampleTime(state.ScrubberPosition);
            HaveCurvesChanged = false;
            hasUserInteracted = false;
        }
        else
        {
            if (state.IsInPreviewMode && IsEditing && GUIUtility.hotControl == 0 && (clipCurve.Firetime <= state.ScrubberPosition && state.ScrubberPosition <= clipCurve.Firetime + clipCurve.Duration) && clipCurve.Actor != null)
            {
                inArea = !(Event.current.shift && Event.current.keyCode == KeyCode.F && Event.current.control);
                checkToAddNewKeyframes(clipCurve, state, EditorWindow.focusedWindow == DirectorWindow.Instance && inArea);
            }
        }
    }
Esempio n. 6
0
    protected virtual void UpdateTracks(DirectorControlState state, Rect header, Rect content, Rect controlArea)
    {
        SortedDictionary <int, TimelineTrackWrapper> sortedDictionary = new SortedDictionary <int, TimelineTrackWrapper>();

        foreach (TimelineTrackWrapper current in timelineTrackMap.Keys)
        {
            timelineTrackMap[current].TargetTrack = current;
            sortedDictionary.Add(current.Ordinal, current);
        }
        float num = header.y + 17f;

        foreach (int current2 in sortedDictionary.Keys)
        {
            TimelineTrackWrapper timelineTrackWrapper = sortedDictionary[current2];
            TimelineTrackControl timelineTrackControl = timelineTrackMap[timelineTrackWrapper];
            timelineTrackControl.Ordinal = new []
            {
                trackGroup.Ordinal,
                current2
            };
            float height           = timelineTrackControl.Rect.height;
            Rect  rect             = new Rect(content.x, num, content.width, height);
            Rect  headerBackground = new Rect(header.x, num, header.width, height);
            Rect  rect2            = new Rect(header.x, num, header.width - sortingOptionsWidth - 4f, height);
            Rect  rect3            = new Rect(rect2.x + rect2.width, num, sortingOptionsWidth / 2f, 16f);
            Rect  arg_225_0        = new Rect(rect3.x + sortingOptionsWidth / 2f, num, sortingOptionsWidth / 2f, 16f);
            timelineTrackControl.UpdateTrackBodyBackground(rect);
            timelineTrackControl.UpdateHeaderBackground(headerBackground, current2);
            GUILayout.BeginArea(rect);
            timelineTrackControl.UpdateTrackContents(state, rect, controlArea);
            GUILayout.EndArea();
            timelineTrackControl.UpdateHeaderContents(state, rect2, headerBackground);
            GUI.enabled = (current2 > 0);
            if (GUI.Button(rect3, string.Empty, DirectorControl.DirectorControlStyles.UpArrowIcon))
            {
                TimelineTrackWrapper expr_1CE = timelineTrackWrapper;
                int ordinal = expr_1CE.Ordinal;
                expr_1CE.Ordinal = ordinal - 1;
                TimelineTrackWrapper expr_1F9 = timelineTrackMap[sortedDictionary[current2 - 1]].TargetTrack;
                ordinal          = expr_1F9.Ordinal;
                expr_1F9.Ordinal = ordinal + 1;
            }
            GUI.enabled = (current2 < sortedDictionary.Count - 1);
            if (GUI.Button(arg_225_0, string.Empty, DirectorControl.DirectorControlStyles.DownArrowIcon))
            {
                TimelineTrackWrapper expr_22E = timelineTrackWrapper;
                int ordinal = expr_22E.Ordinal;
                expr_22E.Ordinal = ordinal + 1;
                TimelineTrackWrapper expr_259 = timelineTrackMap[sortedDictionary[current2 + 1]].TargetTrack;
                ordinal          = expr_259.Ordinal;
                expr_259.Ordinal = ordinal - 1;
            }
            GUI.enabled = (true);
            num        += height;
        }
    }
Esempio n. 7
0
    public override void Draw(DirectorControlState state)
    {
        CinemaShot shot = Wrapper.Behaviour as CinemaShot;

        if (shot == null)
        {
            return;
        }

        if (Selection.Contains(shot.gameObject))
        {
            GUI.Box(controlPosition, GUIContent.none, TimelineTrackControl.styles.ShotTrackItemSelectedStyle);
        }
        else
        {
            GUI.Box(controlPosition, GUIContent.none, TimelineTrackControl.styles.ShotTrackItemStyle);
        }


        // Draw Icon
        Color temp = GUI.color;

        GUI.color = (shot.shotCamera != null) ? new Color(0.19f, 0.76f, 0.84f) : Color.red;
        Rect icon = controlPosition;

        icon.x     += 4;
        icon.width  = 16;
        icon.height = 16;
        //GUI.DrawTexture(icon, shotIcon, ScaleMode.ScaleToFit, true, 0);
        GUI.Box(icon, actionIcon, GUIStyle.none);
        GUI.color = temp;

        Rect labelPosition = controlPosition;

        labelPosition.x      = icon.xMax;
        labelPosition.width -= (icon.width + 4);

        if (TrackControl.isExpanded)
        {
            labelPosition.height = TimelineTrackControl.ROW_HEIGHT;

            if (shot.shotCamera != null)
            {
                Rect extraInfo = labelPosition;
                extraInfo.y += TimelineTrackControl.ROW_HEIGHT;
                GUI.Label(extraInfo, string.Format("Camera: {0}", shot.shotCamera.name));
            }
        }
        DrawRenameLabel(shot.name, labelPosition);
    }
Esempio n. 8
0
    protected virtual void UpdateTracks(DirectorControlState state, Rect header, Rect content)
    {
        SortedDictionary <int, TimelineTrackWrapper> dictionary = new SortedDictionary <int, TimelineTrackWrapper>();

        foreach (TimelineTrackWrapper wrapper in this.timelineTrackMap.Keys)
        {
            this.timelineTrackMap[wrapper].TargetTrack = wrapper;
            dictionary.Add(wrapper.Ordinal, wrapper);
        }
        float num = header.y + 17f;

        foreach (int num2 in dictionary.Keys)
        {
            TimelineTrackWrapper wrapper2 = dictionary[num2];
            TimelineTrackControl control  = this.timelineTrackMap[wrapper2];
            control.Ordinal = new int[] { this.trackGroup.Ordinal, num2 };
            float num3         = control.Rect.height;
            Rect  position     = new Rect(content.x, num, content.width, num3);
            Rect  rect2        = new Rect(header.x, num, header.width, num3);
            Rect  rect3        = new Rect(header.x, num, (header.width - this.sortingOptionsWidth) - 4f, num3);
            float introduced17 = rect3.x;
            Rect  rect4        = new Rect(introduced17 + rect3.width, num, this.sortingOptionsWidth / 2f, 16f);
            control.UpdateTrackBodyBackground(position);
            control.UpdateHeaderBackground(rect2, num2);
            GUILayout.BeginArea(position);
            Rect rect5 = position;
            control.UpdateTrackContents(state, rect5);
            GUILayout.EndArea();
            control.UpdateHeaderContents(state, rect3, rect2);
            GUI.enabled = (num2 > 0);
            if (GUI.Button(rect4, string.Empty, DirectorControl.DirectorControlStyles.UpArrowIcon))
            {
                wrapper2.Ordinal--;
                TimelineTrackWrapper targetTrack = this.timelineTrackMap[dictionary[num2 - 1]].TargetTrack;
                targetTrack.Ordinal++;
            }
            GUI.enabled = (num2 < (dictionary.Count - 1));
            if (GUI.Button(new Rect(rect4.x + (this.sortingOptionsWidth / 2f), num, this.sortingOptionsWidth / 2f, 16f), string.Empty, DirectorControl.DirectorControlStyles.DownArrowIcon))
            {
                wrapper2.Ordinal++;
                TimelineTrackWrapper wrapper3 = this.timelineTrackMap[dictionary[num2 + 1]].TargetTrack;
                wrapper3.Ordinal--;
            }
            GUI.enabled = (true);
            num        += num3;
        }
    }
Esempio n. 9
0
    public virtual void ResizeControlPosition(DirectorControlState state, Rect trackPosition)
    {
        CinemaActionWrapper wrapper = base.Wrapper as CinemaActionWrapper;

        if (wrapper == null)
        {
            return;
        }
        if (base.isRenaming)
        {
            return;
        }
        float num  = (wrapper.Firetime * state.Scale.x) + state.Translation.x;
        float num2 = ((wrapper.Firetime + wrapper.Duration) * state.Scale.x) + state.Translation.x;

        this.controlPosition = new Rect(num, 0f, num2 - num, trackPosition.height);
    }
Esempio n. 10
0
 public virtual void Update(TrackGroupWrapper trackGroup, DirectorControlState state, Rect position, Rect fullHeader, Rect safeHeader, Rect content)
 {
     this.position   = position;
     this.trackGroup = trackGroup;
     this.state      = state;
     if (trackGroup.Behaviour != null)
     {
         this.updateHeaderBackground(fullHeader);
         this.updateContentBackground(content);
         if (base.isExpanded)
         {
             Rect header = new Rect(safeHeader.x, safeHeader.y, fullHeader.width, safeHeader.height);
             this.UpdateTracks(state, header, content);
         }
         this.updateHeaderContent(safeHeader);
     }
 }
    public override void PostUpdate(DirectorControlState state)
    {
        CinemaActorClipCurve clipCurve = Wrapper.Behaviour as CinemaActorClipCurve;
        if (clipCurve == null) return;

        hasUndoRedoBeenPerformed = (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed");
        if ((HaveCurvesChanged || hasUndoRedoBeenPerformed) && state.IsInPreviewMode)
        {
            clipCurve.SampleTime(state.ScrubberPosition);
            HaveCurvesChanged = false;
            hasUserInteracted = false;
        }
        else
        {
            checkToAddNewKeyframes(clipCurve, state);
        }
    }
Esempio n. 12
0
    public override void ResizeControlPosition(DirectorControlState state, Rect trackPosition)
    {
        CinemaActionWrapper wrapper = base.Wrapper as CinemaActionWrapper;

        if (wrapper == null)
        {
            return;
        }
        if (base.isRenaming)
        {
            return;
        }
        SkillParticleEmitterItem action = Wrapper.Behaviour as SkillParticleEmitterItem;
        float num  = (wrapper.Firetime * state.Scale.x) + state.Translation.x;
        float num2 = ((wrapper.Firetime + wrapper.Duration) * state.Scale.x) + state.Translation.x;

        this.controlPosition = new Rect(num, 0f, num2 - num, trackPosition.height / action.GetLevel());
    }
    public override void Draw(DirectorControlState state)
    {
        CinemaShot shot = Wrapper.Behaviour as CinemaShot;
        if (shot == null) return;

        Color temp = GUI.color;

        GUI.color = (shot.shotCamera != null) ? GUI.color : Color.red;
        if (Selection.activeGameObject == shot.gameObject)
        {
            GUI.Box(controlPosition, new GUIContent(shot.name), TimelineTrackControl.styles.ShotTrackItemSelectedStyle);
        }
        else
        {
            GUI.Box(controlPosition, new GUIContent(shot.name), TimelineTrackControl.styles.ShotTrackItemStyle);
        }
        GUI.color = temp;
    }
    public override void Draw(DirectorControlState state)
    {
        SkillParticleActionItem action = Wrapper.Behaviour as SkillParticleActionItem;

        if (action == null)
        {
            return;
        }
        if (IsSelected)
        {
            GUI.Box(controlPosition, GUIContent.none, TimelineTrackControl.styles.ActorTrackItemSelectedStyle);
        }
        else
        {
            GUI.Box(controlPosition, GUIContent.none, TimelineTrackControl.styles.ActorTrackItemStyle);
        }

        DrawRenameLabel(action.name, controlPosition);
    }
Esempio n. 15
0
    public override void Draw(DirectorControlState state)
    {
        if (base.Wrapper.Behaviour == null)
        {
            return;
        }
        string text = base.Behaviour.name;

        if (this.isRenaming)
        {
            GUI.Box(this.controlPosition, GUIContent.none, TimelineTrackControl.styles.TrackItemSelectedStyle);
            GUI.SetNextControlName("TrackItemControlRename");
            text = EditorGUI.TextField(this.controlPosition, GUIContent.none, text);
            if (this.renameRequested)
            {
                EditorGUI.FocusTextInControl("TrackItemControlRename");
                this.renameRequested = false;
            }
            if (!base.IsSelected || Event.current.keyCode == (KeyCode)13 || ((Event.current.type == EventType.MouseDown || Event.current.type == (EventType)11) && !this.controlPosition.Contains(Event.current.mousePosition)))
            {
                this.isRenaming            = false;
                GUIUtility.hotControl      = (0);
                GUIUtility.keyboardControl = (0);
                int drawPriority = base.DrawPriority;
                base.DrawPriority = drawPriority - 1;
            }
        }
        if (base.Behaviour.name != text)
        {
            Undo.RecordObject(base.Behaviour.gameObject, string.Format("Renamed {0}", base.Behaviour.name));
            base.Behaviour.name = (text);
        }
        if (!this.isRenaming)
        {
            if (base.IsSelected)
            {
                GUI.Box(this.controlPosition, new GUIContent(text), TimelineTrackControl.styles.TrackItemSelectedStyle);
                return;
            }
            GUI.Box(this.controlPosition, new GUIContent(text), TimelineTrackControl.styles.TrackItemStyle);
        }
    }
Esempio n. 16
0
    public void OnDestroy(TrackGroupWrapper trackGroup, DirectorControlState state)
    {
        SortedDictionary <int, TimelineTrackWrapper> sortedDictionary = new SortedDictionary <int, TimelineTrackWrapper>();

        foreach (TimelineTrackWrapper current in timelineTrackMap.Keys)
        {
            timelineTrackMap[current].TargetTrack = current;
            sortedDictionary.Add(current.Ordinal, current);
        }
        foreach (int current2 in sortedDictionary.Keys)
        {
            TimelineTrackWrapper timelineTrackWrapper = sortedDictionary[current2];
            TimelineTrackControl timelineTrackControl = timelineTrackMap[timelineTrackWrapper];
            timelineTrackControl.Ordinal = new[]
            {
                trackGroup.Ordinal,
                current2
            };
        }
    }
Esempio n. 17
0
    public override void PostUpdate(DirectorControlState state)
    {
        ActorClipCurve clipCurve = Wrapper.Behaviour as ActorClipCurve;

        if (clipCurve == null)
        {
            return;
        }

        hasUndoRedoBeenPerformed = (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed");
        if ((HaveCurvesChanged || hasUndoRedoBeenPerformed) && state.IsInPreviewMode)
        {
            clipCurve.SampleTime(state.ScrubberPosition);
            HaveCurvesChanged = false;
            hasUserInteracted = false;
        }
        else
        {
            checkToAddNewKeyframes(clipCurve, state);
        }
    }
Esempio n. 18
0
    public virtual void UpdateTrackContents(DirectorControlState state, Rect position, Rect headerBackground)
    {
        this.state = state;
        trackArea  = position;
        List <KeyValuePair <int, TimelineItemWrapper> > list = new List <KeyValuePair <int, TimelineItemWrapper> >();

        foreach (TimelineItemWrapper current in itemMap.Keys)
        {
            TrackItemControl trackItemControl = itemMap[current];
            trackItemControl.Wrapper = current;
            trackItemControl.Track   = TargetTrack;
            trackItemControl.PreUpdate(state, position);
            KeyValuePair <int, TimelineItemWrapper> item = new KeyValuePair <int, TimelineItemWrapper>(trackItemControl.DrawPriority, current);
            list.Add(item);
        }
        list.Sort(Comparison);
        foreach (KeyValuePair <int, TimelineItemWrapper> current2 in list)
        {
            itemMap[current2.Value].HandleInput(state, position);
        }
        list.Reverse();
        Rect      rect           = new Rect(0f, 0f, position.width, position.height);
        int       controlID      = GUIUtility.GetControlID(TargetTrack.Behaviour.GetInstanceID(), FocusType.Passive, rect);
        EventType typeForControl = Event.current.GetTypeForControl(controlID);

        headerBackground.height += 100;
        bool mark = headerBackground.Contains(Event.current.mousePosition);

        foreach (KeyValuePair <int, TimelineItemWrapper> current3 in list)
        {
            TrackItemControl expr_111 = itemMap[current3.Value];
            expr_111.Draw(state);
            expr_111.PostUpdate(state, mark, typeForControl);
        }
        if (typeForControl == EventType.MouseDown && rect.Contains(Event.current.mousePosition) && Event.current.button == 1 && !Event.current.alt && !Event.current.shift && !Event.current.control)
        {
            showBodyContextMenu(Event.current);
            Event.current.Use();
        }
    }
    public override void Draw(DirectorControlState state)
    {
        CinemaAudio audioItem = Wrapper.Behaviour as CinemaAudio;

        if (audioItem == null)
        {
            return;
        }


        if (Selection.activeGameObject == audioItem.gameObject)
        {
            GUI.Box(controlPosition, string.Empty, TimelineTrackControl.styles.AudioTrackItemSelectedStyle);
        }
        else
        {
            GUI.Box(controlPosition, string.Empty, TimelineTrackControl.styles.AudioTrackItemStyle);
        }

        if (audioItem.audio != null && audioItem.audio.clip != null)
        {
            GUILayout.BeginArea(controlPosition);
            if (audioItemName != audioItem.audio.clip.name)
            {
                audioItemName = audioItem.audio.clip.name;
                texture       = AssetPreview.GetAssetPreview(audioItem.audio.clip);
            }

            float inTimeOffset    = (audioItem.InTime) * state.Scale.x;
            float outTimeOffset   = (audioItem.ItemLength - audioItem.OutTime) * state.Scale.x;
            Rect  texturePosition = new Rect(-inTimeOffset + 2, 0, controlPosition.width - 4 + inTimeOffset + outTimeOffset, controlPosition.height);

            if (texture != null)
            {
                GUI.DrawTexture(texturePosition, texture, ScaleMode.StretchToFill);
            }
            GUILayout.EndArea();
        }
    }
    public override void Draw(DirectorControlState state)
    {
        CinemaShot shot = Wrapper.Behaviour as CinemaShot;

        if (shot == null)
        {
            return;
        }

        Color temp = GUI.color;

        GUI.color = (shot.shotCamera != null) ? GUI.color : Color.red;
        if (Selection.activeGameObject == shot.gameObject)
        {
            GUI.Box(controlPosition, new GUIContent(shot.name), TimelineTrackControl.styles.ShotTrackItemSelectedStyle);
        }
        else
        {
            GUI.Box(controlPosition, new GUIContent(shot.name), TimelineTrackControl.styles.ShotTrackItemStyle);
        }
        GUI.color = temp;
    }
Esempio n. 21
0
    public virtual void UpdateTrackContents(DirectorControlState state, UnityEngine.Rect position)
    {
        this.state     = state;
        this.trackArea = position;
        List <KeyValuePair <int, TimelineItemWrapper> > list = new List <KeyValuePair <int, TimelineItemWrapper> >();

        foreach (TimelineItemWrapper wrapper in this.itemMap.Keys)
        {
            TrackItemControl control = this.itemMap[wrapper];
            control.Wrapper = wrapper;
            control.Track   = this.TargetTrack;
            control.PreUpdate(state, position);
            KeyValuePair <int, TimelineItemWrapper> item = new KeyValuePair <int, TimelineItemWrapper>(control.DrawPriority, wrapper);
            list.Add(item);
        }
        list.Sort(new Comparison <KeyValuePair <int, TimelineItemWrapper> >(TimelineTrackControl.Comparison));
        foreach (KeyValuePair <int, TimelineItemWrapper> pair2 in list)
        {
            this.itemMap[pair2.Value].HandleInput(state, position);
        }
        list.Reverse();
        foreach (KeyValuePair <int, TimelineItemWrapper> pair3 in list)
        {
            TrackItemControl local1 = this.itemMap[pair3.Value];
            local1.Draw(state);
            local1.PostUpdate(state);
        }
        UnityEngine.Rect rect = new UnityEngine.Rect(0f, 0f, position.width, position.height);
        int num = GUIUtility.GetControlID(this.TargetTrack.Behaviour.GetInstanceID(), (FocusType)2, rect);

        if ((((Event.current.GetTypeForControl(num) == EventType.MouseUp) && rect.Contains(Event.current.mousePosition)) && ((Event.current.button == 1) && !Event.current.alt)) && (!Event.current.shift && !Event.current.control))
        {
            this.showBodyContextMenu(Event.current);
            Event.current.Use();
        }
    }
    private void checkToAddNewKeyframes(CinemaActorClipCurve clipCurve, DirectorControlState state)
    {
        if (state.IsInPreviewMode && IsEditing && GUIUtility.hotControl == 0 && 
            (clipCurve.Firetime <= state.ScrubberPosition && 
            state.ScrubberPosition <= clipCurve.Firetime + clipCurve.Duration) && clipCurve.Actor != null)
        {
            Undo.RecordObject(clipCurve, "Auto Key Created");
            bool hasDifferenceBeenFound = false;
            foreach (MemberClipCurveData data in clipCurve.CurveData)
            {
                if (data.Type == string.Empty || data.PropertyName == string.Empty) continue;

                Component component = clipCurve.Actor.GetComponent(data.Type);
                object value = clipCurve.GetCurrentValue(component, data.PropertyName, data.IsProperty);

                PropertyTypeInfo typeInfo = data.PropertyType;
                if (typeInfo == PropertyTypeInfo.Int || typeInfo == PropertyTypeInfo.Long || typeInfo == PropertyTypeInfo.Float ||
                typeInfo == PropertyTypeInfo.Double)
                {
                    float x = (float)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(x, curve1Value, data.Curve1, state.ScrubberPosition);

                }
                else if (typeInfo == PropertyTypeInfo.Vector2)
                {
                    Vector2 vec2 = (Vector2)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.y, curve2Value, data.Curve2, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector3)
                {
                    Vector3 vec3 = (Vector3)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.y, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.z, curve3Value, data.Curve3, state.ScrubberPosition);
                    
                }
                else if (typeInfo == PropertyTypeInfo.Vector4)
                {
                    Vector4 vec4 = (Vector4)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.y, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.z, curve3Value, data.Curve3, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.w, curve4Value, data.Curve4, state.ScrubberPosition);

                }
                else if (typeInfo == PropertyTypeInfo.Quaternion)
                {
                    Quaternion quaternion = (Quaternion)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    for (int j = 0; j < data.Curve1.length; j++)
                    {
                        Keyframe k = data.Curve1[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.x, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve1, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve2.length; j++)
                    {
                        Keyframe k = data.Curve2[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.y, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve2, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve3.length; j++)
                    {
                        Keyframe k = data.Curve3[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.z, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve3, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve4.length; j++)
                    {
                        Keyframe k = data.Curve4[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.w, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve4, j, newKeyframe);
                        }
                    }

                    Quaternion curveValue = new Quaternion(curve1Value, curve2Value, curve3Value, curve4Value);
                    float angle = Vector3.Angle(quaternion.eulerAngles, curveValue.eulerAngles);
                    hasDifferenceBeenFound = hasDifferenceBeenFound || angle > QUATERNION_THRESHOLD;
                    if (angle > QUATERNION_THRESHOLD && hasUserInteracted)
                    {
                        data.Curve1.AddKey(state.ScrubberPosition, quaternion.x);
                        data.Curve2.AddKey(state.ScrubberPosition, quaternion.y);
                        data.Curve3.AddKey(state.ScrubberPosition, quaternion.z);
                        data.Curve4.AddKey(state.ScrubberPosition, quaternion.w);
                        hasUserInteracted = true;
                    }
                }
                else if (typeInfo == PropertyTypeInfo.Color)
                {
                    Color color = (Color)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.r, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.g, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.b, curve3Value, data.Curve3, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.a, curve4Value, data.Curve4, state.ScrubberPosition);
                }
            }
            if (hasDifferenceBeenFound)
            {
                hasUserInteracted = true;
                EditorUtility.SetDirty(clipCurve);
            }
        }
    }
    public override void Draw(DirectorControlState state)
    {
        CinemaAudioFragment audioItem = Wrapper.Behaviour as CinemaAudioFragment;

        if (audioItem == null)
        {
            return;
        }
        AudioSource audioSource = audioItem.GetComponent <AudioSource>();

        if (!TrackControl.isExpanded)
        {
            if (Selection.Contains(audioItem.gameObject))
            {
                GUI.Box(controlPosition, string.Empty, TimelineTrackControl.styles.AudioTrackItemSelectedStyle);
            }
            else
            {
                GUI.Box(controlPosition, string.Empty, TimelineTrackControl.styles.AudioTrackItemStyle);
            }
            Color temp = GUI.color;
            GUI.color = new Color(1f, 0.65f, 0f);
            Rect icon = controlPosition;
            icon.x     += 4;
            icon.width  = 16;
            icon.height = 16;
            GUI.Box(icon, actionIcon, GUIStyle.none);
            GUI.color = temp;

            Rect labelPosition = controlPosition;
            labelPosition.x      = icon.xMax;
            labelPosition.width -= (icon.width + 4);


            DrawRenameLabel(audioItem.name, labelPosition);
        }
        else
        {
            if (Selection.Contains(audioItem.gameObject))
            {
                GUI.Box(controlPosition, string.Empty, TimelineTrackControl.styles.TrackItemSelectedStyle);
            }
            else
            {
                GUI.Box(controlPosition, string.Empty, TimelineTrackControl.styles.TrackItemStyle);
            }
            if (audioSource != null && audioSource.clip != null)
            {
                GUILayout.BeginArea(controlPosition);
                if (texture == null || audioItemName != audioSource.clip.name)
                {
                    audioItemName = audioSource.clip.name;
                    texture       = AssetPreview.GetAssetPreview(audioSource.clip);
                }

                float inTimeOffset    = (audioItem.InTime) * state.Scale.x;
                float outTimeOffset   = (audioItem.ItemLength - audioItem.OutTime) * state.Scale.x;
                Rect  texturePosition = new Rect(-inTimeOffset + 2, 0, controlPosition.width - 4 + inTimeOffset + outTimeOffset, controlPosition.height);

                if (texture != null)
                {
                    GUI.DrawTexture(texturePosition, texture, ScaleMode.StretchToFill);
                }
                GUILayout.EndArea();
            }
        }
    }
 public override void UpdateTrackContents(DirectorControlState state, Rect position)
 {
     handleDragInteraction(position, TargetTrack.Behaviour as AudioTrack, state.Translation, state.Scale);
     base.UpdateTrackContents(state, position);
 }
Esempio n. 25
0
    public override void HandleInput(DirectorControlState state, Rect trackPosition)
    {
        CinemaActionWrapper cinemaActionWrapper = base.Wrapper as CinemaActionWrapper;

        if (cinemaActionWrapper == null)
        {
            return;
        }
        if (this.isRenaming)
        {
            return;
        }
        float num  = cinemaActionWrapper.Firetime * state.Scale.x + state.Translation.x;
        float num2 = (cinemaActionWrapper.Firetime + cinemaActionWrapper.Duration) * state.Scale.x + state.Translation.x;

        this.controlPosition = new Rect(num, 0f, num2 - num, trackPosition.height);
        Rect rect  = new Rect(num, 0f, 5f, this.controlPosition.height);
        Rect rect2 = new Rect(num + 5f, 0f, num2 - num - 10f, this.controlPosition.height);
        Rect rect3 = new Rect(num2 - 5f, 0f, 5f, this.controlPosition.height);

        EditorGUIUtility.AddCursorRect(rect, (MouseCursor)3);
        EditorGUIUtility.AddCursorRect(rect2, (MouseCursor)5);
        EditorGUIUtility.AddCursorRect(rect3, (MouseCursor)3);
        this.controlID = GUIUtility.GetControlID(Wrapper.Behaviour.GetInstanceID(), (FocusType)2, this.controlPosition);
        int controlID  = GUIUtility.GetControlID(Wrapper.Behaviour.GetInstanceID(), (FocusType)2, rect);
        int controlID2 = GUIUtility.GetControlID(Wrapper.Behaviour.GetInstanceID(), (FocusType)2, rect2);
        int controlID3 = GUIUtility.GetControlID(Wrapper.Behaviour.GetInstanceID(), (FocusType)2, rect3);

        if (Event.current.GetTypeForControl(this.controlID) == EventType.MouseDown && rect2.Contains(Event.current.mousePosition) && Event.current.button == 1)
        {
            if (!IsSelected)
            {
                GameObject[] gameObjects = Selection.gameObjects;
                ArrayUtility.Add(ref gameObjects, Wrapper.Behaviour.gameObject);
                Selection.objects   = (gameObjects);
                hasSelectionChanged = true;
            }
            this.showContextMenu(base.Wrapper.Behaviour);
            Event.current.Use();
        }
        switch ((int)Event.current.GetTypeForControl(controlID2))
        {
        case 0:
            if (rect2.Contains(Event.current.mousePosition) && (int)Event.current.button == 0)
            {
                GUIUtility.hotControl = (controlID2);
                if (Event.current.control)
                {
                    if (base.IsSelected)
                    {
                        GameObject[] gameObjects2 = Selection.gameObjects;
                        ArrayUtility.Remove <GameObject>(ref gameObjects2, base.Wrapper.Behaviour.gameObject);
                        Selection.objects        = (gameObjects2);
                        this.hasSelectionChanged = true;
                    }
                    else
                    {
                        GameObject[] gameObjects3 = Selection.gameObjects;
                        ArrayUtility.Add <GameObject>(ref gameObjects3, base.Wrapper.Behaviour.gameObject);
                        Selection.objects        = (gameObjects3);
                        this.hasSelectionChanged = true;
                    }
                }
                else if (!base.IsSelected)
                {
                    Selection.activeInstanceID = (base.Behaviour.GetInstanceID());
                }
                this.mouseDragActivity            = false;
                ActionItemControl.mouseDownOffset = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x - cinemaActionWrapper.Firetime;
                Event.current.Use();
            }
            break;

        case 1:
            if (GUIUtility.hotControl == controlID2)
            {
                ActionItemControl.mouseDownOffset = -1f;
                GUIUtility.hotControl             = (0);
                if (!this.mouseDragActivity)
                {
                    if (Event.current.control)
                    {
                        if (!this.hasSelectionChanged)
                        {
                            if (base.IsSelected)
                            {
                                GameObject[] gameObjects4 = Selection.gameObjects;
                                ArrayUtility.Remove <GameObject>(ref gameObjects4, base.Wrapper.Behaviour.gameObject);
                                Selection.objects = (gameObjects4);
                            }
                            else
                            {
                                GameObject[] gameObjects5 = Selection.gameObjects;
                                ArrayUtility.Add <GameObject>(ref gameObjects5, base.Wrapper.Behaviour.gameObject);
                                Selection.objects = (gameObjects5);
                            }
                        }
                    }
                    else
                    {
                        Selection.activeInstanceID = (base.Behaviour.GetInstanceID());
                    }
                }
                else
                {
                    base.TriggerTrackItemUpdateEvent();
                }
                this.hasSelectionChanged = false;
            }
            break;

        case 3:
            if (GUIUtility.hotControl == controlID2 && !this.hasSelectionChanged)
            {
                Undo.RecordObject(base.Behaviour, string.Format("Changed {0}", base.Behaviour.name));
                float num3 = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x;
                num3 = state.SnappedTime(num3 - ActionItemControl.mouseDownOffset);
                if (!this.mouseDragActivity)
                {
                    this.mouseDragActivity = (base.Wrapper.Firetime != num3);
                }
                base.TriggerRequestTrackItemTranslate(num3);
            }
            break;
        }
        switch ((int)Event.current.GetTypeForControl(controlID))
        {
        case 0:
            if (rect.Contains(Event.current.mousePosition))
            {
                GUIUtility.hotControl             = (controlID);
                ActionItemControl.mouseDownOffset = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x - cinemaActionWrapper.Firetime;
                Event.current.Use();
            }
            break;

        case 1:
            if (GUIUtility.hotControl == controlID)
            {
                ActionItemControl.mouseDownOffset = -1f;
                GUIUtility.hotControl             = (0);
                if (this.AlterAction != null)
                {
                    this.AlterAction(this, new ActionItemEventArgs(cinemaActionWrapper.Behaviour, cinemaActionWrapper.Firetime, cinemaActionWrapper.Duration));
                }
            }
            break;

        case 3:
            if (GUIUtility.hotControl == controlID)
            {
                float num4 = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x;
                num4 = state.SnappedTime(num4);
                float num5 = 0f;
                float num6 = cinemaActionWrapper.Firetime + cinemaActionWrapper.Duration;
                using (IEnumerator <TimelineItemWrapper> enumerator = base.Track.Items.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        CinemaActionWrapper cinemaActionWrapper2 = enumerator.Current as CinemaActionWrapper;
                        if (cinemaActionWrapper2 != null && cinemaActionWrapper2.Behaviour != base.Wrapper.Behaviour)
                        {
                            float num7 = cinemaActionWrapper2.Firetime + cinemaActionWrapper2.Duration;
                            if (num7 <= base.Wrapper.Firetime)
                            {
                                num5 = Mathf.Max(num5, num7);
                            }
                        }
                    }
                }
                num4 = Mathf.Max(num5, num4);
                num4 = Mathf.Min(num6, num4);
                cinemaActionWrapper.Duration += base.Wrapper.Firetime - num4;
                cinemaActionWrapper.Firetime  = num4;
            }
            break;
        }
        switch ((int)Event.current.GetTypeForControl(controlID3))
        {
        case 0:
            if (rect3.Contains(Event.current.mousePosition))
            {
                GUIUtility.hotControl             = (controlID3);
                ActionItemControl.mouseDownOffset = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x - base.Wrapper.Firetime;
                Event.current.Use();
            }
            break;

        case 1:
            if (GUIUtility.hotControl == controlID3)
            {
                ActionItemControl.mouseDownOffset = -1f;
                GUIUtility.hotControl             = (0);
                if (this.AlterAction != null)
                {
                    this.AlterAction(this, new ActionItemEventArgs(cinemaActionWrapper.Behaviour, cinemaActionWrapper.Firetime, cinemaActionWrapper.Duration));
                }
            }
            break;

        case 3:
            if (GUIUtility.hotControl == controlID3)
            {
                float num8 = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x;
                num8 = state.SnappedTime(num8);
                float num9 = float.PositiveInfinity;
                using (IEnumerator <TimelineItemWrapper> enumerator = base.Track.Items.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        CinemaActionWrapper cinemaActionWrapper3 = enumerator.Current as CinemaActionWrapper;
                        if (cinemaActionWrapper3 != null && cinemaActionWrapper3.Behaviour != base.Wrapper.Behaviour)
                        {
                            float num10 = cinemaActionWrapper.Firetime + cinemaActionWrapper.Duration;
                            if (cinemaActionWrapper3.Firetime >= num10)
                            {
                                num9 = Mathf.Min(num9, cinemaActionWrapper3.Firetime);
                            }
                        }
                    }
                }
                num8 = Mathf.Clamp(num8, base.Wrapper.Firetime, num9);
                cinemaActionWrapper.Duration = num8 - base.Wrapper.Firetime;
            }
            break;
        }
        if (Selection.activeGameObject == base.Wrapper.Behaviour.gameObject)
        {
            if (Event.current.type == (EventType)13 && Event.current.commandName == "Copy")
            {
                Event.current.Use();
            }
            if (Event.current.type == (EventType)14 && Event.current.commandName == "Copy")
            {
                DirectorCopyPaste.Copy(base.Wrapper.Behaviour);
                Event.current.Use();
            }
        }
        if (Event.current.type == (EventType)4 && Event.current.keyCode == (KeyCode)127 && Selection.activeGameObject == base.Wrapper.Behaviour.gameObject)
        {
            base.deleteItem(base.Wrapper.Behaviour);
            Event.current.Use();
        }
    }
Esempio n. 26
0
    public virtual void HandleInput(DirectorControlState state, Rect trackPosition)
    {
        Behaviour behaviour = this.wrapper.Behaviour;

        if (behaviour == null)
        {
            return;
        }
        float num = this.wrapper.Firetime * state.Scale.x + state.Translation.x;

        this.controlPosition = new Rect(num - 8f, 0f, 16f, trackPosition.height);
        this.controlID       = GUIUtility.GetControlID(this.wrapper.Behaviour.GetInstanceID(), (FocusType)2, this.controlPosition);
        switch ((int)Event.current.GetTypeForControl(this.controlID))
        {
        case 0:
            if (this.controlPosition.Contains(Event.current.mousePosition) && (int)Event.current.button == 0)
            {
                GUIUtility.hotControl = (this.controlID);
                if (Event.current.control)
                {
                    if (base.IsSelected)
                    {
                        GameObject[] gameObjects = Selection.gameObjects;
                        ArrayUtility.Remove <GameObject>(ref gameObjects, this.Wrapper.Behaviour.gameObject);
                        Selection.objects        = (gameObjects);
                        this.hasSelectionChanged = true;
                    }
                    else
                    {
                        GameObject[] gameObjects2 = Selection.gameObjects;
                        ArrayUtility.Add <GameObject>(ref gameObjects2, this.Wrapper.Behaviour.gameObject);
                        Selection.objects        = (gameObjects2);
                        this.hasSelectionChanged = true;
                    }
                }
                else if (!base.IsSelected)
                {
                    Selection.activeInstanceID = (behaviour.GetInstanceID());
                }
                this.mouseDragActivity = false;
                Event.current.Use();
            }
            if (this.controlPosition.Contains(Event.current.mousePosition) && (int)Event.current.button == 1)
            {
                if (!base.IsSelected)
                {
                    GameObject[] gameObjects3 = Selection.gameObjects;
                    ArrayUtility.Add <GameObject>(ref gameObjects3, this.Wrapper.Behaviour.gameObject);
                    Selection.objects        = (gameObjects3);
                    this.hasSelectionChanged = true;
                }
                this.showContextMenu(behaviour);
                Event.current.Use();
            }
            break;

        case 1:
            if (GUIUtility.hotControl == this.controlID)
            {
                GUIUtility.hotControl = (0);
                if (!this.mouseDragActivity)
                {
                    if (Event.current.control)
                    {
                        if (!this.hasSelectionChanged)
                        {
                            if (base.IsSelected)
                            {
                                GameObject[] gameObjects4 = Selection.gameObjects;
                                ArrayUtility.Remove <GameObject>(ref gameObjects4, this.Wrapper.Behaviour.gameObject);
                                Selection.objects = (gameObjects4);
                            }
                            else
                            {
                                GameObject[] gameObjects5 = Selection.gameObjects;
                                ArrayUtility.Add <GameObject>(ref gameObjects5, this.Wrapper.Behaviour.gameObject);
                                Selection.objects = (gameObjects5);
                            }
                        }
                    }
                    else
                    {
                        Selection.activeInstanceID = (behaviour.GetInstanceID());
                    }
                }
                else if (this.TrackItemUpdate != null)
                {
                    this.TrackItemUpdate(this, new TrackItemEventArgs(this.wrapper.Behaviour, this.wrapper.Firetime));
                }
                this.hasSelectionChanged = false;
            }
            break;

        case 3:
            if (GUIUtility.hotControl == this.controlID && !this.hasSelectionChanged)
            {
                Undo.RecordObject(behaviour, string.Format("Changed {0}", behaviour.name));
                float num2 = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x;
                num2 = state.SnappedTime(num2);
                if (!this.mouseDragActivity)
                {
                    this.mouseDragActivity = (this.Wrapper.Firetime != num2);
                }
                if (this.RequestTrackItemTranslate != null)
                {
                    float firetime  = num2 - this.wrapper.Firetime;
                    float firetime2 = this.RequestTrackItemTranslate(this, new TrackItemEventArgs(this.wrapper.Behaviour, firetime));
                    if (this.TrackItemTranslate != null)
                    {
                        this.TrackItemTranslate(this, new TrackItemEventArgs(this.wrapper.Behaviour, firetime2));
                    }
                }
            }
            break;
        }
        if (Selection.activeGameObject == behaviour.gameObject)
        {
            if ((int)(int)Event.current.type == 13 && Event.current.commandName == "Copy")
            {
                Event.current.Use();
            }
            if ((int)Event.current.type == 14 && Event.current.commandName == "Copy")
            {
                DirectorCopyPaste.Copy(behaviour);
                Event.current.Use();
            }
        }
        if ((int)Event.current.type == 4 && (int)Event.current.keyCode == 127 && Selection.activeGameObject == behaviour.gameObject)
        {
            deleteItem(behaviour);
            Event.current.Use();
        }
    }
Esempio n. 27
0
    public override void HandleInput(DirectorControlState state, Rect trackPosition)
    {
        CinemaActionFixedWrapper wrapper = base.Wrapper as CinemaActionFixedWrapper;

        if (wrapper == null)
        {
            return;
        }
        if (base.isRenaming)
        {
            return;
        }
        float num  = state.TimeToPosition(wrapper.Firetime);
        float num2 = state.TimeToPosition(wrapper.Firetime + wrapper.Duration);

        base.controlPosition = new Rect(num, 0f, num2 - num, trackPosition.height);
        bool  flag1 = this.controlPosition.width < 15f;
        float num3  = flag1 ? 0f : 5f;
        Rect  rect  = new Rect(num, 0f, num3, trackPosition.height);
        Rect  rect2 = new Rect(num + num3, 0f, (num2 - num) - (2f * num3), trackPosition.height);
        Rect  rect3 = new Rect(num2 - num3, 0f, num3, trackPosition.height);

        EditorGUIUtility.AddCursorRect(rect2, MouseCursor.SlideArrow);
        if (!flag1)
        {
            EditorGUIUtility.AddCursorRect(rect, MouseCursor.ResizeHorizontal);
            EditorGUIUtility.AddCursorRect(rect3, MouseCursor.ResizeHorizontal);
        }
        base.controlID = GUIUtility.GetControlID(wrapper.Behaviour.GetInstanceID(), UnityEngine.FocusType.Passive, base.controlPosition);
        int num4 = GUIUtility.GetControlID(wrapper.Behaviour.GetInstanceID(), FocusType.Passive, rect);
        int num5 = GUIUtility.GetControlID(wrapper.Behaviour.GetInstanceID(), FocusType.Passive, rect2);
        int num6 = GUIUtility.GetControlID(wrapper.Behaviour.GetInstanceID(), FocusType.Passive, rect3);

        if (((Event.current.GetTypeForControl(base.controlID) == EventType.MouseDown) && rect2.Contains(Event.current.mousePosition)) && (Event.current.button == 1))
        {
            if (!base.IsSelected)
            {
                GameObject[] objArray = Selection.gameObjects;
                ArrayUtility.Add <GameObject>(ref objArray, base.Wrapper.Behaviour.gameObject);
                Selection.objects        = objArray;
                base.hasSelectionChanged = true;
            }
            this.showContextMenu(wrapper.Behaviour);
            if (!base.TrackControl.TargetTrack.IsLocked)
            {
                Event.current.Use();
            }
        }
        switch (Event.current.GetTypeForControl(num5))
        {
        case 0:
        {
            if (!rect2.Contains(Event.current.mousePosition) || (Event.current.button != 0))
            {
                goto Label_0447;
            }
            GUIUtility.hotControl = num5;
            if (!Event.current.control)
            {
                if (!base.IsSelected)
                {
                    Selection.activeInstanceID = base.Behaviour.GetInstanceID();
                }
                break;
            }
            if (!base.IsSelected)
            {
                GameObject[] objArray3 = Selection.gameObjects;
                ArrayUtility.Add <GameObject>(ref objArray3, base.Wrapper.Behaviour.gameObject);
                Selection.objects        = objArray3;
                base.hasSelectionChanged = true;
                break;
            }
            GameObject[] objArray2 = Selection.gameObjects;
            ArrayUtility.Remove <GameObject>(ref objArray2, base.Wrapper.Behaviour.gameObject);
            Selection.objects        = (objArray2);
            base.hasSelectionChanged = true;
            break;
        }

        case EventType.MouseUp:
            if (GUIUtility.hotControl == num5)
            {
                mouseDownOffset       = -1f;
                GUIUtility.hotControl = (0);
                if (base.mouseDragActivity)
                {
                    base.TriggerTrackItemUpdateEvent();
                }
                else if (!Event.current.control)
                {
                    Selection.activeInstanceID = (base.Behaviour.GetInstanceID());
                }
                else if (!base.hasSelectionChanged)
                {
                    if (!base.IsSelected)
                    {
                        GameObject[] objArray5 = Selection.gameObjects;
                        ArrayUtility.Add <GameObject>(ref objArray5, base.Wrapper.Behaviour.gameObject);
                        Selection.objects = (objArray5);
                    }
                    else
                    {
                        GameObject[] objArray4 = Selection.gameObjects;
                        ArrayUtility.Remove <GameObject>(ref objArray4, base.Wrapper.Behaviour.gameObject);
                        Selection.objects = (objArray4);
                    }
                }
                base.hasSelectionChanged = false;
            }
            goto Label_0447;

        case (EventType)3:
            if (GUIUtility.hotControl == num5)
            {
                Undo.RecordObject(base.Behaviour, string.Format("Changed {0}", base.Behaviour.name));
                float firetime = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x;
                firetime = state.SnappedTime(firetime - mouseDownOffset);
                if (!base.mouseDragActivity)
                {
                    base.mouseDragActivity = base.Wrapper.Firetime != firetime;
                }
                base.TriggerRequestTrackItemTranslate(firetime);
            }
            goto Label_0447;

        default:
            goto Label_0447;
        }
        base.mouseDragActivity = false;
        mouseDownOffset        = ((Event.current.mousePosition.x - state.Translation.x) / state.Scale.x) - wrapper.Firetime;
        if (!base.TrackControl.TargetTrack.IsLocked)
        {
            Event.current.Use();
        }
Label_0447:
        switch (Event.current.GetTypeForControl(num4))
        {
        case 0:
            if (rect.Contains(Event.current.mousePosition))
            {
                GUIUtility.hotControl = (num4);
                mouseDownOffset       = ((Event.current.mousePosition.x - state.Translation.x) / state.Scale.x) - wrapper.Firetime;
                if (!base.TrackControl.TargetTrack.IsLocked)
                {
                    Event.current.Use();
                }
            }
            break;

        case (EventType)1:
            if (GUIUtility.hotControl == num4)
            {
                mouseDownOffset       = -1f;
                GUIUtility.hotControl = (0);
            }
            break;

        case (EventType)3:
            if (GUIUtility.hotControl == num4)
            {
                float time = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x;
                time = state.SnappedTime(time);
                if (time >= 0f)
                {
                    float num9 = wrapper.InTime - (wrapper.Firetime - time);
                    num9 = Mathf.Clamp(num9, 0f, wrapper.ItemLength);
                    float num10 = num9 - wrapper.InTime;
                    wrapper.InTime    = num9;
                    wrapper.Firetime += num10;
                    if (this.AlterFixedAction != null)
                    {
                        this.AlterFixedAction(this, new ActionFixedItemEventArgs(wrapper.Behaviour, wrapper.Firetime, wrapper.Duration, wrapper.InTime, wrapper.OutTime));
                    }
                }
            }
            break;
        }
        switch (Event.current.GetTypeForControl(num6))
        {
        case 0:
            if (rect3.Contains(Event.current.mousePosition))
            {
                GUIUtility.hotControl = (num6);
                mouseDownOffset       = ((Event.current.mousePosition.x - state.Translation.x) / state.Scale.x) - wrapper.Firetime;
                if (!base.TrackControl.TargetTrack.IsLocked)
                {
                    Event.current.Use();
                }
            }
            break;

        case (EventType)1:
            if (GUIUtility.hotControl == num6)
            {
                mouseDownOffset       = -1f;
                GUIUtility.hotControl = (0);
            }
            break;

        case (EventType)3:
            if (GUIUtility.hotControl == num6)
            {
                float num11 = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x;
                float num12 = state.SnappedTime(num11) - (wrapper.Firetime - wrapper.InTime);
                Undo.RecordObject(wrapper.Behaviour, string.Format("Changed {0}", wrapper.Behaviour.name));
                wrapper.OutTime = Mathf.Clamp(num12, 0f, wrapper.ItemLength);
                if (this.AlterFixedAction != null)
                {
                    this.AlterFixedAction(this, new ActionFixedItemEventArgs(wrapper.Behaviour, wrapper.Firetime, wrapper.Duration, wrapper.InTime, wrapper.OutTime));
                }
            }
            break;
        }
        if (Selection.activeGameObject == base.Wrapper.Behaviour.gameObject)
        {
            if ((Event.current.type == (EventType)13) && (Event.current.commandName == "Copy"))
            {
                Event.current.Use();
            }
            if ((Event.current.type == (EventType)14) && (Event.current.commandName == "Copy"))
            {
                DirectorCopyPaste.Copy(base.Wrapper.Behaviour);
                Event.current.Use();
            }
        }
        if (((Event.current.type == (EventType)4) && (Event.current.keyCode == (KeyCode)0x7f)) && (Selection.activeGameObject == base.Wrapper.Behaviour.gameObject))
        {
            base.deleteItem(base.Wrapper.Behaviour);
            Event.current.Use();
        }
    }
Esempio n. 28
0
    private void checkToAddNewKeyframes(CinemaActorClipCurve clipCurve, DirectorControlState state, bool inArea)
    {
        Undo.RecordObject(clipCurve, "Auto Key Created");
        bool hasDifferenceBeenFound = false;

        foreach (MemberClipCurveData data in clipCurve.CurveData)
        {
            if (data.Type == string.Empty || data.PropertyName == string.Empty)
            {
                continue;
            }

            Component component = clipCurve.Actor.GetComponent(data.Type);
            object    value     = CinemaActorClipCurve.GetCurrentValue(component, data.PropertyName, data.IsProperty);

            PropertyTypeInfo typeInfo = data.PropertyType;
            if (typeInfo == PropertyTypeInfo.Int || typeInfo == PropertyTypeInfo.Long || typeInfo == PropertyTypeInfo.Float || typeInfo == PropertyTypeInfo.Double)
            {
                float x           = (float)value;
                float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(x, curve1Value, data.Curve1, state.ScrubberPosition, inArea);
            }
            else if (typeInfo == PropertyTypeInfo.Vector2)
            {
                Vector2 vec2        = (Vector2)value;
                float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.x, curve1Value, data.Curve1, state.ScrubberPosition, inArea);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.y, curve2Value, data.Curve2, state.ScrubberPosition, inArea);
            }
            else if (typeInfo == PropertyTypeInfo.Vector3)
            {
                Vector3 vec3        = (Vector3)value;
                float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                float   curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);

                hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.x, curve1Value, data.Curve1, state.ScrubberPosition, inArea);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.y, curve2Value, data.Curve2, state.ScrubberPosition, inArea);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.z, curve3Value, data.Curve3, state.ScrubberPosition, inArea);
            }
            else if (typeInfo == PropertyTypeInfo.Vector4)
            {
                Vector4 vec4        = (Vector4)value;
                float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                float   curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                float   curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.x, curve1Value, data.Curve1, state.ScrubberPosition, inArea);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.y, curve2Value, data.Curve2, state.ScrubberPosition, inArea);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.z, curve3Value, data.Curve3, state.ScrubberPosition, inArea);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.w, curve4Value, data.Curve4, state.ScrubberPosition, inArea);
            }
            else if (typeInfo == PropertyTypeInfo.Quaternion)
            {
                Quaternion quaternion  = (Quaternion)value;
                float      curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                float      curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                float      curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                float      curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(quaternion.x, curve1Value, data.Curve1, state.ScrubberPosition, inArea, QUATERNION_THRESHOLD);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(quaternion.y, curve2Value, data.Curve2, state.ScrubberPosition, inArea, QUATERNION_THRESHOLD);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(quaternion.z, curve3Value, data.Curve3, state.ScrubberPosition, inArea, QUATERNION_THRESHOLD);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(quaternion.w, curve4Value, data.Curve4, state.ScrubberPosition, inArea, QUATERNION_THRESHOLD);
            }
            else if (typeInfo == PropertyTypeInfo.Color)
            {
                Color color       = (Color)value;
                float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                float curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                float curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                hasDifferenceBeenFound |= addKeyOnUserInteraction(color.r, curve1Value, data.Curve1, state.ScrubberPosition, inArea);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(color.g, curve2Value, data.Curve2, state.ScrubberPosition, inArea);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(color.b, curve3Value, data.Curve3, state.ScrubberPosition, inArea);
                hasDifferenceBeenFound |= addKeyOnUserInteraction(color.a, curve4Value, data.Curve4, state.ScrubberPosition, inArea);
            }
        }
        if (hasDifferenceBeenFound)
        {
            hasUserInteracted = true;
            FillReverseKeyframes();
            EditorUtility.SetDirty(clipCurve);
        }
        else
        {
            m_RecordList.Clear();
        }
    }
Esempio n. 29
0
    private void checkToAddNewKeyframes(ActorClipCurve clipCurve, DirectorControlState state)
    {
        if (state.IsInPreviewMode && IsEditing &&
            clipCurve.Manager.State == TimelineManager.TimeLineState.Paused && GUIUtility.hotControl == 0 &&
            (clipCurve.Firetime <= state.ScrubberPosition &&
             state.ScrubberPosition <= clipCurve.Firetime + clipCurve.Duration) && clipCurve.Actor != null)
        {
            Undo.RecordObject(clipCurve, "Auto Key Created");
            bool hasDifferenceBeenFound = false;
            for (int i = 0; i < clipCurve.CurveData.Count; i++)
            {
                MemberClipCurveData data = clipCurve.CurveData[i];
                if (data.Type == string.Empty || data.PropertyName == string.Empty)
                {
                    continue;
                }

                Component component = clipCurve.Actor.GetComponent(data.Type);
                object    value     = clipCurve.GetCurrentValue(component, data.PropertyName, data.IsProperty);

                PropertyTypeInfo typeInfo = data.PropertyType;

                if (typeInfo == PropertyTypeInfo.Int || typeInfo == PropertyTypeInfo.Long)
                {
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(Convert.ToInt32(value), curve1Value, data.Curve1, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Float || typeInfo == PropertyTypeInfo.Double)
                {
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(Convert.ToSingle(value), curve1Value, data.Curve1, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector2)
                {
                    Vector2 vec2        = (Vector2)value;
                    float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.y, curve2Value, data.Curve2, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector3)
                {
                    Vector3 vec3        = (Vector3)value;
                    float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float   curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.y, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.z, curve3Value, data.Curve3, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector4)
                {
                    Vector4 vec4        = (Vector4)value;
                    float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float   curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float   curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.y, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.z, curve3Value, data.Curve3, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.w, curve4Value, data.Curve4, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Quaternion)
                {
                    Quaternion quaternion  = (Quaternion)value;
                    float      curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float      curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float      curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float      curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    for (int j = 0; j < data.Curve1.length; j++)
                    {
                        Keyframe k = data.Curve1[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.x, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve1, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve2.length; j++)
                    {
                        Keyframe k = data.Curve2[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.y, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve2, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve3.length; j++)
                    {
                        Keyframe k = data.Curve3[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.z, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve3, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve4.length; j++)
                    {
                        Keyframe k = data.Curve4[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.w, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve4, j, newKeyframe);
                        }
                    }

                    Quaternion curveValue = new Quaternion(curve1Value, curve2Value, curve3Value, curve4Value);
                    float      angle      = Vector3.Angle(quaternion.eulerAngles, curveValue.eulerAngles);
                    hasDifferenceBeenFound = hasDifferenceBeenFound || angle > QUATERNION_THRESHOLD;
                    if (angle > QUATERNION_THRESHOLD && hasUserInteracted)
                    {
                        data.Curve1.AddKey(state.ScrubberPosition, quaternion.x);
                        data.Curve2.AddKey(state.ScrubberPosition, quaternion.y);
                        data.Curve3.AddKey(state.ScrubberPosition, quaternion.z);
                        data.Curve4.AddKey(state.ScrubberPosition, quaternion.w);
                        hasUserInteracted = true;
                    }
                }
                else if (typeInfo == PropertyTypeInfo.Color)
                {
                    Color color       = (Color)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.r, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.g, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.b, curve3Value, data.Curve3, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.a, curve4Value, data.Curve4, state.ScrubberPosition);
                }
            }
            if (hasDifferenceBeenFound)
            {
                hasUserInteracted = true;
                EditorUtility.SetDirty(clipCurve);
            }
        }
    }
Esempio n. 30
0
 public override void UpdateTrackContents(DirectorControlState state, Rect position)
 {
     handleDragInteraction(position, TargetTrack.Behaviour as AudioTrack, state.Translation, state.Scale);
     base.UpdateTrackContents(state, position);
 }
    private void checkToAddNewKeyframes(CinemaActorClipCurve clipCurve, DirectorControlState state)
    {
        if (state.IsInPreviewMode && IsEditing && GUIUtility.hotControl == 0 && (clipCurve.Firetime <= state.ScrubberPosition && state.ScrubberPosition <= clipCurve.Firetime + clipCurve.Duration))
        {
            bool hasDifferenceBeenFound = false;
            foreach (MemberClipCurveData data in clipCurve.CurveData)
            {
                if (data.Type == string.Empty || data.PropertyName == string.Empty)
                {
                    continue;
                }

                Component component = clipCurve.Actor.GetComponent(data.Type);
                object    value     = clipCurve.GetCurrentValue(component, data.PropertyName, data.IsProperty);


                PropertyTypeInfo typeInfo = data.PropertyType;
                if (typeInfo == PropertyTypeInfo.Int || typeInfo == PropertyTypeInfo.Long || typeInfo == PropertyTypeInfo.Float ||
                    typeInfo == PropertyTypeInfo.Double)
                {
                    float x           = (float)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(x, curve1Value, data.Curve1, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector2)
                {
                    Vector2 vec2        = (Vector2)value;
                    float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.y, curve2Value, data.Curve2, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector3)
                {
                    Vector3 vec3        = (Vector3)value;
                    float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float   curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.y, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.z, curve3Value, data.Curve3, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector4)
                {
                    Vector4 vec4        = (Vector4)value;
                    float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float   curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float   curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.y, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.z, curve3Value, data.Curve3, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.w, curve4Value, data.Curve4, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Quaternion)
                {
                    Quaternion quaternion  = (Quaternion)value;
                    float      curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float      curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float      curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float      curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    for (int j = 0; j < data.Curve1.length; j++)
                    {
                        Keyframe k = data.Curve1[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            data.Curve1.MoveKey(j, new Keyframe(k.time, quaternion.x, k.inTangent, k.outTangent));
                        }
                    }

                    for (int j = 0; j < data.Curve2.length; j++)
                    {
                        Keyframe k = data.Curve2[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            data.Curve2.MoveKey(j, new Keyframe(k.time, quaternion.y, k.inTangent, k.outTangent));
                        }
                    }

                    for (int j = 0; j < data.Curve3.length; j++)
                    {
                        Keyframe k = data.Curve3[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            data.Curve3.MoveKey(j, new Keyframe(k.time, quaternion.z, k.inTangent, k.outTangent));
                        }
                    }

                    for (int j = 0; j < data.Curve4.length; j++)
                    {
                        Keyframe k = data.Curve4[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            data.Curve4.MoveKey(j, new Keyframe(k.time, quaternion.w, k.inTangent, k.outTangent));
                        }
                    }

                    Quaternion curveValue = new Quaternion(curve1Value, curve2Value, curve3Value, curve4Value);
                    float      angle      = Vector3.Angle(quaternion.eulerAngles, curveValue.eulerAngles);
                    hasDifferenceBeenFound = hasDifferenceBeenFound || angle > QUATERNION_THRESHOLD;
                    if (angle > QUATERNION_THRESHOLD && hasUserInteracted)
                    {
                        data.Curve1.AddKey(state.ScrubberPosition, quaternion.x);
                        data.Curve2.AddKey(state.ScrubberPosition, quaternion.y);
                        data.Curve3.AddKey(state.ScrubberPosition, quaternion.z);
                        data.Curve4.AddKey(state.ScrubberPosition, quaternion.w);
                        hasUserInteracted = true;
                    }
                }
                else if (typeInfo == PropertyTypeInfo.Color)
                {
                    Color color       = (Color)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.r, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.g, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.b, curve3Value, data.Curve3, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.a, curve4Value, data.Curve4, state.ScrubberPosition);
                }
            }
            if (hasDifferenceBeenFound)
            {
                hasUserInteracted = true;
            }
        }
    }
Esempio n. 32
0
 public virtual void PreUpdate(DirectorControlState state, Rect trackPosition)
 {
 }
Esempio n. 33
0
 public virtual void PostUpdate(DirectorControlState state, bool inArea, EventType type)
 {
 }
Esempio n. 34
0
    public override void UpdateHeaderContents(DirectorControlState state, Rect position, Rect headerBackground)
    {
        Rect   rect         = new Rect(position.x + 14f, position.y, 14f, position.height);
        float  introduced10 = rect.x;
        Rect   rect2        = new Rect(introduced10 + rect.width, position.y, ((position.width - 14f) - 96f) - 14f, 17f);
        string str          = base.TargetTrack.Behaviour.name;
        bool   flag         = EditorGUI.Foldout(rect, base.isExpanded, GUIContent.none, false);

        if (flag != base.isExpanded)
        {
            base.isExpanded = flag;
            EditorPrefs.SetBool(base.IsExpandedKey, base.isExpanded);
        }
        this.updateHeaderControl1(new Rect(position.width - 64f, position.y, 16f, 16f));
        this.updateHeaderControl2(new Rect(position.width - 48f, position.y, 16f, 16f));
        this.updateHeaderControl3(new Rect(position.width - 32f, position.y, 16f, 16f));
        this.updateHeaderControl4(new Rect(position.width - 16f, position.y, 16f, 16f));
        this.updateHeaderControl6(new UnityEngine.Rect(position.width - 96, position.y, 16f, 16f));
        if (base.isExpanded)
        {
            Rect rect3 = new Rect(rect2.x + 28f, position.y + 17f, (headerBackground.width - rect2.x) - 28f, 17f);
            if (((this.focusedControl != null) && (this.focusedControl.Wrapper != null)) && (this.focusedControl.Wrapper.Behaviour != null))
            {
                float introduced11 = rect3.x;
                float introduced12 = rect3.y;
                new Rect(introduced11, introduced12, rect3.width / 2f, rect3.height);
                float introduced13      = rect3.x;
                float introduced14      = rect3.y;
                float introduced15      = rect3.x;
                float introduced16      = rect3.y;
                Rect  controlHeaderArea = new Rect(introduced15, introduced16 + rect3.height, rect3.width, position.height - 34f);
                this.focusedControl.UpdateHeaderArea(state, controlHeaderArea);
                if (GUI.Button(new Rect(introduced13 + (rect3.width / 2f), introduced14, rect3.width / 2f, rect3.height), new GUIContent("Done")))
                {
                    this.focusedControl = null;
                    this.editItemControl(-1);
                    this.MINIMUM_ROWS_SHOWING = 3;
                    this.rowsShowing          = 5;
                }
            }
            else
            {
                this.updateEditPanel(rect3);
            }
        }
        if (base.isRenaming)
        {
            GUI.SetNextControlName("CurveTrackRename");
            str = EditorGUI.TextField(rect2, GUIContent.none, str);
            if (base.renameRequested)
            {
                EditorGUI.FocusTextInControl("CurveTrackRename");
                base.renameRequested = false;
            }
            if ((Event.current.keyCode == (KeyCode)13) || ((Event.current.type == EventType.MouseUp) && !rect2.Contains(Event.current.mousePosition)))
            {
                base.isRenaming            = false;
                GUIUtility.hotControl      = (0);
                GUIUtility.keyboardControl = (0);
            }
        }
        if (base.TargetTrack.Behaviour.name != str)
        {
            Undo.RecordObject(base.TargetTrack.Behaviour.gameObject, string.Format("Renamed {0}", base.TargetTrack.Behaviour.name));
            base.TargetTrack.Behaviour.name = (str);
        }
        if (!base.isRenaming)
        {
            string str2 = str;
            for (Vector2 vector = GUI.skin.label.CalcSize(new GUIContent(str2)); (vector.x > rect2.width) && (str2.Length > 5); vector = GUI.skin.label.CalcSize(new GUIContent(str2)))
            {
                str2 = str2.Substring(0, str2.Length - 4) + "...";
            }
            if (Selection.Contains(base.TargetTrack.Behaviour.gameObject))
            {
                GUI.Label(rect2, str2, EditorStyles.whiteLabel);
            }
            else
            {
                GUI.Label(rect2, str2);
            }
            int num = GUIUtility.GetControlID(base.TargetTrack.Behaviour.GetInstanceID(), (FocusType)2, position);
            if (Event.current.GetTypeForControl(num) == EventType.MouseDown)
            {
                if (position.Contains(Event.current.mousePosition) && (Event.current.button == 1))
                {
                    if (!base.IsSelected)
                    {
                        base.RequestSelect();
                    }
                    base.showHeaderContextMenu();
                    Event.current.Use();
                }
                else if (position.Contains(Event.current.mousePosition) && (Event.current.button == 0))
                {
                    base.RequestSelect();
                    Event.current.Use();
                }
            }
        }
    }
Esempio n. 35
0
    public virtual void HandleInput(DirectorControlState state, Rect trackPosition)
    {
        Behaviour behaviour = wrapper.Behaviour;

        if (behaviour == null)
        {
            return;
        }
        float num = wrapper.Firetime * state.Scale.x + state.Translation.x;

        controlPosition = new Rect(num - 8f, 0f, 16f, trackPosition.height);
        controlID       = GUIUtility.GetControlID(wrapper.Behaviour.GetInstanceID(), FocusType.Passive, controlPosition);
        switch (Event.current.GetTypeForControl(controlID))
        {
        case EventType.MouseDown:
            if (controlPosition.Contains(Event.current.mousePosition) && Event.current.button == 0)
            {
                GUIUtility.hotControl = controlID;
                if (Event.current.control)
                {
                    if (IsSelected)
                    {
                        GameObject[] gameObjects = Selection.gameObjects;
                        ArrayUtility.Remove(ref gameObjects, Wrapper.Behaviour.gameObject);
                        Selection.objects   = (gameObjects);
                        hasSelectionChanged = true;
                    }
                    else
                    {
                        GameObject[] gameObjects2 = Selection.gameObjects;
                        ArrayUtility.Add(ref gameObjects2, Wrapper.Behaviour.gameObject);
                        Selection.objects   = (gameObjects2);
                        hasSelectionChanged = true;
                    }
                }
                else if (!IsSelected)
                {
                    Selection.activeInstanceID = (behaviour.GetInstanceID());
                }
                mouseDragActivity = false;
                Event.current.Use();
            }
            if (controlPosition.Contains(Event.current.mousePosition) && Event.current.button == 1)
            {
                if (!IsSelected)
                {
                    GameObject[] gameObjects3 = Selection.gameObjects;
                    ArrayUtility.Add(ref gameObjects3, Wrapper.Behaviour.gameObject);
                    Selection.objects   = (gameObjects3);
                    hasSelectionChanged = true;
                }
                showContextMenu(behaviour);
                Event.current.Use();
            }
            break;

        case EventType.MouseUp:
            if (GUIUtility.hotControl == controlID)
            {
                GUIUtility.hotControl = (0);
                if (!mouseDragActivity)
                {
                    if (Event.current.control)
                    {
                        if (!hasSelectionChanged)
                        {
                            if (IsSelected)
                            {
                                GameObject[] gameObjects4 = Selection.gameObjects;
                                ArrayUtility.Remove(ref gameObjects4, Wrapper.Behaviour.gameObject);
                                Selection.objects = (gameObjects4);
                            }
                            else
                            {
                                GameObject[] gameObjects5 = Selection.gameObjects;
                                ArrayUtility.Add(ref gameObjects5, Wrapper.Behaviour.gameObject);
                                Selection.objects = (gameObjects5);
                            }
                        }
                    }
                    else
                    {
                        Selection.activeInstanceID = (behaviour.GetInstanceID());
                    }
                }
                else
                {
                    TrackItemUpdate?.Invoke(this, new TrackItemEventArgs(wrapper.Behaviour, wrapper.Firetime));
                }
                hasSelectionChanged = false;
            }
            break;

        case EventType.MouseDrag:
            if (GUIUtility.hotControl == controlID && !hasSelectionChanged)
            {
                Undo.RecordObject(behaviour, string.Format("Changed {0}", behaviour.name));
                float num2 = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x;
                num2 = state.SnappedTime(num2);
                if (!mouseDragActivity)
                {
                    mouseDragActivity = (Wrapper.Firetime != num2);
                }
                if (RequestTrackItemTranslate != null)
                {
                    float firetime  = num2 - wrapper.Firetime;
                    float firetime2 = RequestTrackItemTranslate(this, new TrackItemEventArgs(wrapper.Behaviour, firetime));
                    TrackItemTranslate?.Invoke(this, new TrackItemEventArgs(wrapper.Behaviour, firetime2));
                }
            }
            break;
        }
        if (Selection.activeGameObject == behaviour.gameObject)
        {
            if (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "Copy")
            {
                Event.current.Use();
            }
            if ((int)Event.current.type == 14 && Event.current.commandName == "Copy")
            {
                DirectorCopyPaste.Copy(behaviour);
                Event.current.Use();
            }
        }
        if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Delete && Selection.activeGameObject == behaviour.gameObject)
        {
            deleteItem(behaviour);
            Event.current.Use();
        }
    }