Sprite is only a illustration of the picture to be displayed. To spawn it as an object in your scene, you want a GameObject with a SpriteRenderer or UI Picture part hooked up, which then references that Sprite and handles getting it drawn to the display screen at that location.
You possibly can arrange a GameObject in your scene that appears the way in which you need your card to look, then drag that object out of your Scene Hierarchy tab into one in all your Undertaking tab’s Asset folders to reserve it as a “prefab”. Then you possibly can spawn cases of that prefab and override their sprite if wanted, like this:
utilizing System.Collections;
utilizing System.Collections.Generic;
utilizing UnityEngine;
public class CardSpawn : MonoBehaviour
{
// Do not pluralize variables that consult with a single merchandise.
public Rework spawnPoint;
// Assign this prefab reference within the inspector.
// Right here I am assuming you need a SpriteRenderer, not a UI Picture.
public SpriteRenderer cardPrefab;
public Sprite cardSprite;
void Begin()
{
Spawncard();
}
public void Spawncard()
{
// Spawn a replica of the cardboard prefab at your required location/orientation.
SpriteRenderer occasion = Instantiate(
cardPrefab,
spawnPoint.remodel.place,
Quaternion.id
);
// Set the sprite on the cardboard to the one you need to show.
// Notice that this implies you possibly can re-use the identical card prefab
// for a lot of completely different sprites.
occasion.sprite = cardSprite;
}
}
