Quantcast
Channel: Questions in topic: "build"
Viewing all articles
Browse latest Browse all 4084

Prefabs not instantiating after build

$
0
0
Hello there, In my game I have two prefabs I want to instantiate at different times, as one spawns the other gets destroyed using it's tag. All of this works well in the editor but after I build the game it just will not instantiate my prefabs. Here's a look at my code for spawning the prefabs: ---------- public class SpawnAndDestroy : MonoBehaviour, IDimensionSwap { [Header("DimensionObjects")] public GameObject Dimension001Objects; public GameObject Dimension002Objects; //[Header("Text")] //public Text dimension; [Header("NavMesh Stuff")] public NavMeshSurface surface; //private Stuff bool homeDimension; public void Start() { homeDimension = true; } public void Spawn() { if (!homeDimension) { Instantiate(Dimension001Objects); Destroy(GameObject.FindWithTag("Dimension002")); StartCoroutine(DoAfterTime(0.1f)); //dimension.text = "Dimension 001"; homeDimension = true; } else { Instantiate(Dimension002Objects); Destroy(GameObject.FindWithTag("Dimension001")); StartCoroutine(DoAfterTime(0.1f)); //dimension.text = "Dimension 002"; homeDimension = false; } } public IEnumerator DoAfterTime(float time) { yield return new WaitForSeconds(time); surface.BuildNavMesh(); yield return null; } } ---------- And the Event System that calls it (though I know that's not the issues since I've tried just OnButtonDown in the SpawnAndDestroy script): ---------- [System.Serializable] public class OnLeftClickEvent : UnityEvent { } [System.Serializable] public class OnRightClickEvent : UnityEvent { } public class EventClick : MonoBehaviour { public OnLeftClickEvent OnLeftClick = new OnLeftClickEvent(); public OnRightClickEvent OnRightClick = new OnRightClickEvent(); void Update() { if (Input.GetButtonDown("Fire1")) { OnLeftClick.Invoke(); //Debug.Log("did i click?"); } if (Input.GetButtonDown("Fire2")) { OnRightClick.Invoke(); //Debug.Log("i clicked now what?"); } } } ---------- Thank you for any insight you may have!

Viewing all articles
Browse latest Browse all 4084

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>