Hey. I got some code that i think is right, but it gives a error: NullReferenceException: Object reference is not set to an instance of an object.
I have dragged the Datacollection into the script. But i guess there could be a issue there ?
public tk2dSpriteCollectionData CD;
public int i;
public List<GameObject> Servers = new List<GameObject>();
private RoomInfo[] oldList;
void Awake () {
}
// Update is called once per frame
void Update () {
if (oldList != PhotonNetwork.GetRoomList()){
// foreach(tk2dSprite obj in this.gameObject.GetComponentsInChildren<tk2dSprite>()){
// GameObject.Destroy(obj.gameObject);
// }
i = 0;
foreach (RoomInfo game in PhotonNetwork.GetRoomList()){
int spriteID = CD.GetSpriteIdByName("infoBox");
// GameObject tempObj = new GameObject("Server "+i.ToString());
GameObject obj = new GameObject();
tk2dSprite.AddComponent(obj, CD, spriteID);
// tk2dSprite tempSpr = tempObj.AddComponent<tk2dSprite>();
// tempSpr.SetSprite(CD,CD.);
// tempObj.GetComponent<tk2dSprite>().SetSprite
// tempObj.transform.position = new Vector3(0,0,-0.1f);
// this.gameObject.AddChild(tempObj.transform);
//Servers.Add(tempObj);
i++;
Debug.Log("Server Added");
}
oldList = PhotonNetwork.GetRoomList();
Debug.Log("GameList Updated");
}
}
Please check if something is wrong ?