Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by barrett-and · Jul 14, 2017 at 02:45 AM · javascriptwebglhtmlkongregateloader

"ReferenceError: UnityLoader.js is not defined" on Kongregate

Hello Unity,

I'm trying to get a WebGL Build of a unity project up and running on kongregate, but I've got an issue: All that appears when I run it on the site is a black screen I have scrollbars for. The build works fine if I run it on a private server or open it in a browser from file inspector, but for some reason Kongregate is being uncooperative. Whenever the build plays it displays the same error of "ReferenceError: UnityLoader.js is not defined" even though UnityLoader.js is specifically referenced in the index.html. I have tried asking the Kongregate forums for a solution, but they have been silent, if anybody here has a solution let me know. Below is the code for index.html and the errors for when I run the game on kongregate.

 <!doctype html>
 <html lang="en-us">
 <head>
   <meta charset="utf-8">
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <title>Unity WebGL Player | VistaLights</title>
   <style>
     * {
       margin: 0;
       padding: 0;
     }
 
     #gameContainer canvas {
       display:block;
     }
 
     div#webgl-content {
       position: absolute;
       top: 50%;
       left: 50%;
       -webkit-transform: translate(-50%, -50%);
       transform: translate(-50%, -50%);
     }
 
     div#loadingBox {
       width: 100%;
       height: 0px;
       position: absolute;
       top: 50%;
       margin-top: 137px;
       text-align: center;
     }
 
     div#icon {
       width: 300px;
       height: 310px;
       position: absolute;
       top: 50%;
       left: 50%;
       margin-top: -185px;
       margin-left: -150px;
       background-image: url("Template/anthill.png");
       background-repeat: no-repeat;
       box-shadow: 1px 1px 5px #141414;
     }
 
     div#box {
       width: 328px;
       height: 367px;
       position: absolute;
       top: 50%;
       left: 50%;
       margin-top: -199px;
       margin-left: -164px;
       background: #222;
       box-shadow: 1px 1px 5px #000;
     }
 
     div#bgBar {
       display: none;
       position: absolute;
       width: 300px;
       margin-left: -150px;
       left: 50%;
       height: 18px;
       background-color: #882121;
       box-shadow: 1px 1px 5px #111;
     }
 
     div#progressBar {
       display: none;
       left: 50%;
       position: absolute;
       margin-left: -150px;
       width: 0px;
       height: 18px;
       background-color: #dc4241;
     }
 
     p#loadingInfo {
       color: #fff;
       letter-spacing: 1px;
       position: absolute;
       width: 100%;
       font-family: sans-serif;
       text-align: center;
       top: 50%;
       font-size: 11px;
       font-weight: 500;
       margin-top: 140px;
       text-shadow: 0px 0px 5px #000;
     }
 
     div#spinner {
       position: absolute;
       height: 18px;
       left: 50%;
       margin-left: -150px;
       width: 300px;
       position: relative;
       overflow: hidden;
       background-color: #882121;
       box-shadow: 1px 1px 5px #111;
     }
 
     div#spinner:before {
       display: block;
       position: absolute;
       content: "";
       width: 150%;
       margin-left: -10px;
       height: 10px;
       background-color: #e85352;
       transform: rotate(-5deg);
       animation: loading 1s linear infinite;
     }
 
     @keyframes loading {
       from {
         top: -185%
       }
       to {
         top: 225%
       }
     }
   </style>
 
   <script src='https://cdn1.kongregate.com/javascripts/kongregate_api.js'>
   </script>
 
   <script src="Build/UnityLoader.js"></script>
   <script>
     function UnityProgress(gameInstance, progress) {
       var container = document.getElementById('gameContainer');
       if (container) document.body.style.background = container.style.background;
 
       if (!gameInstance.Module) {
          return;
       } else if (progress === "complete") {
         document.getElementById("loadingBox").style.display = "none";
         document.getElementById("icon").style.display = "none";
         document.getElementById("loadingInfo").style.display = "none";
         document.getElementById("box").style.display = "none";
         return;
       } else if (progress == 1) {
         document.getElementById("loadingInfo").innerHTML = "PROCESSING...";
         document.getElementById("spinner").style.display = "inherit";
         document.getElementById("bgBar").style.display = "none";
         document.getElementById("progressBar").style.display = "none";
       } else if (progress > 0) {
         document.getElementById("progressBar").style.width = 300 * progress + "px"
         document.getElementById("loadingInfo").innerHTML = Math.round(progress * 100) + "%";
         document.getElementById("spinner").style.display = "none";
         document.getElementById("bgBar").style.display = "block";
         document.getElementById("progressBar").style.display = "inherit";
       }
     }
     var gameInstance = UnityLoader.instantiate("gameContainer", "Build/VistaBuild.json", {
       onProgress: UnityProgress,
       Module: {
         onRuntimeInitialized: function() { UnityProgress(gameInstance, "complete") }
       }
     });
   </script>
 </head>
 <body>
   <div id="webgl-content" style="width: 960px; height: 540px">
     <div id="gameContainer" style="width: 960px; height: 540px"></div>
   </div>
   <div id="box"></div>
   <div id="loadingBox">
     <div id="spinner"></div>
     <div id="bgBar"></div>
     <div id="progressBar"></div>
   </div>
   <a target="_blank" href="http://www.kongregate.com"> <div id="icon"></div> </a>
   <p id="loadingInfo"></p>
 </body>
 </html>
 

alt text`

  • List item

unityloaderscreenshot.png (110.1 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by barrett-and · Aug 15, 2017 at 09:08 PM

Fixed it. I didn't realize that you have to have an extra level of folder in the script reference (i.e. "ZipFolderName/Build/UnityLoader.js") because the site treats the index.html and zip as seperate entities on the same file level.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Nuclear_Developer · May 12, 2018 at 04:22 PM 0
Share

Hey! I have tried to publish my game on $$anonymous$$ongregate, but i get the same error you got. Can you explain o me how you fixed it?

avatar image KeithT · May 17, 2018 at 08:41 AM 0
Share

I second the request for more info how you solved this, have similar issues.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

155 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is possible to Embed WebGL Compiled Game in Blogger? if Possible How? 2 Answers

I am getting this error in WebGL 0 Answers

Scaling Unity WebGL Canvas causes a bad performance 0 Answers

Base64 to texture decoding, js -> webgl 1 Answer

EditorUtility.OpenFilePanel for UnityWebGL (Runtime) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges