Example #1
0
        public void ShowTrackMenu(FTrack track)
        {
            if (_fcEventTypes == null)
            {
                _fcEventTypes = new Type[0];
                Type[] allTypes = typeof(FEvent).Assembly.GetTypes();

                foreach (Type type in allTypes)
                {
                    if (type.IsSubclassOf(typeof(FEvent)) && !type.IsAbstract)
                    {
                        object[] attributes = type.GetCustomAttributes(typeof(FEventAttribute), false);
                        if (attributes.Length == 1)
                        {
                            ArrayUtility.Add <Type>(ref _fcEventTypes, type);
                        }
                    }
                }
            }

            GenericMenu menu = new GenericMenu();

            foreach (Type t in _fcEventTypes)
            {
                TimelineMenuData param = new TimelineMenuData();
                param.track = track; param.evtType = t;
                object[] attributes = t.GetCustomAttributes(typeof(FEventAttribute), false);
                menu.AddItem(new GUIContent(((FEventAttribute)attributes[0]).menu), false, AddEventToTrack, param);
            }
            menu.ShowAsContext();
        }
Example #2
0
        private void AddEventToTrack(object obj)
        {
            TimelineMenuData menuData = (TimelineMenuData)obj;
            GameObject       go       = new GameObject(menuData.evtType.ToString());
            FEvent           evt      = (FEvent)go.AddComponent(menuData.evtType);

            menuData.track.Add(evt);

            SequenceEditor.Refresh();
        }