Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

28 righe
513 B

  1. using System;
  2. using UnityEngine;
  3. public class ThereCanBeOnlyOne : MonoBehaviour
  4. {
  5. private void Awake()
  6. {
  7. if (this.Prefab != null)
  8. {
  9. if (!GameObject.Find(this.Prefab.name))
  10. {
  11. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.Prefab);
  12. gameObject.name = this.Prefab.name;
  13. }
  14. }
  15. else
  16. {
  17. UnityEngine.Debug.LogError("Error prefab not set so There Can't Be Only One", this);
  18. }
  19. }
  20. private void Start()
  21. {
  22. }
  23. public GameObject Prefab;
  24. }