Hi ![]()
Let’s say I have a javascript class in a script on a gameobject.
If I create an instance of the class into a variable and then set the variable back to null, does that effectively destroy the instanced class or is it hanging out in memory somewhere?
for example:
myscript.js
//var declarations, etc...
var myClass : UbahClass;
function Update()
{
// update stuff
}
function OnGUI()
{
// gooey stuff
if (GUI.Button(Rect(10,10,100,100),"Oobafy")
{
myClass = new UbahClass;
}
if (GUI.Button(Rect(150,10,100,100),"Reech!")
{
print(myClass.blah+myClass.bleh);
}
if (GUI.Button(Rect(300,10,100,100),"Po!")
{
myClass.DeUbah;
print(myClass.blah+myClass.bleh+ "You is Po!");
}
if (GUI.Button(Rect(450,10,100,100),"No Mo Po!")
{
myClass = null;
print("You No Mo Po!");
//// Is the class instance still in memory without a handle or is it truly gone and memory released?
}
}
class UbahClass
{
var blah;
var bleh;
function UbahClass()
{
blah = "One Beeelion Dollars";
bleh = blah; // now you have 2 beelion dollars!
}
function DeUbah()
{
bleh = "penny";
blah = bleh; // now you have two pennies!
}
}
function Start()
{
//start stuff, etc
}
Thanks,
Jason