I'm building some serializing logic, and I'm trying to serialize a reference to a unityObject. What I have come across is AssetDatabase.GetAssetPath --> AssetPathToGUID. Which works quite well, but not for assets which aren't the "main" asset. And object.GetInstanceID --> EditorUtility.InstanceIDToObject which works even better.
But I wonder how references are serialized in the project by Unity, is it using InstanceIDs?
And is there a risk with using instanceIDs? Are they changed by Unity sometimes?
Lastly, is there a better way to serialize references?