In response to challenges in traditional offline experiments in optical physics, such as high trial-and-error costs, expensive equipment, limited design parameters, and restricted explanations of instrument structures and principles, this paper proposes a design method for an optical physics virtual simulation system based on Unreal Engine 5. The method employs a generic design architecture to partition system units and utilizes technologies like pixel streaming, rendering engines, and physics engines to implement the design of the virtual simulation system. This system covers the entire experimental process, including video learning, instrument adjustment, phenomenon observation, data measurement and recording, and grade inquiry. The proposed design method enhances the immersive experience of experiments, reduces the hardware performance requirements for users, and allows access and utilization across multiple platforms. It efficiently facilitates physics teaching through simulated experiments, thereby effectively improving the quality of experimental teaching. Finally, through a comparison with existing virtual simulation systems, it is demonstrated that the system can save approximately 94.76% of the average CPU usage and provide better immersion and user experience advantages.