Geometry.Parse: Native type 'BaseObject' is not registered
Posted: 08 Jun 2023, 17:36
Hi, this is a rather strange situation.
I work with Geometry from under the code. For personal convenience, I decided to directly process the string and get the geometry through Geometry.Parse("M3..."); However, the method threw an error:
I searched for the reason for a long time until I discovered that Geometry.Parse does not work if Geometry is not loaded from ResourceDictionary at least once before the first call.
An example in which throws an exception:
But! If you write like this, then everything will work:
I work with Geometry from under the code. For personal convenience, I decided to directly process the string and get the geometry through Geometry.Parse("M3..."); However, the method threw an error:
Code: Select all
InvalidOperationException: Native type 'BaseObject' is not registered
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:480)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetProxy (System.IntPtr cPtr, System.Boolean ownMemory) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:519)
Noesis.Geometry.Parse (System.String source) (at ./NoesisGUI3.2/Runtime/API/Proxies/Geometry.cs:44)
Tester.Awake () (at Assets/Tester.cs:15)
An example in which throws an exception:
Code: Select all
private void Awake()
{
var geometry1 = Geometry.Parse("M3.91667 13.8333L12.0833 13.8333L12.0833 5.66667L3.91667 5.66667L3.91667 13.8333ZM13.25 4.5L13.25 15L2.75 15L2.75 4.5L13.25 4.5ZM5.08333 11.8442L5.90583 12.6667L8 10.5725L10.0942 12.6667L10.9167 11.8442L8.8225 9.75L10.9167 7.65583L10.0942 6.83333L8 8.9275L5.90583 6.83333L5.08333 7.65583L7.1775 9.75L5.08333 11.8442Z M13.25 2.75L2.75 2.75L2.75 3.91667L13.25 3.91667L13.25 2.75Z M12.6667 1L3.33335 1L3.33335 2.16667L12.6667 2.16667L12.6667 1Z");
var dictionary = _testResources.Load() as ResourceDictionary;
var geometry2 = dictionary["TestIcon"] as Geometry;
}
Code: Select all
private void Awake()
{
var dictionary = _testResources.Load() as ResourceDictionary;
var geometry2 = dictionary["TestIcon"] as Geometry;
var geometry1 = Geometry.Parse("M3.91667 13.8333L12.0833 13.8333L12.0833 5.66667L3.91667 5.66667L3.91667 13.8333ZM13.25 4.5L13.25 15L2.75 15L2.75 4.5L13.25 4.5ZM5.08333 11.8442L5.90583 12.6667L8 10.5725L10.0942 12.6667L10.9167 11.8442L8.8225 9.75L10.9167 7.65583L10.0942 6.83333L8 8.9275L5.90583 6.83333L5.08333 7.65583L7.1775 9.75L5.08333 11.8442Z M13.25 2.75L2.75 2.75L2.75 3.91667L13.25 3.91667L13.25 2.75Z M12.6667 1L3.33335 1L3.33335 2.16667L12.6667 2.16667L12.6667 1Z");
}