stonesheltergames / Unity-GUID

Implementation of a persistent serializable GUID (Globally Unique Identifier) for Unity.
https://www.stonesheltergames.com
MIT License
49 stars 5 forks source link

GUID not generating automatically #6

Open BurritoBushido opened 1 year ago

BurritoBushido commented 1 year ago

Installed manually from package.

I have a prefab with a class inheriting GUID. Guids are never generated automatically. Context menu functions work. Prefab instances never generate new guids either, they inherit whatever is in the field for the prefab asset.

andreiagmu commented 1 year ago

I'm also having this issue, when instantiating prefabs in-game or duplicating prefab instances in-editor.

Currently, it seems GUIDs are only auto-generated for pre-existing scene instances. They aren't auto-generated for dynamically instanced prefabs in-game (i.e.: GameObject.Instantiate(); dragging a prefab to the Scene View), or for duplicated prefab instances in-editor (i.e.: Ctrl+D).

Xriuk commented 16 hours ago

Hello, sorry for the very late reply but this repo is not actively monitored. When you inherit GUID from a custom class if you override the Reset method you should call the parent implementation with base.Reset() to generate Guids on instantiation.

Prefab instances should generate guids if the asset guid is set to auto, if you are having problems with that you can give use more details on that and we can take a look at it.

Runtime-generated instances (via GameObject.Instantiate()) should not auto-generate guids because (I guess) Reset() is never called on those, you could generate it yourself after instantiating by calling GenerateGUID(). The same should apply for duplicated prefabs (which is a problem we also had), but the latest commit should have fixed that (it had a missing assembly error so you may not have tried it yet). While dragging a prefab to the scene view should regularly work, if the prefab asset has the guid set to auto (see paragraph above).