You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

28 rivejä
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. }