-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: GlobalObjectIdHash generation for already existing in-scene placed prefab instances [MTT-7055] #2707
fix: GlobalObjectIdHash generation for already existing in-scene placed prefab instances [MTT-7055] #2707
Conversation
Split apart the NetworkObjectRefreshTool from NetworkObject. Made some updates that don't require any form of editor application update. Added script in NetworkObject.RefreshAllPrefabInstances context menu method that handles refreshing the currently active scene and all enabled scenes in the build list.
// 1 = Imported Asset | ||
// 2 = Scene Object | ||
// 3 = Source Asset. | ||
var objetType = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these types be an enum something similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, that is actually part of the format for the GlobalObjectId that is generated by GlobalObjectId.GetGlobalObjectIdSlow
. I added those comments to remind anyone what the values for that section of the GlobalObjectId is:
The format of the string representation of the ID is "GlobalObjectId_V1-{i}-{a}-{l}-{p}" where:
{i} is the identifier type represented by an integer (0 = Null, 1 = Imported Asset, 2 = Scene Object, 3 = Source Asset).
{a} is the asset GUID.
{l} is the local file ID of the object. For objects inside a prefab instance this is the local file ID of the source object in the prefab.
{p} is the local file ID of the prefab instance of the object (or 0 when the object is not part of a prefab instance).
How about I make those constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah constants would be good:
var objectType = k_GlobalObjectIdObjectType_SourceAsset;
would look much better, or a define or whatever :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed an update that applies this suggested modification.
…ed prefab instances [MTT-7055] (#2707) * update Resolves MTT-7055. Split apart the NetworkObjectRefreshTool from NetworkObject. Made some updates that don't require any form of editor application update. Added script in NetworkObject.RefreshAllPrefabInstances context menu method that handles refreshing the currently active scene and all enabled scenes in the build list. Added dialog notification when attempting to do a NetworkObject Refresh on an in-scene placed prefab instance as opposed to a prefab instance. * test Made some minor updates for the manual test * update adding change log entry * style Added object type identifier constants for code clarity purposes.
This is a fix for handling the scenario where several in-scene placed instances of a normal prefab might already exist in one or more scenes (i.e. an already existing single player project that the user wants to make multiplayer) and the user wishes to make the source/original prefab a network prefab by adding a
NetworkObject
component to it.MTT-7055
fix: #2644
Changelog
GlobalObjectIdHash
value for all in-scene placed prefab instances that were created prior to adding aNetworkObject
component to it.Testing and Documentation
Additional Information
Context menu was added to NetworkObject that allows one to refresh all in-scene placed prefab instances in any of the enabled scenes in the build list: