as mentioned in the title, I get error message when transitioning from one scene to another:
MissingReferenceException: The object of type ‘SpriteRenderer’ has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.
I have a character empty object, that has several objects within that has sprite renderer: example with screen shot:
Note: these are not the exact names, just to help with explanation
Male_Empty_GameObject
— Hair - Game Object with Sprite Renderer
— Shirt - Game Object with Sprite Renderer
---- Pants - Game Object with Sprite Renderer
I tried to use the following:
public void DestroyObjects()
{
DontDestroyOnLoad(PlayFabController.PFC.RootPlayerCharacter);
DontDestroyOnLoad(PlayFabController.PFC.Male_char);
DontDestroyOnLoad(PlayFabController.PFC.Female_char);
DontDestroyOnLoad(PlayFabController.PFC.f_hair);
DontDestroyOnLoad(PlayFabController.PFC.f_skin);
DontDestroyOnLoad(PlayFabController.PFC.f_shirt);
DontDestroyOnLoad(PlayFabController.PFC.f_pants);
DontDestroyOnLoad(PlayFabController.PFC.m_hair);
DontDestroyOnLoad(PlayFabController.PFC.m_skin);
DontDestroyOnLoad(PlayFabController.PFC.m_pants);
DontDestroyOnLoad(PlayFabController.PFC.m_shirt);
//DontDestroyOnLoad(PlayFabController.PFC.m_shirt);
}
unfortunately, it gives me this message:
DontDestroyOnLoad only works for root GameObjects or components on root GameObjects.
then spams message:
MissingReferenceException: The object of type ‘SpriteRenderer’ has been destroyed but you are still
not sure what to do exactly, my scene goes when player clicks button “Start Game” thats when the error comes up, with a new scene… I was thinking of just putting a new Panel for the levels… but not sure if that would be clean or not
thoughts and how to resolve this?