Hey, guys! I have a small problem. I am instantiating game object but whenever I want to enable my options menu my clone game objects are still active. So, I have a game object to my prefabs and I am instantiating them. For one reason only my first original game object deactivates but my clones/instances are staying there. Can you please me?
#How to disable already existed clones/instances of my game object?
1 messages · Page 1 of 1 (latest)
You could add all the instantiated objects to a list, then destroy them when you need to
Show code
Here is the code that I am enabling and disabling the game objects I have to go for sleep now there is no time so you can inspect my code here:
MainGameUIManager.cs
https://hatebin.com/emlyjbrldd
SettingsManager.cs
https://hatebin.com/hrrvpkiten
Tell me whatever you want here I will see it tomorrow. Thanks!
Oh, I got a video as well to show you
just parent them under a gameobject ie. Trees when u create them. And disable / enable that (1) gameobject..
otherwise you'll need to track every tree you spawn and and enable/disable all of em..
in a list<> for example, and disabling them running a for/foreach loop..
1s easier than the other obv
Oh that's smart, I should start doing that
@cold pagoda So, what do you mean to parent them ? You mean my tree logs?
What I do is that I am instantiating my game object everytime
Thats why you see tree logs (clones) so I don't know how to disable these clone objects when pressing settings to enable options menu
var treeJustSpawned = Instantiate(treeprefab...
treeJustSpawned.parent = TreeContainer; <-- would hold all tree's
then when u wanna disable them.. (for the pause menu for example)
you just have to say TreeContainer.SetActive(false);