Hi all,
I have created a custom class of my own in javascript with attributes as shown below:
class ConceptNode{ //node to store concept/relation
static var concept = "";
static var activity = -1;
static var activated = false;
static var hyperConceptOf = new Array();
static var elementConcept = new Array();
function ConceptNode(con,act,hyper,ele){//constructor
this.concept = con;
this.activity = act;
hyperConceptOf.push(hyper);
elementConcept.push(ele);
}
}
I then try to create an array of objects of the above class in another script which is attached to a GameObject using the following:
static var conceptList = new Array(); static var conceptNodeList = new Array();
function Update(){
}
function Start(){
conceptNodeList[0] = new ConceptNode("Landmark",0,"","Building");</p>
conceptNodeList[1] = new ConceptNode("Building",0,"Landmark","Commercial");
for(var i=0;i<conceptNodeList.length;i++){
Debug.Log(conceptNodeList*.concept);*
_ Debug.Log(conceptNodeList*.hyperConceptOf[0]);*_
_*}*_
_*```*_
_*<p>}</p>*_
_*<p>It seems that both the ConceptNode objects which I've created in the conceptNodeList are the same object. The log messages show the same attributes for both iterations. is this due to javascript array passing by reference? Or am I doing something wrongly? Any help by anyone would be greatly appreciated.</p>*_
_*<p>Thank you</p>*_