コード例 #1
0
 /// <summary>
 /// Put the metadata in the container.
 /// </summary>
 public void FillWith(AnimatorMetadata _contents, StateMachineExtender _stateMachineExtender)
 {
     contents             = _contents;
     stateMachineExtender = _stateMachineExtender;
     onceFilled?.Invoke();
     onceFilled = null;
 }
    /// <summary>
    /// Make sure the animator controller has a metadata pusher on layer 0, and
    /// associate it with the appropriate index in the metadata lookup table.
    /// </summary>
    private static void RegisterAnimatorController(AnimatorController animatorController, int index)
    {
        StateMachineBehaviour[] layer0Behaviours = animatorController.layers[0].stateMachine.behaviours;
        StateMachineExtender    metadataPusher   = null;

        for (int i = 0; i < layer0Behaviours.Length; i++)
        {
            if (layer0Behaviours[i] is StateMachineExtender)
            {
                metadataPusher = (StateMachineExtender)layer0Behaviours[i];
                break;
            }
        }
        if (metadataPusher == null)
        {
            metadataPusher = animatorController.layers[0].stateMachine.AddStateMachineBehaviour <StateMachineExtender>();
        }
        metadataPusher.tableIndex_SetAutomatically = index;
        EditorUtility.SetDirty(animatorController);
    }