Search Unity

Animator StateMachineBehaviour multiple components of same type collapse in inspector

Discussion in 'Animation' started by ScreenJuice, Aug 13, 2020.

  1. ScreenJuice

    ScreenJuice

    Joined:
    Aug 4, 2013
    Posts:
    11
    I am using StateMachineBehaviours in order to change animator parameters depending on the current animator state. In order to do this I attach a simple StateMachineBehviour to a state that changes a parameter when entering the state. In order to chnage multiple paramters of the same data type (float or bool in my case) with one state, I attach multiple StatemachineBehaviours of the same type to a state. The Behaviour lets me then specify the name of the parameter i want to change and the target value as seen here:

    StateMachineBehaviour Code for changing float parameter (problem occures for all types of statemachine behaviours as long as the same script is attached multiple times to the same state):

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class SateDrivenVariableSetting_Float : StateMachineBehaviour
    {
    public string parameterName;
    public float value;

    //OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
    animator.SetFloat(parameterName, value);
    }
    }

    In the past (before Unity 2019.4) that has worked perfectly fine. However, in new Unity versions (also in all 2020.x version so far) all behaviours of the same type are collapsed in the inspector. I can still add multiple behavipurs that are supposed to change a float, however, I can only edit the behaviour's parameters of the first behaviour i have added to the state.
    This bug occured simultaneously to another bug related to the Animator, where selecting some states would leave the Inspector blank. While that has not yet been fixed, this workaround solve the issue. However, the StatemachineBehaviour bug cannot be fixed with [this workaround][1].
    Does somebody else have this issue or knows a workaround for this problem? This is immensly disrupting my current work as it is nearly impossible to integrate animations in a way that is required for my project. It is also not possible for me to simply rollback to an earlier version of Unity due to me using HDRP and other packages.

    I really hope someone can help me with this issue!

    [1]: https://forum.unity.com/threads/animator-bug.906932/
     

    Attached Files:

  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Just change the fields to arrays so you only need one script of each type.
     
    Marrlie likes this.
  3. David_296

    David_296

    Joined:
    Jun 26, 2015
    Posts:
    5
    Same here, i've already sent a bug report
     
  4. DL_se

    DL_se

    Joined:
    Nov 29, 2020
    Posts:
    5