示例#1
0
        private static void ShowCreationContext(InAudioEventNode audioevent)
        {
            var menu = new GenericMenu();

            List <EventActionExtension.ActionMeta> actionList = EventActionExtension.GetList();

            foreach (EventActionExtension.ActionMeta currentType in actionList)
            {
                Type newType  = AudioEventAction.ActionEnumToType(currentType.ActionType);
                var  enumType = currentType.ActionType;
                menu.AddItem(new GUIContent(currentType.Name), false, f =>
                             AudioEventWorker.AddEventAction(audioevent, newType, enumType), currentType);
            }
            menu.ShowAsContext();
        }
        public static void ReplaceActionDestructiveAt(InAudioEventNode audioEvent, EventActionTypes enumType, int toRemoveAndInsertAt)
        {
            //A reel mess this function.
            //It adds a new component of the specied type, replaces the current at the toRemoveAndInsertAt index, and then deletes the old one
            float  delay         = audioEvent._actionList[toRemoveAndInsertAt].Delay;
            Object target        = audioEvent._actionList[toRemoveAndInsertAt].Target;
            var    newActionType = AudioEventAction.ActionEnumToType(enumType);

            InUndoHelper.Destroy(audioEvent._actionList[toRemoveAndInsertAt]);
            //UndoHelper.RecordObject(audioEvent, "Event Action Creation");

            audioEvent._actionList.RemoveAt(toRemoveAndInsertAt);
            var added = AddEventAction(audioEvent, newActionType, enumType);

            added.Delay  = delay;
            added.Target = target; //Attempt to set the new value, will only work if it is the same type

            audioEvent._actionList.Insert(toRemoveAndInsertAt, added);
            audioEvent._actionList.RemoveLast();
        }
示例#3
0
        private static void ChangeAction(InAudioEventNode audioEvent, AudioEventAction action, EventActionTypes newEnumType)
        {
            for (int i = 0; i < audioEvent._actionList.Count; ++i)
            {
                if (audioEvent._actionList[i] == action)
                {
                    Type oldType = AudioEventAction.ActionEnumToType(action._eventActionType);
                    Type newType = AudioEventAction.ActionEnumToType(newEnumType);


                    if (oldType != newType)
                    {
                        InUndoHelper.DoInGroup(() => AudioEventWorker.ReplaceActionDestructiveAt(audioEvent, newEnumType, i));
                    }
                    else
                    {
                        InUndoHelper.RecordObject(action, "Change Event Action Type");
                        action._eventActionType = newEnumType;
                    }

                    break;
                }
            }
        }