- Create a function library
- Create a very simple function with a “Switch by int” and Return nodes that return asset references, as you see below.
- Use it’s output from a blueprint
- Test it in editor, it will work perfectly
- Package it without nativizing assets, again it will work fine.
- Package with “Nativize Assets” enabled. It will crash when we call that function in the phone.
In the monitor.bat, it is giving this error:
10-02 01:18:11.683: D/UE4(17252): Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:Runtime/Core/Public/Containers\Array.h] [Line: 804]
10-02 01:18:11.683: D/UE4(17252): Array index out of bounds: 2 from an array of size 0libUE4.so!FDebug::LogAssertFailedMessage(char const*, char const*, int, wchar_t const*, ...)
As far as I found out, array index 2 is came from this line in the nativized .cpp file:
UMyFunctionLibrary_C__pf398527342::StaticClass())->UsedAssets[2]
Here is an empty project that you can reproduce this issue: Microsoft OneDrive - Access files anywhere. Create docs with free Office Online.
10-02 01:18:11.645: D/UE4(17252): [2016.10.01-22.18.11:645][-6980444]LogBlueprintUserMessages: [MeshSwitcherWidget_C_0] Found the actor with given tag! Now I will set it to the mesh that I took from function...
10-02 01:18:11.649: D/UE4(17252): [2016.10.01-22.18.11:649][-6980444]LogOutputDevice:Warning:
10-02 01:18:11.649: D/UE4(17252): Script Stack:
10-02 01:18:11.649: D/UE4(17252): MeshSwitcherWidget_C.BndEvt__ButtonCylinder_K2Node_ComponentBoundEvent_1_OnButtonClickedEvent__DelegateSignature
10-02 01:18:11.683: D/UE4(17252): Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:Runtime/Core/Public/Containers\Array.h] [Line: 804]
10-02 01:18:11.683: D/UE4(17252): Array index out of bounds: 2 from an array of size 0libUE4.so!FDebug::LogAssertFailedMessage(char const*, char const*, int, wchar_t const*, ...)
10-02 01:18:11.683: D/UE4(17252): libUE4.so!UMyFunctionLibrary_C__pf398527342::bpf__GetMesh__pf(int, UObject*, UStaticMesh*&)
10-02 01:18:11.684: D/UE4(17252): libUE4.so!UMeshSwitcherWidget_C__pf398527342::bpf__ExecuteUbergraph_MeshSwitcherWidget__pf_0(int)
10-02 01:18:11.684: D/UE4(17252): libUE4.so!UFunction::Invoke(UObject*, FFrame&, void*)
10-02 01:18:11.684: D/UE4(17252): libUE4.so!UObject::ProcessEvent(UFunction*, void*)
10-02 01:18:11.684: D/UE4(17252): libUE4.so!void TMulticastScriptDelegate<FWeakObjectPtr>::ProcessMulticastDelegate<UObject>(void*) const
10-02 01:18:11.684: D/UE4(17252): libUE4.so!UButton::SlateHandleClicked()
10-02 01:18:11.684: D/UE4(17252): libUE4.so!TBaseUObjectMethodDelegateInstance<false, UButton, FReply ()>::Execute() const
10-02 01:18:11.684: D/UE4(17252): libUE4.so!SButton::OnMouseButtonUp(FGeometry const&, FPointerEvent const&)
10-02 01:18:11.684: D/UE4(17252): libUE4.so!FSlateApplication::RoutePointerUpEvent(FWidgetPath&, FPointerEvent&)
10-02 01:18:11.684: D/UE4(17252): libUE4.so!FSlateApplication::ProcessMouseButtonUpEvent(FPointerEvent&)
10-02 01:18:11.684: D/UE4(17252): libUE4.so!FSlateApplication::OnTouchEnded(FVector2D const&, int, int)
10-02 01:18:11.684: D/UE4(17252): libUE4.so!non-virtual thunk to FSlateApplication::OnTouchEnded(FVector2D const&, int, int)
10-02 01:18:11.684: D/UE4(17252): libUE4.so!FAndroidInputInterface::SendControllerEvents()
10-02 01:18:11.684: D/UE4(17252): libUE4.so!FAndroidApplication::PollGameDeviceState(float)
10-02 01:18:11.684: D/UE4(17252): libUE4.so!FEngineLoop::Tick()
10-02 01:18:11.684: D/UE4(17252): libUE4.so!AndroidMain(android_app*)
10-02 01:18:11.684: D/UE4(17252): libUE4.so!android_main()
10-02 01:18:11.684: D/UE4(17252): libUE4.so![Unknown]()
10-02 01:18:11.686: D/UE4(17252): [2016.10.01-22.18.11:685][-6980444]Assertion failed: Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:Runtime/Core/Public/Containers\Array.h] [Line: 804]
10-02 01:18:11.686: D/UE4(17252): Array index out of bounds: 2 from an array of size 0
10-02 01:18:11.686: D/UE4(17252): [2016.10.01-22.18.11:686][-6980444]LogWindows: FAndroidMisc::RequestExit(1)
10-02 01:18:11.688: I/art(17252): System.exit called, status: 0
10-02 01:18:11.688: I/AndroidRuntime(17252): VM exiting with result code 0, cleanup skipped.