0
\$\begingroup\$

I need to add some animation events or copy them from other models. So I decided to make a EditorWindow. Unfortunately there's not much information about this, and I'm stuck in here.

void OnGUI() {
    GUILayout.Label("Source Object contains Animation Clips", EditorStyles.boldLabel);
    sourceObject = (GameObject) EditorGUILayout.ObjectField(sourceObject, typeof(Object), false);

    if(GUILayout.Button("Copy")) {
        if(sourceObject == null) {
            throw new System.NullReferenceException("Source Object is missing.");
        }

        // Do Copy here

    }
}

What I need to do is:

  1. Extract all animation clips from the selected model(fbx) - it's the source object
  2. Select "AnimationClip" to want to copy. Note that AnimationClip in here is not inside of model, it's seperated AnimationClip that duplicated from original model because basically animation clip from imported model is read-only, so I have to duplicate to update it.

How do I get animation clips from selected fbx model with ObjectField? Any advice will very appreciate it.

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

I solved this by getting Animation Clip directly as input, not GameObject.

sourceClip = (AnimationClip) EditorGUILayout.ObjectField(sourceClip, typeof(AnimationClip), false);

Now I can access any information about AnimationEvents, Curves and others.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .