Carousell menu shows no pictures when new assetbundle is loaded
Hello everyone!
I got a carousell menu I bought. It is this one. https://assetstore.unity.com/packages/tools/gui/carousel-menu-144689
I set up assetbundles that are loaded if the user decides so by pressing a button. The carousell menu consists also of buttons. I use sprites to give the buttons another look. If another assetbundle is loaded the sprites should also change. Now I got this weird situation where everything works as inteded when I load an assetbundle for the first time. As soon as I load a second assetbundle the sprites are not displayed on the buttons.
The coding for the sprites
foreach (var name in requestAssets.allAssets)
{
cellController.AddCell(); //Add Cell to Menu
var f_menuItem = GameObject.Find("Content").transform.GetChild(counter).GetComponent<Image>(); //Getting image of button
Sprite sprite = loadedAssetBundle.LoadAsset<Sprite>("Picture_"+name.name); //Load Picture from AssetBundle
f_menuItem.sprite = sprite;
counter++;
}
noOfLoadedCells = counter;
counter = 0; //Rücksetzen counter
The code to remove the cells as another bundle is loaded
for (int i = 0; i < noOfLoadedCells; i++)
{
cellController.RemoveCell(0);
//var cellChild = GameObject.Find("Content").transform.GetChild(i);
//Destroy(cellChild);
//Debug.Log("Destroyed " + cellChild.name);
}
In RemoveCell() I need to use 0 since one cell might remain at the end. If I do not use 0 (but i) one cell remains and with the next call of AddCells() an additional cell is generated.
Funny enough if I load assetbundle1 and then assetbundle 2 ONE of the sprites shows up. If I load assetbundle 2 followed by assetbundle1 or assetbundle2 NO sprites shows. But as said: All show up when the assetbundle is loaded the very first time.
Any idea where to look?