This is entirely dependent on the order in which your Draw GUI code gets executed, which gets complicated if there are several instances of objects w/ code in that particular event active at once, which is likely why your solution solves the problem - it makes sure the shader application code runs first.