Search Unity

AnimationUtility woes

Discussion in 'Immediate Mode GUI (IMGUI)' started by StarManta, Aug 31, 2015.

  1. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    I'm using the AnimationUtility to modify animation curves as they're being edited. However, when I do this - using AnimationUtility.SetEditorCurve - there's no feedback whatsoever on the window. Even clicking in the window doesn't update the animation displayed - it seems to only update when the user tabs back and forth between the curve/dopesheet view. Is there a way to force it to repaint completely?

    In addition, it would be really nice to be able to see (in script) which AnimationClip the user is editing right now. But that does not appear to be possible.

    Finally, modifying curves through SetEditorCurve seems to be incredibly glitchy. Sometimes the curves are changed - sometimes they aren't. Sometimes they *revert* to their previous state after I change them in script. Has anyone ever actually successfully used this API? Any pointers? It's a nightmare.
     
  2. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    1) Just force a repaint. If it is your own Editor Window call repaint. If not you can try to grab the one in focus and repaint.
    Code (CSharp):
    1. EditorWindow.focusedWindow.Repaint();
    2) You are able to track which control is currently being modified using the following two values. Keep in mind all Unity uses to keep track of the controls is an int. That int is set in the order that they are renderered.
    Code (CSharp):
    1. EditorGUIUtility.hotControl
    2. EditorGUIUtility.keyboardControl
    3) I have never used this so I am not sure.

    Cheers,
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    No, I need to force the animation window to repaint, not my own editor window. Is there a way to get the reference to the animation window?
     
  4. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    That's why I said if not grab the one you want and repaint it. You have the power to get anything that Unity draws. Since the type is internal you can't directly search for it. You can however grab every Editor Window type and filter the results. Store that instance and refresh it when need be.