hey …
as the title says, I’m having issues when trying to create a variable with an Object data type.
This is what I’m trying to do:
var PowerSource:Object = new Object();
PowerSource.voltage = 12;
function Start ()
{
displayPowerFlow(PowerSource.voltage);
}
function displayPowerFlow(p)
{
Debug.Log (p);
}
How would I create an Object variable in Unity?
var powerSource = new PowerSource();
powerSource.voltage = 12;
class PowerSource {
var voltage : int;
}
Or:
var powerSource = new PowerSource(12);
class PowerSource {
var voltage : int;
function PowerSource (voltage : int) {
this.voltage = voltage;
}
}
–Eric
Thanks Eric …
So what you’re basically telling me is that I can’t create generic object variables, I have to create a class?
You can implement the concept of Expando objects if you want to use Unityscript:
http://www.unifycommunity.com/wiki/index.php?title=ExpandoObject
Thanks Ntero … I’ll have a look at it.