The script contains a simple functionprefab is instantiated like so:
setAddress(string//create stra "building" object using the csv data and add a reference to a list:
ResidentialHousing thisResidential = new ResidentialHousing(theLine){;
residentialList.Add(thisResidential);
address buildingRef = str;residentialList.Count - 1;
//addresskeep istrack aof stringhow variablemany definedhave forbeen theplaced:
script
numberPlaced ++;
Debug.Log("you //set addressa "reference +to addressthe prefab's behavior script:
BuildingBehavior bldgBhave = multiFamHigh.GetComponent<BuildingBehavior>();
//calledset afterthe addressinformation isfor set.the prefab:
} bldgBhave.setInfo( mgr.lotsList[chose].getAddress(),buildingRef);
In the "TownCreator" script, after the prefab is instantiated, I call thatthe setInfo function and pass the address to it. The setInfo looks like this:
public class BuildingBehavior : MonoBehaviour {
private string address;
public void setInfo(string useString, int bldgListRef)
{
address = useString;
Debug.Log ("Set Address = " + address);
buildingListRef = bldgListRef;
}
}
The debug log correctly displays "you set address 3071 N." - meaning at that time, the "address" variable of the prefab script is set to 3071 N. Perfect.
I believe theThat code is:
Text void OnMouseDown()
{
thisCG = GameObject.textFind("MainCanvas").GetComponent<CanvasGroup>();
thisCG.alpha = address;1;
//I switched it out to "ADDRESS" - andCanvasStuff thatthisCS works= GameObject.Find("MainCanvas").GetComponent<CanvasStuff>();
thisCS.setAddyText (address);
Debug.Log ("clicked on " + address);
}
This happens:
Any ideas why the script on the prefab clones is not storing the values?
Also - when I can post code later, if it helpschange (I am at my day jobaddress) - but I figure the debug logs showing a value and the UI popping up meanto (and the hard coded "ADDRESS" working"Address") that, the code is fine - but address is not stickingpopup has "Address" above the OK, Thanks! button. :/