Character Select Button Putting Info into GameManager Script - Is this Possible?
So I'm a Unity 2D baby and started to assemble the game myself after designing the assets myself. I have a character creation menu with buttons and information attached to each button (e.g. press this button and your character in the game will be a seal, press this button and it will get a special technique, etc.). I attached sprites to each of the character button and, upon pressing it, I want the sprites put into the GameManager prefab that is present in every scene.
Here is my code:
public class Ichooseyou: MonoBehaviour {
//I put this script on the button in the character creation scene. //so to each button I attach a hero (a stationary sprite that shows up in the passport) and a movement // (a sprite sheet that will dictate the animations of said character)
public Sprite hero; public Sprite movement;
public void ourhero(){
// In my GameManager I have the "MyHero" GameObject attached to it, which contains the elements of // a tabletop RPG character sheet. MyHero has two public sprites, the first of which is the sprite sheet // for the character and the second its passport photo. In addition to that it has all of the stats, etc.
GameObject.Find("myhero").GetComponent("hero"); GameObject.Find("myhero").GetComponent("passportphoto");
passportphoto= hero;
//I want to set the passport photo of the GameManager Object to the one set on the button hero= movement;
//I want to set the sprite sheet in the same way
//GameManager loads in the first scene but has DontDestroyOnLoad, not sure if I should do it some other way.
//Thank you so much in advance! If you'd like I'll include you in the credits of the final game.
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612233450im_/https://answers.unity.com/themes/thub/images/avi.jpg)