Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

BuildAssetBundles() error: An abnormal situation has occurred: the PlayerLoop internal

Discussion in 'Editor & General Support' started by Hickna, Mar 13, 2016.

  1. Hickna

    Hickna

    Joined:
    Mar 14, 2013
    Posts:
    26
    I'm trying to update my code to use the new method to create AssetBundles. Unfortunately by script I'm not having success.

    The error occurs in the "BuildPipeline.BuildAssetBundles("Assets/Resources/AssetBundle/", finalBuildMap);" line BUT all AssetBundles are created... The problem is that script stop to work and the next method is not called.


    Code (CSharp):
    1.  
    2.         private IEnumerator BuildAssetBundleNew() {
    3.             string[] assetPaths = AssetDatabase.GetAllAssetPaths();
    4.             for (int i = 0; i < assetPaths.Length; i++) {
    5.                 AssetDatabase.Refresh();
    6.                 yield return new WaitForSeconds(1f);
    7.                 if ((assetPaths[i].Contains("Materials") == false) &&
    8.                         (
    9.                             assetPaths[i].Contains("Assets/Resources/OBJ/")
    10.                             || assetPaths[i].Contains("Assets/Resources/Textures/")
    11.                             || assetPaths[i].Contains("Assets/Resources/PrefabColliders/")
    12.                         )
    13.                     ) {
    14.  
    15.                     UnityEngine.Object[] assets = AssetDatabase.LoadAllAssetsAtPath(assetPaths[i]);
    16.  
    17.                     //------------------------------------------------/*
    18.                     //BUILD MAP
    19.                     AssetBundleBuild[] buildMap = new AssetBundleBuild[1];
    20.                     buildMap[0] = new AssetBundleBuild();
    21.                     buildMap[0].assetBundleName = assets[0].name + ".unity3d5";
    22.                     string[] assetsToBuild = new string[1];
    23.                     assetsToBuild[0] = assetPaths[i];
    24.                     buildMap[0].assetNames = assetsToBuild;
    25.                     //------------------------------------------------*/
    26.                     AddBuildMap(buildMap);
    27.                     qtAbFiles++;
    28.                 }
    29.             }
    30.             yield return StartCoroutine(BuildAllAssetsFromBuildMap());
    31.             yield return new WaitForSeconds(1.0f);
    32.             EncryptAssetBundles();
    33.         }
    34.         //----------------------------------------------------------
    35.         private AssetBundleBuild[] finalBuildMap;
    36.         private void AddBuildMap(AssetBundleBuild[] buildMap) {
    37.             AssetBundleBuild[] aux = finalBuildMap;
    38.             finalBuildMap = new AssetBundleBuild[qtAbFiles+1];
    39.             Debug.Log("qtAbFiles" + qtAbFiles);
    40.             if (qtAbFiles == 0) {
    41.                 finalBuildMap[0] = new AssetBundleBuild();
    42.                 finalBuildMap[0] = buildMap[0];
    43.             } else {
    44.                 for (int i = 0; i < qtAbFiles; i++) {
    45.                     finalBuildMap[i] = new AssetBundleBuild();
    46.                     finalBuildMap[i] = aux[i];
    47.                  }
    48.                  finalBuildMap[qtAbFiles] = buildMap[0];
    49.             }
    50.         }
    51.  
    52.         //----------------------------------------------------------
    53.         private IEnumerator BuildAllAssetsFromBuildMap() {
    54.             yield return null;
    55.             BuildPipeline.BuildAssetBundles("Assets/Resources/AssetBundle/", finalBuildMap);
    56.         }
    57.         //----------------------------------------------------------
    58.    

    I tried a lot of ways to create an AssetBundle using this new method, but always I'm getting this error:

    "An abnormal situation has occurred: the PlayerLoop internal function has been called recursively. Please contact Customer Support with a sample project so that we can reproduce the problem and troubleshoot it.
    UnityEditor.BuildPipeline:BuildAssetBundles(String, AssetBundleBuild[])
    c__Iterator5:MoveNext() (at Assets/Scripts/NMABuilder.cs:352)"

    NOTE: In this case was created 4 AssetBundles, so the Iterator5:MoveNext could be some valuable information.

    Thanks in advance!
     
    Last edited: Mar 14, 2016
  2. Hickna

    Hickna

    Joined:
    Mar 14, 2013
    Posts:
    26
    Hi again...

    So, I tried using the very simple example from the Unity docs: http://docs.unity3d.com/ScriptReference/BuildPipeline.BuildAssetBundles.html
    The only difference is that I NEED to build it as I was doing with the deprecated method (BuildPipeline.BuildAssetBundle), I mean I need to create the AssetBundle without a Menu in the Editor, as I need to create a lot of AssetBundles every time. Using the old method I just drop all .obj files in some folder and generate thousand of AssetBundles with one click.

    Anyway, using the Unity example the same error occurs.

    Here is the simple class created to build a simple AssetBundle using the new method BuildAssetBundles:

    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using UnityEditor;
    3. using UnityEngine;
    4.  
    5. public class BuildUnity5Test: MonoBehaviour {
    6.    
    7.      void Start() {
    8.         // Create the array of bundle build details.
    9.         AssetBundleBuild[] buildMap = new AssetBundleBuild[1];
    10.  
    11.         buildMap[0] = new AssetBundleBuild();
    12.         buildMap[0].assetBundleName = "kwas015";
    13.         string[] assetsToBuild = new[] { "Assets/Resources/PrefabColliders/kwas015.prefab"};
    14.         buildMap[0].assetNames = assetsToBuild;
    15.  
    16.         // Put the bundles in a folder called "AssetBundles" within the Assets folder.
    17.         BuildPipeline.BuildAssetBundles("AssetBundles", buildMap);
    18.     }
    19. }
    20. #endif
    The error persists:

    NOTE: The AssetBundle is created but as I said in the main post, the script stops and the system didn't work as should works.
    assetbundle_created.PNG


    Please! Can you help me? Thanks!
     
  3. Deleted User

    Deleted User

    Guest

    Please don't use BuildPipeline.BuildAssetBundles() at play mode
     
    unity_udHZ02M1kFENww likes this.