Structs and possibly implicit operators ?

Issue #403 invalid
Former user created an issue

Here's my simple code:

    [System.Serializable]
    public struct TimeData
    {
        public TimeFormat Format;

        [SerializeField]
        private float _time;

        public float Time => _time * (int) Format;

        public static implicit operator float(TimeData data)
        {
            return data.Time;
        }
    }

The inspector and everything else seems fine, but odin constantly complains when I change one value of time =>

Unsupported type TimeData
UnityEditor.PrefabUtility:RecordPrefabInstancePropertyModifications(Object)
Sirenix.OdinInspector.Editor.PropertyTree`1:<ApplyChanges>b__42_1() (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/RangeAttributeDrawer.cs:76)
Sirenix.OdinInspector.Editor.PropertyTree`1:InvokeDelayedActions()
Sirenix.OdinInspector.Editor.InspectorUtilities:EndDrawPropertyTree(PropertyTree) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/SerializationInfoMenuItem.cs:16)
Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean)
Sirenix.OdinInspector.Editor.OdinEditor:DrawTree()
Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector()
Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI()
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Comments (1)

  1. Tor Esa Vestergaard

    Reported fixed by reporter on Discord - was not an Odin-related error. The fix was to remove and then re-add the component containing the value (which was on a prefab instance).

  2. Log in to comment