I want to create dynamically ui button,
I have one prefab,
here is code:
public class SFSConnect : MonoBehaviour {
SmartFox sfs;
public GameObject cnv1;
public GameObject potchPrf;
public Canvas fCanvas;
void Start () {
fCanvas = cnv1.GetComponent<Canvas> ();
Button ptf1 = potchPrf.GetComponent<Button> ();
Instantiate(ptf1,new Vector3 (0, 0, 10), Quaternion.identity);
potchPrf.transform.SetParent (fCanvas.transform);
}
}
I tried thousands of posts, but nothing happened