AddSelectedAnimationsToRig

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Description)
Line 1: Line 1:
==Description==
 
A wizard to add multiple animations to a rig in one go.
 
 
 
Author: Jeff Murray (psychicparrot)
 
Author: Jeff Murray (psychicparrot)
  
 
----
 
----
  
Usage
+
==Description==
Select all the animations, then open the wizard and select a rig to apply them to. Hit the button. Boom! You're done!
+
A wizard to add multiple animations to a rig in one go.
  
----
+
==Usage==
 +
Place this script in YourProject/Assets/Editor and a menu item will automatically appear in the Custom menu after it is compiled.
  
Place this script in YourProject/Assets/Editor and a menu item will automatically appear in the Custom menu after it is compiled.
+
Select all the animations, then open the wizard and select a rig to apply them to. Hit the button. Boom! You're done!
  
 
----
 
----
  
C# - SelectMainCamera.cs
+
==C# - SelectMainCamera.cs==
  
[csharp]using UnityEngine;
+
<csharp>using UnityEngine;
 
using UnityEditor;
 
using UnityEditor;
  
Line 63: Line 61:
 
     }   
 
     }   
 
}
 
}
[/csharp]
+
</csharp>

Revision as of 00:39, 7 May 2009

Author: Jeff Murray (psychicparrot)


Description

A wizard to add multiple animations to a rig in one go.

Usage

Place this script in YourProject/Assets/Editor and a menu item will automatically appear in the Custom menu after it is compiled.

Select all the animations, then open the wizard and select a rig to apply them to. Hit the button. Boom! You're done!


C# - SelectMainCamera.cs

<csharp>using UnityEngine; using UnityEditor;

public class AddSelectedAnimationsToRig : ScriptableWizard {

   public GameObject rig;
  
   [MenuItem ("Custom/Add selected animations to rig")]
   static void DoSet()
   {
       ScriptableWizard.DisplayWizard("Add selected animations to rig", typeof(AddSelectedAnimationsToRig), "Set animations...");
      
   }
  
   void OnWizardUpdate()
   {
   	        
       if(!rig.animation){

// Disable the wizard create button isValid = false;

// And tell the user why helpString = "Choose a rig with an animation component already attached to it.";

       } else {
       	        helpString = "Add selected animations to the rig...";
       }
       
   }
  
   void OnWizardCreate()
   {
       Object[] objs = Selection.GetFiltered(typeof(Animation), SelectionMode.Unfiltered);
      
       foreach (Animation an in objs)
       {

rig.animation.AddClip(an.clip,an.name);

       }
       
       Selection.activeObject=rig;
       
       // bit of clean up
       objs=null;
       rig=null;
       
   }   

} </csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox