04-19-2019, 02:52 AM
Well, Unity has an editing environment that I have to take into account. For running Tilengine in Unity's deployment environment, there is no problem. For that I can initialize Tilengine once for every instance, and then call Deinit or DeleteContext just before the program shuts down. Easy. But Unity's editing environment complicates matters.
The editor is running constantly, and it runs a "preview" environment whenever you press the play button. Scripts for Unity frequently have to have their values initialized for that preview. In order to get Tilengine running in the preview, I have to call the Init function every time the preview is activated. I have been able to get this working, in fact, I've even gotten it working with more than one instance simultaneously. You just have to be a bit more careful in manually setting the context.
What concerns me is that it is typical when working with Unity to use the "preview" feature a lot. Like, a WHOLE LOT. People slap that play button all the time, in order to get a quick look at what their most recent changes have done to their scenes. And because of how Unity's editor is structured, I can't call the Deinit or DeleteContext functions when the preview stops. Which means that the Init function can, and likely will, get called A LOT, with no calls to Deinit or DeleteContext. Now, thankfully this isn't a loop issue or a frame update issue. I can insure that it only gets called once per instance per preview session. But I'm slightly concerned that this might cause some manner of memory leak, with how repeatedly Init is getting called. I don't want to inadvertently max out someone's system RAM while they're in the middle of working on a game. (just because they used the preview a bit more aggressively than usual)
The editor is running constantly, and it runs a "preview" environment whenever you press the play button. Scripts for Unity frequently have to have their values initialized for that preview. In order to get Tilengine running in the preview, I have to call the Init function every time the preview is activated. I have been able to get this working, in fact, I've even gotten it working with more than one instance simultaneously. You just have to be a bit more careful in manually setting the context.
What concerns me is that it is typical when working with Unity to use the "preview" feature a lot. Like, a WHOLE LOT. People slap that play button all the time, in order to get a quick look at what their most recent changes have done to their scenes. And because of how Unity's editor is structured, I can't call the Deinit or DeleteContext functions when the preview stops. Which means that the Init function can, and likely will, get called A LOT, with no calls to Deinit or DeleteContext. Now, thankfully this isn't a loop issue or a frame update issue. I can insure that it only gets called once per instance per preview session. But I'm slightly concerned that this might cause some manner of memory leak, with how repeatedly Init is getting called. I don't want to inadvertently max out someone's system RAM while they're in the middle of working on a game. (just because they used the preview a bit more aggressively than usual)