|
Does anyone know the syntax for an IDisposable class in UnityScript? The C# ~ callback doesn't work. Thanks, -Aubrey
(comments are locked)
|
|
I'm not sure what callback you're talking about, but an IDisposable class is just one that implements the IDisposable interface and has a public Dispose method:
Edit: IDisposable isn't what you're looking for at all, you're wanting the finalizer syntax. Try this instead:
(comments are locked)
|
Thanks for all the info, but I am working in Unity Javascript. The ~ destructor doesn't compile, and I am interested in the syntax for the destructor in UnityScript. The following code compiles fine, but it never prints anything even long after the reference to the object has been destroyed. class WhirldIn extends System.Object implements System.IDisposable { function Dispose() { Debug.Log("Farewell, Cruel World!"); } }
Dec 11 '10 at 04:59 PM
Aubrey Falconer
IDisposable implys that you manually call Dispose(). I wouldn't trust any destructors in unity. If you need to make cleanup when an object is destroyed you have to manually call such method. I made an extension method (In C#) that is called Dispose() which calls BroadcastMessage ("OnDispose".. and after that Destroy that object.
Dec 12 '10 at 05:14 PM
Statement ♦♦
Do you mean it doesn't get called when you do objectReference = null or when you do Destroy(objectReference)?
Dec 12 '10 at 05:15 PM
Statement ♦♦
A destructor would work fine for the class he created above (which doesn't inherit MonoBehaviour - that'd be awful otherwise).
Dec 12 '10 at 05:28 PM
Mike 3
(comments are locked)
|

What has multithreading with the question to do?
Umm ~ not much. Tag removed...