/** * @brief Creates a FTrack. * @param T type of event this track will hold */ public static FTrack Create <T>() where T : FEvent { Type evtType = typeof(T); string evtName = evtType.Name; GameObject trackGO = new GameObject(evtName); Type trackType = typeof(FTrack); object[] customAttributes = evtType.GetCustomAttributes(typeof(FEventAttribute), false); if (customAttributes.Length > 0) { trackType = ((FEventAttribute)customAttributes[0]).trackType; } FTrack track = (FTrack)trackGO.AddComponent(trackType); //track._evtType = evtType; //track._evtTypeStr = evtType.ToString(); track.SetEventType(evtType); track.CacheMode = track.RequiredCacheMode; // track.CacheType = track.DefaultCacheType(); // CEvent evt = CEvent.Create<T>( range ); // // track.Add( evt ); // // track._timeline = timeline; // track.SetId( id ); return(track); }
/** * @brief Creates a FTrack. * @param T type of event this track will hold */ public static FTrack Create <T>() where T : FEvent { Type evtType = typeof(T); string evtName = evtType.Name; GameObject trackGO = new GameObject(evtName); Type trackType = typeof(FTrack); #if NETFX_CORE System.Attribute[] customAttributes = new List <System.Attribute>(evtType.GetTypeInfo().GetCustomAttributes(typeof(FEventAttribute), false)).ToArray(); #else object[] customAttributes = evtType.GetCustomAttributes(typeof(FEventAttribute), false); #endif if (customAttributes.Length > 0) { trackType = ((FEventAttribute)customAttributes[0]).trackType; } FTrack track = (FTrack)trackGO.AddComponent(trackType); track.SetEventType(evtType); track.CacheMode = track.RequiredCacheMode; track.SetOwner(trackGO.transform); return(track); }