Skip to content

GetCurrentPrefabStage() is unreliable and can disable the AudioManager component on its original prefab #63

@LazyEti

Description

@LazyEti

For context: In my workflow, all essential managers are saved as prefabs that get instantiated when the game initializes and dont destroy til the game stops:
Image

The issue occurs in play mode.
If you either open or just click on the audio manager prefab in the project window, OnValidate() gets triggered but it doesn't detect that this is a prefab asset and will run EstablishSingletonDominance () anyway.

Thus the AudioManager Component gets disabled on the original prefab.
This is annoying and generates errors because the next time the game runs it instantiates the prefab with the disabled component.

For my specific situation i can do a dirty fix and just ignore the re establishment of the instance because i know there's never more than one of them but it'd be good to find a clean solution to this.
Does "EstablishSingletonDominance" really have to run when OnValidate? Couldn't it be run on awake?

Unity 6.0.38, using the latest version on the dev branch
Cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions