private void UpdatePrefabMap() { GameObject[] gameObjects = GameObjectUtils.FindAllNotInScene(); foreach (var go in gameObjects) { GuidComponent guidComp = go.GetComponent <GuidComponent>(); if (guidComp != null) { string guid = guidComp.GetGuid().ToString(); if (!guidToPrefabMap.ContainsKey(guid) && !guidToObjectMap.ContainsKey(guid)) { guidToPrefabMap.Add(guid, guidComp.gameObject); } else { bool existsInAsset = (guidToPrefabMap.ContainsKey(guid) && guidToPrefabMap[guid] != null && guidToPrefabMap[guid] != guidComp.gameObject); bool existsInScene = (guidToObjectMap.ContainsKey(guid) && guidToObjectMap[guid] != null && guidToObjectMap[guid] != guidComp.gameObject); if (existsInAsset || existsInScene) { duplicateGuidObjectList.Add(guidComp.gameObject); } } } } }
public override void OnInspectorGUI() { if (guidComp == null) { guidComp = (GuidComponent)target; } EditorGUILayout.LabelField("Guid:", guidComp.GetGuid().ToString()); if (GUILayout.Button("Create New Guid")) { Undo.RecordObject(guidComp, "Create New Guid"); guidComp.CreateNewGuid(); } }