Search Unity

Extending the editor

Discussion in 'Scripting' started by RingOfStorms, Jan 5, 2013.

  1. RingOfStorms

    RingOfStorms

    Joined:
    Oct 23, 2010
    Posts:
    584
    Hello today I just learned how to extend the editor and make better looking inspectors for my scripts. I'm making one for my charactermovement script and have hit a stump. In the CharacterMovement.cs there are AnimationClip's. Everything else up to now has been EditorGUILayout.FLoatField, but what kind of thing would I use for an animationclip?

    I've tried EditorGUILayout.ObjectFIeld - but could not get that to work. So how can I add my animation clips to my custom editor inspector?
     
  2. RingOfStorms

    RingOfStorms

    Joined:
    Oct 23, 2010
    Posts:
    584
    I guess the question didn't make sense.

    I'm making an inspector window for my character controller and can't figure out what to use for an animationclip. All my other values have been float fields and that was self explanatory. But what can I use to have my animationclips shown in the inspector window?
     
  3. RingOfStorms

    RingOfStorms

    Joined:
    Oct 23, 2010
    Posts:
    584
  4. Ereous

    Ereous

    Joined:
    Aug 29, 2012
    Posts:
    163
    Code (csharp):
    1. tar.myAnimationClip = (AnimationClip)EditorGUILayout.ObjectField(tar.myAnimationClip, typeof(AnimationClip), true);
    You could do something with a List of Strings instead since AnimationClips can be accessed by the string. animations[myListOfAnimations[indexLocation]].Play();
     
  5. RingOfStorms

    RingOfStorms

    Joined:
    Oct 23, 2010
    Posts:
    584
    Thanks, didn't think of casting the whole thing. :)