Quantcast
Channel: Questions in topic: "dontdestroyonload"
Viewing all articles
Browse latest Browse all 416

DontDestroyOnLoad duplicate solve test failed.

$
0
0
Hello everyone I have 2 script and im trying that the dontdestroyonload doesnt duplicate the objects when i come back to the first scene i tried to count the tag of the object and if its zero the it should instantiate a prefab but i didnt work here are my scripts The duplicate solver: #pragma strict var audio2 : GameObject; var clonedObject : Transform; var audioCounter : int; function Update () { audioCounter = GameObject.FindGameObjectsWithTag("audio"); if(audioCounter == 1) { Instantiate(audio2, clonedObject.transform.position, transform.rotation); } } and the script with the dontdestroyonload #pragma strict function Start () { } function Update () { DontDestroyOnLoad(this); if(Application.loadedLevel <= 1) { audio.volume = MenuMastering.myVolume; } if(Application.loadedLevel == 2) { audio.volume = 0; } } if anyone can tell me how i can make the gameobject with the second script not to be duplictaed it would be very apreciatet and if someone posts a singleton pattern link or script please let it be in java i dont know c#. thanks in advance skullbeats1

Viewing all articles
Browse latest Browse all 416

Trending Articles



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