Scene Asset Bundle - LoadLevelAdditive and OnLevelWasLoaded

This question has 2 parts.

First :

Is there a way to get the index of a scene loaded from an assetBundle ? At runtime ?

Second :

Is the function OnLevelWasLoaded called when you use the LoadLevelAdditive ?

Now, the reason I want to know this is because i’m using a script which deals with scene changes, it also handles showing and hiding the loading screen when needed. As of now, I was just calling the “Show” method (for the loading screen) before loading a scene, and then, in that scene, I had a script that would “Hide” it from the Start. Let’s face it, this isn’t… well encapsulated. And it’s kind of a pain to need a script in each scene to call the loading screen off.

I recently discovered the OnLevelWasLoaded method, which would actually achieve what I want.
Problem is, some of these scenes are bundled. (Not in the project settings), and I have no way of telling which index they are. Hence the First question.

After thinking for a bit, I thought “Well, I don’t actually need to know which scene is loaded, I just need to dismiss the screen when a scene is loaded, Any”… well, ends up that’s not exactly true. There’s some scenes I am loading additively (is that a word ?) And I don’t necessarily want the “Hide” function to be called at those times - Well, sure, right now it’s not doing much, but it might eventually do. Hence the Second question

If it’s not fired, then I could work with this workaround.

Thank you for your time, hope I was clear enough.


I just thought about something, Is it possible to get the name instead of the index ? and then get the index with the name ?

EDIT 2 :

I found part of an answer to that last question Here

Says you can Check names with assetBundle.contains, but not really get the name without knowing it first.

This is what you’re looking for. :slight_smile: