Is a bug? or my code is wrong?

when i want to clear a List ,it will fail ,after “wasHit.Clear();”,the wasHit element is still in ,not empty. when I want to change the element ,it run error :

public List wasHit = new List();

public override void clean()

{


     wasHit.Clear();

     wasHit[0] = Guid.Empty;



}

error:

[ 00:56:45.352 ]: [Error] Native interop exception!

[ 00:56:45.352 ]: [Warning] Exception has been thrown during Main thread action. Invalid ManagedHandle

Stack strace:

at FlaxEngine.Interop.ManagedHandle.ManagedHandlePool.GetObject(IntPtr handle) in F:\FlaxEngine\Source\Engine\Engine\NativeInterop.Managed.cs:line 513

at FlaxEngine.Interop.ManagedHandle.get_Target() in F:\FlaxEngine\Source\Engine\Engine\NativeInterop.Managed.cs:line 360

at FlaxEngine.Interop.NativeInterop.MarshalHelperReferenceType`1.ToManaged(T& managedValue, IntPtr nativePtr, Boolean byRef) in F:\FlaxEngine\Source\Engine\Engine\NativeInterop.cs:line 782

at FlaxEngine.Interop.NativeInterop.MarshalHelper`1.ToManaged(T& managedValue, IntPtr nativePtr, Boolean byRef) in F:\FlaxEngine\Source\Engine\Engine\NativeInterop.cs:line 472

at FlaxEngine.Interop.NativeInterop.Invoker.InvokerStaticNoRet1`1.MarshalAndInvoke(Object delegateContext, ManagedHandle instancePtr, IntPtr paramPtr) in F:\FlaxEngine\Source\Engine\Engine\NativeInterop.Invoker.cs:line 529

at FlaxEngine.Interop.NativeInterop.InvokeMethod(ManagedHandle instanceHandle, ManagedHandle methodHandle, IntPtr paramPtr, IntPtr exceptionPtr) in F:\FlaxEngine\Source\Engine\Engine\NativeInterop.Unmanaged.cs:line 675

[ 00:56:45.352 ]: [Error] Exception has been thrown during Main thread action.

Invalid ManagedHandle

I found when in the AnimEvent, i set a variable, it’s not changed when i want to change it…how can i get a AnimEvent flag???

when the AnimEvent happened, manager.test is still 0 ,not to 1…

my flax version is 1.6;

I solve it by GameplayGlobals.in AnimEvent ,it will changed.i make it flag to trigger states.

is there other ways?

You are trying to access an element of a cleared list. The list will have no elements because it is cleared. If you want the 0 element of the list to exist after you clear it, you will need to .Add(Guid.Empty).

Not sure exactly what you are trying to do… but you can override the OnEvent function to get a reference to the AnimatedModel actor and then access any scripts or other actors from that actor. For future reference, it would be good to break this question out into another forum post so that way it is easier to track and find for others.

thanks, i will.