ERROR:SCRIPT: main/change_shader.script:11: go.set failed with error code -10
stack traceback:
[C]:-1: in function set
main/change_shader.script:11: in function <main/change_shader.script:8>
Assertion failed: i < Size(), file D:\a\defold\defold\tmp\dynamo_home\sdk\include\dmsdk/dlib/array.h, line 494
INFO:CRASH: Successfully wrote Crashdump to file: C:\Users\Mike\AppData\Roaming\Defold/_crash
ERROR:CRASH: CALL STACK:
ERROR:CRASH: 0 0x7FF7018E4030 dmCrash::GenerateCallstack D:\a\defold\defold\engine\crash\src\backtrace_win32.cpp:144
ERROR:CRASH: 1 0x7FF7019DBC4C raise minkernel\crts\ucrt\src\appcrt\misc\signal.cpp:547
ERROR:CRASH: 2 0x7FF7019BFBCC abort minkernel\crts\ucrt\src\appcrt\startup\abort.cpp:71
ERROR:CRASH: 3 0x7FF70196F5B8 common_assert_to_stderr<wchar_t> minkernel\crts\ucrt\src\appcrt\startup\assert.cpp:186
ERROR:CRASH: 4 0x7FF70196FC70 _wassert minkernel\crts\ucrt\src\appcrt\startup\assert.cpp:443
ERROR:CRASH: 5 0x7FF701611AF0 dmGameSystem::RenderBatch D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_sprite.cpp:1319
ERROR:CRASH: 6 0x7FF7016121A0 dmGameSystem::RenderListDispatch D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_sprite.cpp:1733
ERROR:CRASH: 7 0x7FF7016EA5C0 dmRender::DrawRenderList D:\a\defold\defold\engine\render\src\render\render.cpp:894
ERROR:CRASH: 8 0x7FF701708CB0 dmRender::ParseCommands D:\a\defold\defold\engine\render\src\render\render_command.cpp:183
ERROR:CRASH: 9 0x7FF7016F7090 dmRender::UpdateRenderScriptInstance D:\a\defold\defold\engine\render\src\render\render_script.cpp:3607
ERROR:CRASH: 10 0x7FF70152FB30 dmEngine::StepFrame D:\a\defold\defold\engine\engine\src\engine.cpp:1687
ERROR:CRASH: 11 0x7FF701530890 dmEngineUpdate D:\a\defold\defold\engine\engine\src\engine.cpp:2189
ERROR:CRASH: 12 0x7FF701530AC0 dmEngine::RunLoop D:\a\defold\defold\engine\engine\src\engine_loop.cpp:83
ERROR:CRASH: 13 0x7FF701528CA0 engine_main D:\a\defold\defold\engine\engine\src\engine_main.cpp:152
ERROR:CRASH: 14 0x7FF701951BA4 __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
ERROR:CRASH: 15 0x7FF80B422560 BaseThreadInitThunk <unknown>:0
ERROR:CRASH: 16 0x7FF80C2EAA20 RtlUserThreadStart <unknown>:0
ERROR:CRASH:
This is the code I’m using. And yes I know I’m created the same material twice. I’m just doing this as a test. 2nd material will be entered once I get this working.
function init(self)
-- Store references to the materials
self.material1 = hash("/assets/rainbow/rainbow.materialc")
self.material2 = hash("/assets/rainbow/rainbow.materialc")
--self.material2 = resource.load("/assets/materials/holographic/holographic.materialc")
end
function on_message(self, message_id, message, sender)
if message_id == hash("change_shader") then
if message.shader == 1 then
go.set("#sprite", "material", self.material1)
elseif message.shader == 2 then
go.set("#sprite", "material", self.material2)
end
-- ... handle more shaders as needed
end
end