I’m a quite confused about Scriptable Objects.
I have to make sure that each button instantiates a different object but I don’t understand why I have to recreate them in the second script too. I don’t understand the logic of it
this is how i create the scriptable object:
[CreateAssetMenu(fileName = "Show Auto", menuName = "Auto")] //crea una voce quando vai negli asset (t.Dx->create->Nemico)
public class AutoInfo : ScriptableObject
{
public string nomeAuto;
public GameObject prefabAuto;
public string descrizioneAuto;
public string prezzo;
}
and here i create the function of the button.
public class CliccoBottone : MonoBehaviour
{
public AutoInfo[] auto;
public TMP_Text info;
public TMP_Text nome;
public TMP_Text prezzo;
GameObject macchina;
public void InstanziaAuto(int numero)
{
Destroy(macchina);
macchina = Instantiate (auto[numero].prefabAuto);
macchina.transform.position= new Vector3( 0,0,0);
info.text = (auto[numero].descrizioneAuto);
nome.text = (auto[numero].nomeAuto);
prezzo.text = (auto[numero].prezzo);
}
}
why if i create : public GameObject prefabAuto i have to create -GameObject macchina in the second script?
JollyLolly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.