Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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,356
    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,397
    anim.runtimeAnimatorController.name
     
  3. tawdry

    tawdry

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