Fix the bug and prevent scripts switching to 3D if OpneGL is off.

Re #7538
Merge branch 'feature/7538_opengl_issue' into develop