Vous ne pouvez pas sélectionner plus de 25 sujets
Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
|
- using System;
- using UnityEngine;
-
- public class ThereCanBeOnlyOne : MonoBehaviour
- {
- private void Awake()
- {
- if (this.Prefab != null)
- {
- if (!GameObject.Find(this.Prefab.name))
- {
- GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.Prefab);
- gameObject.name = this.Prefab.name;
- }
- }
- else
- {
- UnityEngine.Debug.LogError("Error prefab not set so There Can't Be Only One", this);
- }
- }
-
- private void Start()
- {
- }
-
- public GameObject Prefab;
- }
|