Proper way to end a game in webbrowser

Hi all,

I have a problem in my game when the user reaches the end of the game. The game shows a message saying “good job” :slight_smile: and it disables some scripts, not by de-attaching them, but by setting boolean variables (ex : the MouseLook script has a CanLook var and I set it to false via SendMessage). So, the user cannot do anything, except clicking a button which executes an Application.ExternalCall(“myjsfunc”).

The JS function is a simple http redirect and the bug comes here. I tried to use Application.OpenURL and it does the same bug : my browser SHUTS DOWN ! I tried in IE and Firefox (Windows) and it’s not a browser-related problem. Tried under Firefox on Mac, the problem doesn’t appear.

I did some tests :

  • making another game with same scripts attached to my First Person Controller, but with no mesh, just a terrain and a light…no bug

  • trying to remove step by step every one of my GameObjects (objects, lights, particule emiters, characters)…always the same bug

  • trying to “make the user win” a the start of the game by directly showing the message : no bug.

Conclusion : it seems that my last character that I meet (the goal of the game is to find him and after saying some strings, the game ends) is causing the bug. Because he has several animations queued, I think the bug comes when I try to redirect to another page (or setting display to ‘none’ on the web player’s hosting DIV), while an animation is still playing.

Finally, the question : what’s the proper way to “end” my game ? Should I stop all animations, de-activate all the scripts before hiding/redirecting the page which hosts the web player ?

Many thanks

Up…please :sweat_smile:

Generally: The lack of responses to this thread are directly related to the lack of mind readers on these forums. For this problem to be more easily solvable, your post needs one of the following:

  • A running webplayer which demonstrates the problem along with a text describing how to reproduce the problem.
  • The script which causes the problem.
  • A project which reproduces the problem.

Without these, I can only guess what’s going.

Best bet: check your unity player log for exception messages. Firefox handles exceptions incorrectly, meaning if your code trips an exception, Firefox will crash. I haven’t heard that IE would crash in the same manner, but without further information, this is my best guess.

Hi,

I’ve resolved my problem by changing some code. The problem was in the use of System.Timers.Timer in C#. I used a timer to show one by one the letters of a string (a character sentence) and even if the states of the timers were closed at the end of the sentences and the objects where correctly disposed, it seems there was a memory leak on this timer.

In IE, I’ve had one time an “Memory cant’ be written” error and in Firefox, nothing appeared.

I changed the code by using InvokeRepeating and CancelInvoke instead of closing the timer and it worked.

In my opinion, there are some classes we shouldn’t use in multiple platforms devs, like those timers that are really dependant of the hosting System clock and other “obscure” things…I didn’t saw the InvokeRepeating before, so now I’ll prefer to use it…

Just a question, AngryAnt, where can I find the web player log file under Windows ?

Thanks again,
Bye

http://www.google.com/search?hl=en&q=site%3Aforum.unity3d.com+"player+log"+windows&btnG=Search

OK lol…

Maybe too much lazyness :stuck_out_tongue:

Bye