Search Unity

Resolved How to get name of animator controller

Discussion in 'Animation' started by tawdry, Dec 28, 2022.

  1. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,357
    Hello I am just trying to get the name of the animator controller on a model but this code just returns the avatar name instead.
    For instance if I wanted to be able to slot in a animator controller through public expose in code;
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class crawl : MonoBehaviour
    6. { public Animator anim;
    7.     // Start is called before the first frame update
    8.  
    9.     void Start()
    10.     {
    11.         anim=GetComponent<Animator>();
    12.     Debug.Log(anim );
    13.  
    14.     }
    15.  
    16.     // Update is called once per frame
    17.     void Update()
    18.     {
    19.      
    20.     }
    21. }
    22.  
     
    Last edited: Dec 28, 2022
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    anim.runtimeAnimatorController.name
     
    exitshadow likes this.
  3. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,357
    Aha thx.