Esempio n. 1
0
 static public int get_CanOptimize(IntPtr l)
 {
     try {
         CinemaDirector.TrackGroup self = (CinemaDirector.TrackGroup)checkSelf(l);
         pushValue(l, self.CanOptimize);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 2
0
 static public int Resume(IntPtr l)
 {
     try {
         CinemaDirector.TrackGroup self = (CinemaDirector.TrackGroup)checkSelf(l);
         self.Resume();
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 3
0
 static public int GetAllowedTrackTypes(IntPtr l)
 {
     try {
         CinemaDirector.TrackGroup self = (CinemaDirector.TrackGroup)checkSelf(l);
         var ret = self.GetAllowedTrackTypes();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 4
0
 static public int set_CanOptimize(IntPtr l)
 {
     try {
         CinemaDirector.TrackGroup self = (CinemaDirector.TrackGroup)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.CanOptimize = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 5
0
 static public int SetRunningTime(IntPtr l)
 {
     try {
         CinemaDirector.TrackGroup self = (CinemaDirector.TrackGroup)checkSelf(l);
         System.Single             a1;
         checkType(l, 2, out a1);
         self.SetRunningTime(a1);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 6
0
 static public int set_Ordinal(IntPtr l)
 {
     try {
         CinemaDirector.TrackGroup self = (CinemaDirector.TrackGroup)checkSelf(l);
         int v;
         checkType(l, 2, out v);
         self.Ordinal = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 7
0
 static public int UpdateTrackGroup(IntPtr l)
 {
     try {
         CinemaDirector.TrackGroup self = (CinemaDirector.TrackGroup)checkSelf(l);
         System.Single             a1;
         checkType(l, 2, out a1);
         System.Single a2;
         checkType(l, 3, out a2);
         self.UpdateTrackGroup(a1, a2);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 8
0
 static public int GetMilestones(IntPtr l)
 {
     try {
         CinemaDirector.TrackGroup self = (CinemaDirector.TrackGroup)checkSelf(l);
         System.Single             a1;
         checkType(l, 2, out a1);
         System.Single a2;
         checkType(l, 3, out a2);
         var ret = self.GetMilestones(a1, a2);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Optimizes the Cutscene by preparing all tracks and timeline items into a cache.
 /// Call this on scene load in most cases. (Avoid calling in edit mode).
 /// </summary>
 public void Optimize()
 {
     if (canOptimize)
     {
         trackGroupCache  = GetTrackGroups();
         hasBeenOptimized = true;
     }
     TrackGroup[] tgs = GetTrackGroups();
     if (tgs != null)
     {
         for (int i = 0; i < tgs.Length; ++i)
         {
             TrackGroup tg = tgs[i];
             tg.Optimize();
         }
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Updates the cutscene by the amount of time passed.
        /// </summary>
        /// <param name="deltaTime">The delta in time between the last update call and this one.</param>
        public void UpdateCutscene(float deltaTime)
        {
            this.RunningTime += (deltaTime * playbackSpeed);

            TrackGroup[] groupArr = this.GetTrackGroups();
            for (int i = 0; i < groupArr.Length; i++)
            {
                TrackGroup group = groupArr[i];
                group.UpdateTrackGroup(RunningTime, deltaTime * playbackSpeed);
            }
            if (state != CutsceneState.Scrubbing)
            {
                if (runningTime >= duration || runningTime < 0f)
                {
                    Stop();
                }
            }
        }
        /// <summary>
        /// Returns a list of Track types that are associated with the given Track Group.
        /// </summary>
        /// <param name="trackGroup">The track group to be inspected</param>
        /// <returns>A list of track types that meet the genre criteria of the given track group.</returns>
        public static List <Type> GetAllowedTrackTypes(TrackGroup trackGroup)
        {
            // Get all the allowed Genres for this track group
            TimelineTrackGenre[] genres = new TimelineTrackGenre[0];

            TrackGroupAttribute[] tga = ReflectionHelper.GetCustomAttributes <TrackGroupAttribute>(trackGroup.GetType(), true);
            for (int i = 0; i < tga.Length; i++)
            {
                if (tga[i] != null)
                {
                    genres = tga[i].AllowedTrackGenres;
                    break;
                }
            }

            Type[]      subTypes          = DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineTrack));
            List <Type> allowedTrackTypes = new List <Type>();

            for (int i = 0; i < subTypes.Length; i++)
            {
                TimelineTrackAttribute[] customAttributes = ReflectionHelper.GetCustomAttributes <TimelineTrackAttribute>(subTypes[i], true);
                for (int j = 0; j < customAttributes.Length; j++)
                {
                    if (customAttributes[j] != null)
                    {
                        for (int k = 0; k < customAttributes[j].TrackGenres.Length; k++)
                        {
                            TimelineTrackGenre genre = customAttributes[j].TrackGenres[k];
                            for (int l = 0; l < genres.Length; l++)
                            {
                                if (genre == genres[l])
                                {
                                    allowedTrackTypes.Add(subTypes[i]);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            return(allowedTrackTypes);
        }
Esempio n. 12
0
        /// <summary>
        /// Returns a list of Track types that are associated with the given Track Group.
        /// </summary>
        /// <param name="trackGroup">The track group to be inspected</param>
        /// <returns>A list of track types that meet the genre criteria of the given track group.</returns>
        public static List <Type> GetAllowedTrackTypes(TrackGroup trackGroup)
        {
            // Get all the allowed Genres for this track group
            TimelineTrackGenre[] genres = new TimelineTrackGenre[0];
            MemberInfo           info   = trackGroup.GetType();

            foreach (TrackGroupAttribute attribute in info.GetCustomAttributes(typeof(TrackGroupAttribute), true))
            {
                if (attribute != null)
                {
                    genres = attribute.AllowedTrackGenres;
                    break;
                }
            }

            List <Type> allowedTrackTypes = new List <Type>();

            foreach (Type type in DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineTrack)))
            {
                foreach (TimelineTrackAttribute attribute in type.GetCustomAttributes(typeof(TimelineTrackAttribute), true))
                {
                    if (attribute != null)
                    {
                        foreach (TimelineTrackGenre genre in attribute.TrackGenres)
                        {
                            foreach (TimelineTrackGenre genre2 in genres)
                            {
                                if (genre == genre2)
                                {
                                    allowedTrackTypes.Add(type);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            return(allowedTrackTypes);
        }
        /// <summary>
        /// Returns a list of Track types that are associated with the given Track Group.
        /// </summary>
        /// <param name="trackGroup">The track group to be inspected</param>
        /// <returns>A list of track types that meet the genre criteria of the given track group.</returns>
        public static List<Type> GetAllowedTrackTypes(TrackGroup trackGroup)
        {
            // Get all the allowed Genres for this track group
            TimelineTrackGenre[] genres = new TimelineTrackGenre[0];
            MemberInfo info = trackGroup.GetType();
            foreach (TrackGroupAttribute attribute in info.GetCustomAttributes(typeof(TrackGroupAttribute), true))
            {
                if (attribute != null)
                {
                    genres = attribute.AllowedTrackGenres;
                    break;
                }
            }

            List<Type> allowedTrackTypes = new List<Type>();
            foreach (Type type in DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineTrack)))
            {
                foreach (TimelineTrackAttribute attribute in type.GetCustomAttributes(typeof(TimelineTrackAttribute), true))
                {
                    if (attribute != null)
                    {
                        foreach (TimelineTrackGenre genre in attribute.TrackGenres)
                        {
                            foreach (TimelineTrackGenre genre2 in genres)
                            {
                                if (genre == genre2)
                                {
                                    allowedTrackTypes.Add(type);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            return allowedTrackTypes;
        }
        public static void ShowAddTrackContextMenu(TrackGroup trackGroup)
        {
            List<Type> trackTypes = trackGroup.GetAllowedTrackTypes();

            GenericMenu createMenu = new GenericMenu();

            // Get the attributes of each track.
            foreach (Type t in trackTypes)
            {
                MemberInfo info = t;
                string label = string.Empty;
                foreach (TimelineTrackAttribute attribute in info.GetCustomAttributes(typeof(TimelineTrackAttribute), true))
                {
                    label = attribute.Label;
                    break;
                }

                createMenu.AddItem(new GUIContent(string.Format("Add {0}", label)), false, addTrack, new TrackContextData(label, t, trackGroup));
            }

            createMenu.ShowAsContext();
        }
Esempio n. 15
0
        /// <summary>
        /// Get the Actors associated with this track. Can return null.
        /// In the case of MultiActors it will return the full list.
        /// </summary>
//         public List<Transform> Actors
//         {
//             get
//             {
//                 ActorTrackGroup trackGroup = TrackGroup as ActorTrackGroup;
//                 if (trackGroup != null)
//                 {
//                     List<Transform> actors = new List<Transform>() { };
//                     actors.Add(trackGroup.Actor);
//                     return actors;
//                 }
//
//                 MultiActorTrackGroup multiActorTrackGroup = TrackGroup as MultiActorTrackGroup;
//                 if (multiActorTrackGroup != null)
//                 {
//                     return multiActorTrackGroup.Actors;
//                 }
//                 return null;
//             }
//         }

        public bool GetActors(ref List <Transform> actorList)
        {
            actorList.Clear();

            TrackGroup      thisTrackGroup = this.GetTrackGroup();
            ActorTrackGroup trackGroup     = thisTrackGroup as ActorTrackGroup;

            if (trackGroup != null)
            {
                actorList.Add(trackGroup.Actor);
                return(true);
            }

            MultiActorTrackGroup multiActorTrackGroup = thisTrackGroup as MultiActorTrackGroup;

            if (multiActorTrackGroup != null)
            {
                actorList.AddRange(multiActorTrackGroup.Actors);
                return(true);
            }

            return(false);
        }
Esempio n. 16
0
        /// <summary>
        /// The TrackGroup associated with this Track. Can return null.
        /// </summary>
        public TrackGroup GetTrackGroup()
        {
            TrackGroup group = null;

            if (transform.parent != null)
            {
                // GetComponentInParent does not seem to work in Unity 5.3.
                // This means that the Cutscene hierarchy structure has to be strictly maintained.
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
                group = transform.parent.GetComponent <TrackGroup>();
#else
                group = transform.parent.GetComponentInParent <TrackGroup>();
#endif
                if (group == null)
                {
                    Debug.LogError("No TrackGroup found on parent.", this);
                }
            }
            else
            {
                Debug.LogError("Track has no parent.", this);
            }
            return(group);
        }
Esempio n. 17
0
        /// <summary>
        /// Returns a list of Track types that are associated with the given Track Group.
        /// </summary>
        /// <param name="trackGroup">The track group to be inspected</param>
        /// <returns>A list of track types that meet the genre criteria of the given track group.</returns>
        public static List <Type> GetAllowedTrackTypes(TrackGroup trackGroup)
        {
            var         trackGroupType = trackGroup.GetType();
            List <Type> allowedTrackTypes;

            if (_DicAllowedTrackTypes.TryGetValue(trackGroupType, out allowedTrackTypes))
            {
                return(allowedTrackTypes);
            }
#if BakeReflection
            // Get all the allowed Genres for this track group
            TimelineTrackGenre[] genres = new TimelineTrackGenre[0];

            TrackGroupAttribute[] tga = ReflectionHelper.GetCustomAttributes <TrackGroupAttribute>(trackGroupType, true);
            for (int i = 0; i < tga.Length; i++)
            {
                if (tga[i] != null)
                {
                    genres = tga[i].AllowedTrackGenres;
                    break;
                }
            }

            Type[] subTypes = GetAllSubTypes(typeof(TimelineTrack));
            allowedTrackTypes = new List <Type>();
            for (int i = 0; i < subTypes.Length; i++)
            {
                TimelineTrackAttribute[] customAttributes;

                var subType = subTypes[i];
                List <TimelineTrackAttribute> cache = null;
                if (_CacheTLTAttribute.TryGetValue(subType, out cache))
                {
                    //Debug.Log("++++" + trackGroupType.Name);
                    customAttributes = cache.ToArray();
                }
                else
                {
                    //Debug.Log(trackGroupType.Name);
                    customAttributes = ReflectionHelper.GetCustomAttributes <TimelineTrackAttribute>(subType, true);
                    _CacheTLTAttribute.Add(subType, new List <TimelineTrackAttribute>(customAttributes));
                }

                for (int j = 0; j < customAttributes.Length; j++)
                {
                    if (customAttributes[j] != null)
                    {
                        for (int k = 0; k < customAttributes[j].TrackGenres.Length; k++)
                        {
                            TimelineTrackGenre genre = customAttributes[j].TrackGenres[k];
                            for (int l = 0; l < genres.Length; l++)
                            {
                                if (genre == genres[l])
                                {
                                    allowedTrackTypes.Add(subType);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            _DicAllowedTrackTypes.Add(trackGroupType, allowedTrackTypes);
#endif
            return(allowedTrackTypes);
        }
 /// <summary>
 /// Create a new Track.
 /// </summary>
 /// <param name="trackGroup">The track group that this track will be attached to.</param>
 /// <param name="type">The type of the new track.</param>
 /// <param name="label">The name of the new track.</param>
 /// <returns>The newly created track. Reminder: Register an Undo.</returns>
 internal static TimelineTrack CreateTimelineTrack(TrackGroup trackGroup, Type type, string label)
 {
     GameObject timelineTrackGO = new GameObject(label, type);
     timelineTrackGO.transform.parent = trackGroup.transform;
     return timelineTrackGO.GetComponent<TimelineTrack>();
 }
Esempio n. 19
0
        public static List <Type> GetAllowedTrackTypes(TrackGroup trackGroup)
        {
#if PROFILE_FILE
            Profiler.BeginSample("DirectorRuntimeHelper.GetAllowedTrackTypes");
#endif // PROFILE_FILE
            // Get all the allowed Genres for this track group
            var         t = trackGroup.GetType();
            List <Type> allowedTrackTypes = null;
            if (_allowedTrackTypes.TryGetValue(t, out allowedTrackTypes))
            {
#if PROFILE_FILE
                Profiler.EndSample();
#endif // PROFILE_FILE
                return(allowedTrackTypes);
            }

            TimelineTrackGenre[] genres = new TimelineTrackGenre[0];
            var list   = ReflectionHelper.GetCustomAttributes <TrackGroupAttribute>(t, true);
            var length = list.Length;
            for (var i = 0; i < length; i++)
            {
                var attribute = list[i];

                if (attribute != null)
                {
                    genres = attribute.AllowedTrackGenres;
                    break;
                }
            }

            allowedTrackTypes = new List <Type>();
            var typeList = DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineTrack));
            length = typeList.Length;
            var lengthGenres = genres.Length;
            for (var i = 0; i < length; i++)
            {
                var type    = typeList[i];
                var list2   = ReflectionHelper.GetCustomAttributes <TimelineTrackAttribute>(type, true);
                var length2 = list2.Length;
                for (var j = 0; j < length2; j++)
                {
                    var attribute = list2[j];
                    if (attribute != null)
                    {
                        var list3   = attribute.TrackGenres;
                        var length3 = list3.Length;
                        for (var k = 0; k < length3; k++)
                        {
                            for (var x = 0; x < lengthGenres; x++)
                            {
                                if (list3[k] == genres[x])
                                {
                                    allowedTrackTypes.Add(type);
                                    break;
                                }
                            }
                        }

                        break;
                    }
                }
            }

            _allowedTrackTypes[t] = allowedTrackTypes;
#if PROFILE_FILE
            Profiler.EndSample();
#endif // PROFILE_FILE

            return(allowedTrackTypes);
        }
 public TrackContextData(string label, Type type, TrackGroup trackGroup)
 {
     this.Label = label;
     this.Type = type;
     this.TrackGroup = trackGroup;
 }
Esempio n. 21
0
        /// <summary>
        /// Returns a list of Track types that are associated with the given Track Group.
        /// </summary>
        /// <param name="trackGroup">The track group to be inspected</param>
        /// <returns>A list of track types that meet the genre criteria of the given track group.</returns>
        public static List <Type> GetAllowedTrackTypes(TrackGroup trackGroup)
        {
            // Get all the allowed Genres for this track group
            TimelineTrackGenre[] genres = new TimelineTrackGenre[0];
            MemberInfo           info   = trackGroup.GetType();
            {
                var __array1       = info.GetCustomAttributes(typeof(TrackGroupAttribute), true);
                var __arrayLength1 = __array1.Length;
                for (int __i1 = 0; __i1 < __arrayLength1; ++__i1)
                {
                    var attribute = (TrackGroupAttribute)__array1[__i1];
                    {
                        if (attribute != null)
                        {
                            genres = attribute.AllowedTrackGenres;
                            break;
                        }
                    }
                }
            }
            List <Type> allowedTrackTypes = new List <Type>();

            {
                var __array2       = DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineTrack));
                var __arrayLength2 = __array2.Length;
                for (int __i2 = 0; __i2 < __arrayLength2; ++__i2)
                {
                    var type = (Type)__array2[__i2];
                    {
                        {
                            var __array9       = type.GetCustomAttributes(typeof(TimelineTrackAttribute), true);
                            var __arrayLength9 = __array9.Length;
                            for (int __i9 = 0; __i9 < __arrayLength9; ++__i9)
                            {
                                var attribute = (TimelineTrackAttribute)__array9[__i9];
                                {
                                    if (attribute != null)
                                    {
                                        {
                                            // foreach(var genre in attribute.TrackGenres)
                                            var __enumerator15 = (attribute.TrackGenres).GetEnumerator();
                                            while (__enumerator15.MoveNext())
                                            {
                                                var genre = (TimelineTrackGenre)__enumerator15.Current;
                                                {
                                                    {
                                                        var __array18       = genres;
                                                        var __arrayLength18 = __array18.Length;
                                                        for (int __i18 = 0; __i18 < __arrayLength18; ++__i18)
                                                        {
                                                            var genre2 = (TimelineTrackGenre)__array18[__i18];
                                                            {
                                                                if (genre == genre2)
                                                                {
                                                                    allowedTrackTypes.Add(type);
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(allowedTrackTypes);
        }