title: Unity: slowdown caused by something?
body: <p>I figured out how to create an asset bundle containing an animation clip, and then loading that animation clip in another project and then overriding existing animation clip with the new one via a script. Basically the goal is to allow users to edit animations.</p>
  
  <p>Everything now thankfully works, but for some reason there is a slowdown. I am not sure what is causing the slowdown when everything is being loaded in start frame:</p>
  
  <p>Here is my code:</p>
  
  
  
  <pre class="lang-c# prettyprint-override"><code>protected Animator animator;
  protected AnimatorOverrideController animatorOverrideController;
  protected AnimationClipOverrides clipOverrides;
  
  void Start()
  {
      animator = GetComponent&lt;Animator&gt;();
      animatorOverrideController = new AnimatorOverrideController(animator.runtimeAnimatorController);
      animator.runtimeAnimatorController = animatorOverrideController;
  
      clipOverrides = new AnimationClipOverrides(animatorOverrideController.overridesCount);
      animatorOverrideController.GetOverrides(clipOverrides);
      LoadAnimation();
  }
  
  public void LoadAnimation()
  {
      StartCoroutine(LoadAnimClip());
  }        
  
  IEnumerator LoadAnimClip(string )
  {
      var FilePath = Application.streamingAssetsPath + "/Characters/Sonic/Animations/stand";
  
      var req = AssetBundle.LoadFromFileAsync(FilePath);
      yield return req;
      AssetBundle animationAsset = req.assetBundle;
  
      AnimationClip animation = animationAsset.LoadAsset&lt;AnimationClip&gt;("Stand") as AnimationClip;
  
      clipOverrides["Idle"] = animation;
      animatorOverrideController.ApplyOverrides(clipOverrides);
  
  }
  </code></pre>
  
  <p>If you are wondering what is animationclipoverrides, here is the class:</p>
  
  <pre class="lang-c# prettyprint-override"><code>public class AnimationClipOverrides : List&lt;KeyValuePair&lt;AnimationClip, AnimationClip&gt;
  {
      public AnimationClipOverrides(int capacity) : base(capacity) { }
  
      public AnimationClip this[string name]
      {
          get { return this.Find(x =&gt; x.Key.name.Equals(name)).Value; }
          set
          {
              int index = this.FindIndex(x =&gt; x.Key.name.Equals(name));
              if (index != -1)
                  this[index] = new KeyValuePair&lt;AnimationClip, AnimationClip&gt;(this[index].Key, value);
          }
      }
  }
  </code></pre>