Advertisement
Guest User

Untitled

a guest
Apr 13th, 2017
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5.  
  6. public class RemoveScale : MonoBehaviour {
  7.  
  8.     class Postprocessing : AssetPostprocessor {
  9.  
  10.  
  11.         void OnPreprocessModel (){
  12.             ((ModelImporter)assetImporter).isReadable = false; //doesn't change anything
  13.         }
  14.  
  15.         void OnPostprocessModel (GameObject g){
  16.             Apply(g);
  17.         }
  18.    
  19.    
  20.         static int numRemoved = 0;
  21.  
  22.         void Apply(GameObject g)
  23.         {
  24.             Debug.Log ("Post Precessing:" + g);
  25.             List<AnimationClip> animationClipList = new List<AnimationClip>();
  26.             AnimationClip[] objectList = UnityEngine.Object.FindObjectsOfType (typeof(AnimationClip)) as AnimationClip[];
  27.             animationClipList.AddRange(objectList);
  28.  
  29.             foreach (AnimationClip animationClip in animationClipList)
  30.             {
  31.                 foreach (EditorCurveBinding curveBinding in AnimationUtility.GetCurveBindings(animationClip))
  32.                 {
  33.                     string name = curveBinding.propertyName.ToLower();
  34.  
  35.                     if (name.Contains("m_localscale"))
  36.                     {
  37.                         AnimationUtility.SetEditorCurve(animationClip, curveBinding, null);
  38.                         numRemoved += 1;
  39.                     }
  40.                 }
  41.             }
  42.         }
  43.     }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement