usingUnityEngine;usingSystem.Collections;usingUnityEngine.UI;publicclasscanvas:MonoBehaviour{//Me creo un entero para saber el numero de cartasprivateintnumCartas=0;// Use this for initializationvoidStart(){numCartas=0;}// Update is called once per framevoidUpdate(){}publicvoidcambiarCarta(){GameObjectnueva=newGameObject();Imageimagen=nueva.AddComponent<Image>();//Add the Image Component scriptimagen.sprite=Resources.Load<Sprite>("Cartas/103");//Set the Sprite of the Image Component on the new GameObjectnueva.GetComponent<RectTransform>().SetParent(gameObject.transform);//Assign the newly created Image GameObject as a Child of the Parent Panel.nueva.GetComponent<RectTransform>().position=newVector3(40*numCartas+40,300,0);nueva.GetComponent<RectTransform>().sizeDelta=newVector2(90,130);nueva.SetActive(true);//Activate the GameObjectnumCartas++;}}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.