Unity-Technologies/guid-based-reference

CanEditMultipleObjects (or other multi object edition tools like Odin) changes the GuidReferences to the same value

adbourdages opened this issue · 0 comments

I was trying to figure out why some GuiReferences were changing on me and finally realized it was when I selected multiple components at a time.

I have an AnchorComponent that uses a GuidReference as one of its serialized field. That AnchorComponent has a CustomEditor with [CanEditMultipleObjects]. When selecting multiple AnchorComponents, all the GuidReferences are set to the same value (the one from the last object selected).

I don't have a great fix for this since I'm not an expert in editor serialization. However placing the following script in GuidReferenceDrawer will prevent the drawing and therefore the overriding of the values when there are multiple objects selected.

Also note the same behaviour with other tools, like Odin, that allows multiple object selection

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        if( Selection.gameObjects.Length > 1 )
            return;