Behavior.AssociatedObject in AttachableObject.OnDetaching is null (bug)
Hi there!
If we use AssociatedObject in custom Behavior.OnDetaching method we get NullReferenceException :(
For example:
Noesis GUI version is 3.2.2, Unity version is 2023.1.13f1.
Thanks in advance.
If we use AssociatedObject in custom Behavior.OnDetaching method we get NullReferenceException :(
For example:
Code: Select all
protected override void OnDetaching()
{
base.OnDetaching();
AssociatedObject.PreviewKeyDown -= OnPreviewKeyDown; // NullReferenceException
}
Thanks in advance.
-
-
sfernandez
Site Admin
- Posts: 2908
- Joined:
Re: Behavior.AssociatedObject in AttachableObject.OnDetaching is null (bug)
Hi, this issue is already reported here: #2730.
It is happening because the associated object is being destroyed and then OnDetaching is called.
While we fix it, you can just check if the associated object is null before using it.
It is happening because the associated object is being destroyed and then OnDetaching is called.
While we fix it, you can just check if the associated object is null before using it.
Who is online
Users browsing this forum: Ahrefs [Bot], gvol1 and 2 guests