mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
fix: Prevent m_AssetId set to empty string (#2766)
* fix: Prevent m_AssetId set to empty string Fixes: #2765 Checks path for empty string before assigning to `m_AssetId`. I left commented debug logs in place from testing, which was setting `NetworkIdentity.ServerOnly` on and off both in normal edit mode and prefab edit mode. In either mode, OnValdidate fires 4 times, and two of those try to set an empty string to `m_AssetId`. * Changes as requested * Update Assets/Mirror/Runtime/NetworkIdentity.cs * Update NetworkIdentity.cs Co-authored-by: vis2k <info@noobtuts.com>
This commit is contained in:
parent
b08cc62fd4
commit
8218979e32
@ -328,7 +328,13 @@ void OnValidate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
void AssignAssetID(string path) => m_AssetId = AssetDatabase.AssetPathToGUID(path);
|
void AssignAssetID(string path)
|
||||||
|
{
|
||||||
|
// only set if not empty. fixes https://github.com/vis2k/Mirror/issues/2765
|
||||||
|
if (!string.IsNullOrEmpty(path))
|
||||||
|
m_AssetId = AssetDatabase.AssetPathToGUID(path);
|
||||||
|
}
|
||||||
|
|
||||||
void AssignAssetID(GameObject prefab) => AssignAssetID(AssetDatabase.GetAssetPath(prefab));
|
void AssignAssetID(GameObject prefab) => AssignAssetID(AssetDatabase.GetAssetPath(prefab));
|
||||||
|
|
||||||
// persistent sceneId assignment
|
// persistent sceneId assignment
|
||||||
|
Loading…
Reference in New Issue
Block a user