I need a way to detect if the webclient has shutdown.
Meaning a player is playing the game, then quits the browser, the client takes a little time to shutdown, so I want to have a method that can send my server a message telling me that he just closed out of the game (closing out of the game rather)
I assume there is a deinitialize somewhere, how do I detect and send a message prior to it finishing or when it is called?
In OnApplicationQuit you can do whatever you like. You can also have many of these functions implemented in multiple scripts - they all will be called.
using UnityEngine;
using System.Collections;
public class DisplayMessage : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnApplicationQuit () {
}
}
When attempting to attach to anything it says:
Can’t Add Script
Can’t add script behaviour DisplayMessage. The
script needs to derive from MonoBehaviour!
Well, I don’t know if this was the proper “fix” but I decided to just do a “rebuild assets”, took like 15 minutes then after it reloaded my game, I got the method to work. Now back to doing some cool script testing.
Oddly, my current scene is about 37 megs, only 1 music file attached, a bare bone castle, a few houses in the village, couple dozen trees, some weapons with scripts attached to them.
I really need to figure out how to attach the camera to the player object, enable collision on everything etc. Guess that will come in time, having more fun with the scripts at the moment.