Search Unity

Question Navigate to and select AnimationState through code?

Discussion in 'Editor & General Support' started by CAJJI, Mar 14, 2023.

  1. CAJJI

    CAJJI

    Joined:
    Jul 20, 2016
    Posts:
    4
    An example of what I'm trying to attempt is similar to Debug.Log(string, CONTEXT), where clicking the debug log focuses the context (i.e GameObject).

    I have an AnimationController with a large amount of AnimationStates (and sub-state machines), and an editor script that searches for a specified state in the controller. Is it possible to automatically select the resulting state in the Inspector and/or Animator window?

    1. Code searches for desired state in controller
    2. The path to the desired state is logged in the console
    3. With animator open, navigate to the resulting state's sub-state machine and select the state
     
    Last edited: Mar 14, 2023
    Kurt-Dekker likes this.
  2. CAJJI

    CAJJI

    Joined:
    Jul 20, 2016
    Posts:
    4
    I figured out a semi-solution. I wasn't able to navigate in the Animator, but I was able to select the resulting state using:
    Selection.SetActiveObjectWithContext(state, state);