- Home /
Question by
raul corrales · Mar 22, 2011 at 08:13 PM ·
javascript
How i make this code in Unity Javascript
Hi to all. This is a javascript code. How i make this in unity?
var locations = [
{ name: "shops", x:3, y:4 },
{ name: "library", x:5, y:3 },
{ name: "pub", x:1, y:2 }
];
Comment
Best Answer
Answer by Peter G · Mar 22, 2011 at 08:34 PM
That looks like an array of arrays: Object[][]
. I would personally do it this way though:
class Location : System.ValueType { //In js, you have to create structs by inheriting from the above. var name : String;
var x : float;
var y : float;
}
var locations : Location[];
Answer by Alexandre Zakime · Mar 22, 2011 at 08:37 PM
try this:
var x : int;
var y : int;
var names : String;
var locations = [
{ names: "shops", x:3, y:4 },
{ names: "library", x:5, y:3 },
{ names: "pub", x:1, y:2 }
];