How to I refrence a sript on a gameobject in another scene?
Hi, I'm going to try to explain this as best I can. Note that I'm pretty new to unity(1-2 months) so please explain your answers or scripts. I'm making an FPS game.It has a Main menu(MainMenu) with an achievements button that you click and see 14 boxes with a "locked" icon on them. I also have a scene(Level_1) that has a radio,that when you turn it on displays an achievemnt icon and plays a sound then removes itself. I have a script with a void titled "Unlocked ()" and that basically removes the "locked" icon and displays text on those boxes I told you about earlier. Now,my question is how do i reference this void/gameobject in the script that shows the achievemnt,which is in another scene? Script 1 is the one that displays the achievement when you play the radio. Script 2 is the one that when the void is triggered should remove the lock and put text. How do i make it so that when you get the achievement,in the other scene(MainMenu)It removes "locked" and puts text? I'm using C#. Thanks!
Answer by OneCept-Games · Jan 02, 2018 at 12:08 PM
You have in my opinion two ways to solve this: 1: Save/load your locked/unlocked by ie. PlayerPrefs() method 2: Use a Singleton approach and DontDestroyOnLoad() method
Thanks! Didnt know how to refrence it because i didnt know about PlayerPrefs()!