In my cocos 3.8.3, I have project settings as -
DesignWidth - 1920
DesignHeight - 1080
fitwidth - true
fitheight - true
when I run this through the editor/simulator, it opens it in a browser, when I click the “Inspect” on the right click, it gives me options to choose various devices. Here, when I choose a different device, the game window resizes based on the device selected and my index.html gets updated -
<div id="GameDiv" class="wrapper" style="display: flex; justify-content: center; align-items: center; transform: rotate(0deg); margin: 0px auto; width: 414px; height: 896px;">
<div id="Cocos3dGameContainer" style="width: 100%; height: 100%;">
<canvas id="GameCanvas" tabindex="-1" style="background-color: '';" width="828" height="1792"></canvas>
</div>
<div id="splash" style="visibility: visible; display: none;">
<div class="progress-bar stripes"><span style="width: 60%;"></span></div>
</div>
<div id="bulletin">
<div id="sceneIsEmpty" class="inner">There's nothing in scene to preview.Add something to the scene now!</div>
</div>
<div class="error" id="error">
<div class="title">Error <i>(Please open the console to see detailed errors)</i></div>
<div class="error-main"></div>
<div class="error-stack"></div>
</div>
</div>
However, when I Build this and open the index.html in the build folder, or when I open the build folder through visual studio code and open it through “goLive”. Now, when I click on the inspect button, and choose a device, the windowsize doesnt fit the resolution of the device. The index.html is -
<div id="GameDiv" cc_exact_fit_screen="false" style="width: 1920px; height: 1080px; display: flex; justify-content: center; align-items: center;">
<div id="Cocos3dGameContainer" style="width: 100%; height: 100%;">
<canvas id="GameCanvas" width="3840" height="2160" tabindex="99"></canvas>
</div>
</div>
Why is my build behaving differently ? How do I fit my game on various devices ?