예제 #1
0
 private void FireEvent(USEventBase baseEvent, float prevElapsedTime, float elapsedTime)
 {
     if ((prevElapsedTime < baseEvent.FireTime || prevElapsedTime <= 0f) && elapsedTime >= baseEvent.FireTime && baseEvent.AffectedObject)
     {
         baseEvent.FireEvent();
     }
 }
예제 #2
0
        private void FireEventCommon(USEventBase baseEvent, float sequencerTime, float prevElapsedTime, float elapsedTime)
        {
            if (elapsedTime > baseEvent.FireTime && elapsedTime <= baseEvent.FireTime + baseEvent.Duration)
            {
                float deltaTime = sequencerTime - baseEvent.FireTime;
                if (baseEvent.AffectedObject)
                {
                    baseEvent.ProcessEvent(deltaTime);
                }
            }

            if (prevElapsedTime < baseEvent.FireTime + baseEvent.Duration && elapsedTime >= baseEvent.FireTime + baseEvent.Duration)
            {
                if (baseEvent.AffectedObject)
                {
                    float deltaTime = sequencerTime - baseEvent.FireTime;
                    baseEvent.ProcessEvent(deltaTime);
                    baseEvent.EndEvent();
                }
            }

            if (prevElapsedTime >= baseEvent.FireTime && elapsedTime < baseEvent.FireTime)
            {
                if (baseEvent.AffectedObject)
                {
                    baseEvent.UndoEvent();
                }
            }
        }
예제 #3
0
        /// <summary>
        /// This function will skip the timeline time to the time passed, any event that is flagged to fire when skipped
        /// (None by default) will not fired.
        /// </summary>
        public override void SkipTimelineTo(float time)
        {
            float prevElapsedTime = elapsedTime;

            elapsedTime = time;

            foreach (Transform child in transform)
            {
                USEventBase baseEvent = child.GetComponent <USEventBase>();
                if (!baseEvent)
                {
                    continue;
                }

                bool shouldSkipEvent = !baseEvent.IsFireAndForgetEvent || !baseEvent.FireOnSkip;
                if (shouldSkipEvent)
                {
                    continue;
                }

                if ((prevElapsedTime < baseEvent.FireTime || prevElapsedTime <= 0.0f) && time > baseEvent.FireTime)
                {
                    if (Sequence.IsPlaying && baseEvent.AffectedObject)
                    {
                        baseEvent.FireEvent();
                    }
                }
            }
        }
예제 #4
0
        public override void Process(float sequencerTime, float playbackRate)
        {
            float num = this.elapsedTime;

            this.elapsedTime = sequencerTime;
            USEventBase[] events = this.Events;
            if (num < this.elapsedTime)
            {
                Array.Sort <USEventBase>(events, (USEventBase a, USEventBase b) => a.FireTime.CompareTo(b.FireTime));
            }
            else
            {
                Array.Sort <USEventBase>(events, (USEventBase a, USEventBase b) => b.FireTime.CompareTo(a.FireTime));
            }
            USEventBase[] array = events;
            for (int i = 0; i < array.Length; i++)
            {
                USEventBase baseEvent = array[i];
                if (playbackRate >= 0f)
                {
                    this.FireEvent(baseEvent, num, this.elapsedTime);
                }
                else
                {
                    this.FireEventReverse(baseEvent, num, this.elapsedTime);
                }
                this.FireEventCommon(baseEvent, sequencerTime, num, this.elapsedTime);
            }
        }
        public void Initialize(USEventBase evt)
        {
            Event = evt;

            // Use Reflection to find the Function we require and call it.
            var baseType  = typeof(USEventBaseEditor);
            var foundType = baseType;
            var types     = USEditorUtility.GetAllSubTypes(baseType);

            foreach (var type in types)
            {
                if (type.IsSubclassOf(baseType))
                {
                    foreach (Attribute attr in type.GetCustomAttributes(true))
                    {
                        var eventAttr = attr as CustomUSEditorAttribute;

                        if (eventAttr == null)
                        {
                            continue;
                        }

                        if (eventAttr.InspectedType == Event.GetType())
                        {
                            foundType = type;
                        }
                    }
                }
            }

            eventEditor             = CreateInstance(foundType) as USEventBaseEditor;
            eventEditor.TargetEvent = Event;
        }
예제 #6
0
 public override void PauseTimeline()
 {
     USEventBase[] events = this.Events;
     for (int i = 0; i < events.Length; i++)
     {
         USEventBase uSEventBase = events[i];
         uSEventBase.PauseEvent();
     }
 }
예제 #7
0
 public override void ResumeTimeline()
 {
     USEventBase[] events = this.Events;
     for (int i = 0; i < events.Length; i++)
     {
         USEventBase uSEventBase = events[i];
         if (!uSEventBase.IsFireAndForgetEvent && base.Sequence.RunningTime > uSEventBase.FireTime && base.Sequence.RunningTime < uSEventBase.FireTime + uSEventBase.Duration)
         {
             uSEventBase.ResumeEvent();
         }
     }
 }
