using UnityEngine;
public class ReceivedGiftPopup : MonoBehaviour
{
public GameObject originalWidget;
public Texture2D graphics;
public void SetGiftRandom()
{
GameObject clone = NGUITools.AddChild(gameObject, originalWidget);
UITexture uiTexture = clone.GetComponentInChildren<UITexture>();
uiTexture.ResetAndUpdateAnchors(); // <-- you are missing this
uiTexture.mainTexture = graphics;
uiTexture.width = graphics.width;
uiTexture.height = graphics.height;
}
}