public GameObject Create(string name, int x, int y) { GameObject obj = Instantiate(chesspiece, new Vector3(0, 0, -1), Quaternion.identity); Chessman cm = obj.GetComponent <Chessman>(); //We have access to the GameObject, we need the script cm.name = name; //This is a built in variable that Unity has, so we did not have to declare it before cm.SetXBoard(x); cm.SetYBoard(y); cm.Activate(); //It has everything set up so it can now Activate() return(obj); }
public GameObject Create(string name, int x, int y) { GameObject obj = Instantiate(chesspiece, new Vector3(0, 0, -1), Quaternion.identity); Chessman cm = obj.GetComponent <Chessman>(); cm.name = name; cm.SetXBoard(x); cm.SetYBoard(y); cm.Activate(); return(obj); }
public GameObject Create(string pieceName, int posX, int posY) { GameObject obj = Instantiate(chesspiece, new Vector3(0, 0, 0), Quaternion.identity); Chessman cm = obj.GetComponent <Chessman>(); cm.name = pieceName; cm.xBoard = posX; cm.yBoard = posY; cm.Activate(); return(obj); }