예제 #8
0
 private void Start()
 {
     USTimelineContainer[] array = this.TimelineContainers;
     for (int i = 0; i < array.Length; i++)
     {
         USTimelineContainer uSTimelineContainer = array[i];
         if (uSTimelineContainer)
         {
             USTimelineBase[] timelines = uSTimelineContainer.Timelines;
             for (int j = 0; j < timelines.Length; j++)
             {
                 USTimelineBase  uSTimelineBase  = timelines[j];
                 USTimelineEvent uSTimelineEvent = uSTimelineBase as USTimelineEvent;
                 if (uSTimelineEvent)
                 {
                     USEventBase[] events = uSTimelineEvent.Events;
                     for (int k = 0; k < events.Length; k++)
                     {
                         USEventBase uSEventBase = events[k];
                         uSEventBase.FixupAdditionalObjects();
                     }
                 }
                 USTimelineObserver uSTimelineObserver = uSTimelineBase as USTimelineObserver;
                 if (uSTimelineObserver)
                 {
                     foreach (USObserverKeyframe current in uSTimelineObserver.observerKeyframes)
                     {
                         if (!(current.cameraPath == string.Empty))
                         {
                             GameObject gameObject = GameObject.Find(current.cameraPath);
                             if (gameObject)
                             {
                                 Camera component = gameObject.GetComponent <Camera>();
                                 if (component)
                                 {
                                     current.KeyframeCamera = component;
                                 }
                             }
                         }
                     }
                 }
                 USTimelineObjectPath uSTimelineObjectPath = uSTimelineBase as USTimelineObjectPath;
                 if (uSTimelineObjectPath)
                 {
                     uSTimelineObjectPath.FixupAdditionalObjects();
                 }
             }
         }
     }
 }
예제 #9
0
        public USEventBase Event(int index)
        {
            if (index >= this.EventCount)
            {
                Debug.LogError("Trying to access an element in mEventList that does not exist from USTimelineEvent::Event");
                return(null);
            }
            USEventBase component = base.transform.GetChild(index).GetComponent <USEventBase>();

            if (!component)
            {
                Debug.LogWarning("We've requested an event that doesn't have a USEventBase component : " + component.name + " from timeline : " + base.name);
            }
            return(component);
        }
예제 #10
0
 public override void ManuallySetTime(float sequencerTime)
 {
     foreach (Transform transform in base.transform)
     {
         USEventBase component = transform.GetComponent <USEventBase>();
         if (component)
         {
             float deltaTime = sequencerTime - component.FireTime;
             if (component.AffectedObject)
             {
                 component.ManuallySetTime(deltaTime);
             }
         }
     }
 }
예제 #11
0
        public override void ManuallySetTime(float sequencerTime)
        {
            foreach (Transform child in transform)
            {
                USEventBase baseEvent = child.GetComponent <USEventBase>();
                if (!baseEvent)
                {
                    continue;
                }

                float deltaTime = sequencerTime - baseEvent.FireTime;
                if (baseEvent.AffectedObject)
                {
                    baseEvent.ManuallySetTime(deltaTime);
                }
            }
        }
예제 #12
0
        public override void SkipTimelineTo(float time)
        {
            float num = this.elapsedTime;

            this.elapsedTime = time;
            foreach (Transform transform in base.transform)
            {
                USEventBase component = transform.GetComponent <USEventBase>();
                if (component)
                {
                    bool flag = !component.IsFireAndForgetEvent || !component.FireOnSkip;
                    if (!flag)
                    {
                        if ((num < component.FireTime || num <= 0f) && time > component.FireTime && base.Sequence.IsPlaying && component.AffectedObject)
                        {
                            component.FireEvent();
                        }
                    }
                }
            }
        }
예제 #13
0
        private void RemoveEvent(USEventBase baseEvent)
        {
            USUndoManager.RegisterCompleteObjectUndo(this, "Remove Event");

            EventRenderData foundEventData = null;

            foreach (var cachedRenderData in cachedEventRenderData)
            {
                if (cachedRenderData.Event == baseEvent)
                {
                    foundEventData = cachedRenderData;
                }
            }

            cachedEventRenderData.Remove(foundEventData);

            var removedGameObject = foundEventData.Event.gameObject;

            USUndoManager.DestroyImmediate(foundEventData);
            USUndoManager.DestroyImmediate(removedGameObject);
        }
예제 #14
0
        public void AddNewEvent(USEventBase sequencerEvent)
        {
            sequencerEvent.transform.parent = transform;

            SortEvents();
        }
예제 #15
0
 private void FireEventReverse(USEventBase baseEvent, float prevElapsedTime, float elapsedTime)
 {
 }