Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Why can't delete event from a animation clip?

Discussion in 'Animation' started by alexhy, Jun 4, 2014.

  1. alexhy

    alexhy

    Joined:
    Nov 21, 2013
    Posts:
    26
    Add event to an animation like this:
    AnimationEvent hitEvent = new AnimationEvent();
    hitEvent.time = 1.2f;
    hitEvent.functionName = "bt_hit";
    model.animation.GetClip("BattleAtk").AddEvent(hitEvent);

    but I can't delete event from clip "BattleAtk" or clear all event from this clip and can't judgement this clip have added this event,
    so cause some problems:
    sometimes the clip event is lost, but I can't judgement to add new event.if I add event every times. the event will be multiple added,it is not wished.

    I wish add three function to clip:
    1.clip.deleteEvent(functionName),
    2.clip.clearAllEvents(),
    3.clip.haveEvent(functionName)
     
  2. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Hi Alexy,

    I agree that we should add this functionality.

    But I'm not sure that deleting an Event by function name is a good idea, you can have different event at different time with the same function name. Doing such would clear all event that match this criteria.

    I would rather prefer to add a new property on AnimationClip call events, with this you can query all events, delete event and clear them all.

    AnimationClip.events

    would this solve your issue?
     
    rakkarage likes this.
  3. alexhy

    alexhy

    Joined:
    Nov 21, 2013
    Posts:
    26
    query all events, delete event and clear them all.very good!!
     
  4. alexhy

    alexhy

    Joined:
    Nov 21, 2013
    Posts:
    26
    Which version will be added these three method??
     
  5. alexhy

    alexhy

    Joined:
    Nov 21, 2013
    Posts:
    26
    Hello?
     
  6. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Hi Alexhy,

    Sorry I was on Vacation, this new feature should be available in 5.0, in the next alpha/beta release.
     
    BryanO and rakkarage like this.
  7. multimediamarkers

    multimediamarkers

    Joined:
    Feb 17, 2016
    Posts:
    49
    I still can't find any delete event function on the AnimationClip object? Is it not implemented in Unity?