BabylonJS / BabylonToolkit

Home of the community maintained Unity & Unreal exporters for Babylon.js
179 stars 47 forks source link

Uncaught TypeError: BABYLON.SceneManager.LoadScene is not a function #11

Closed Jedarch closed 5 years ago

Jedarch commented 5 years ago

Typescript compiles the scene in Unity but won't load due to the uncaught type error. Please see attached for reference. Thank You.

LoadSceneFunction

MackeyK24 commented 5 years ago

Seems like the babylon.manager.js is not loaded yet...

Try and replace the bottom loader script with this:

            // ..
            // Default babylon scene loader
            // ..
            var defaultSceneLoader = function(root, name) {
                scene = null;
                loaded = false;
                showSceneLoader();
                executeSceneLoader(root, name);            
            };
            window.addEventListener("DOMContentLoaded", function() {
                defaultSceneLoader(scenepath, scenename);
            });

See if that works... I changed it to that in the latest classic edition updates :)

Jedarch commented 5 years ago

Thank you for your reply Mackey. I made the changes you suggested; same result. If you take a look at the attached image you will notice that it appears not all of the scripts in the scripts folder are being read by the index.html file (even though they are called via the section). Also, off to the right hand side you will see under DOMContent that the function is not being passed to the window. Maybe the code should be added in the game.html file in the template folder, so when the program compiles, it will be recognized. Not sure how the process works.

LoadSceneFunction2

Jedarch commented 5 years ago

Update, I was able to get it to work with a few tweaks. Not certain which of them made the difference. One: I changed the settings in the compiler options back to the default: allowJS = false; declarations = true;. Two: I unchecked the minify script option in the compiler settings for the exporter. Three: I added your code to the game.html file in the template folder. I am assuming that the compiler recognizes your code during compilation and ties together all the necessary references when it outputs to the Export folder. I'll wait for your input on this before closing this issue. Thanks again Mackey!!!

MackeyK24 commented 5 years ago

Hmmm... It works perfect on my machine... Can you try another browser ... like chrome...

And make sue you get the latest toolkit.

On Sat, Jul 13, 2019 at 7:25 AM Jedarch notifications@github.com wrote:

Thank you for your reply Mackey. I made the changes you suggested; same result. If you take a look at the attached image you will notice that it appears not all of the scripts in the scripts folder are being read by the index.html file (even though they are called via the section). Also, off to the right hand side you will see under DOMContent that the function is not being passed to the window. Maybe the code should be added in the game.html file in the template folder, so when the program compiles, it will be recognized. Not sure how the process works.

[image: LoadSceneFunction2] https://user-images.githubusercontent.com/52780367/61174648-214b9600-a571-11e9-8aaf-743328fb85ee.jpg

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/BabylonJS/UnityExporter/issues/11?email_source=notifications&email_token=ABGH7JZRP42ZAKCDKBAXZB3P7IFYTA5CNFSM4ICX7MZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ3V6EA#issuecomment-511139600, or mute the thread https://github.com/notifications/unsubscribe-auth/ABGH7J3TVCMZL7YBOUB7R23P7IFYTANCNFSM4ICX7MZA .

Jedarch commented 5 years ago

It works fine now; see my previous comment. Works only when opening with Microsoft Edge browser when using local host. Google Chrome creates some additional error messages. I don't expect this to be the case though when I put my content on the web. Your additional code works only when added to the game.html file prior to compiling. That being said, I think either my config file needed to be changed as I mentioned in my previous post, and/or the minify script check box needs to be left empty on the compiler prior to exporting. Your code is what did the trick though. I spent days trying to figure out why it wasn't working. Wouldn't have figured it out without your input. Now I can move onto your intro tutorial video. I'd be glad to see additional tutorial videos when they are released on the Coming Soon section of your babylontoolkit.com website. Great work on your part. Thank you very much for your time and help to the BabylonJS and Unity3D communites!!!