Hello, I want to check if some unity Object is null but inside async thread.
I get “InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread” error message with obj == null, obj.IsEqual(null)
I tried with obj is null, ReferenceEquals(obj,null) but it’s returning true no matter what.
Can I check if some Unity.Object is null in other way and without InvalidOperationException inside async method?
You can’t do pretty much ANYTHING with most of the Unity API outside of the main thread, so even if it was or was not null, there’s nothing you can do with it.
Are you just wanting to see when something else sets / nulls it? If so, employ another variable like a bool and check that.
Thanks, then I probably will do something like preparation stage and then use bools in async method.
This will be dynamic list of various methods to call in the async method, so it may need some work to automate.