protected override void OnUpdate() { if (!initialized) { return; } var env = World.TinyEnvironment(); var config = env.GetConfigData <DisplayInfo>(); var wantwebgl = config.renderMode == RenderMode.Auto || config.renderMode == RenderMode.WebGL; int wCanvas = 0, hCanvas = 0; HTMLNativeCalls.getCanvasSize(ref wCanvas, ref hCanvas); HTMLNativeCalls.getFrameSize(ref config.frameWidth, ref config.frameHeight); if (config.autoSizeToFrame) { config.width = config.frameWidth; config.height = config.frameHeight; } if (wCanvas != config.width || hCanvas != config.height || wantwebgl != iswebgl) { iswebgl = HTMLNativeCalls.setCanvasSizeAndMode(config.width, config.height, wantwebgl); config.renderMode = iswebgl ? RenderMode.WebGL : RenderMode.Canvas; config.framebufferWidth = config.width; config.framebufferHeight = config.height; } env.SetConfigData(config); double newFrameTime = HTMLNativeCalls.time(); env.StepWallRealtimeFrame(newFrameTime - frameTime); frameTime = newFrameTime; }
protected override void OnStartRunning() { base.OnStartRunning(); if (initialized) { return; } Console.WriteLine("HTML Window init."); try { initialized = HTMLNativeCalls.init(); } catch { Console.WriteLine(" Excepted (Is lib_unity_tiny2d_html.dll missing?)."); initialized = false; } if (!initialized) { Console.WriteLine(" Failed."); return; } var env = World.TinyEnvironment(); var config = env.GetConfigData <DisplayInfo>(); HTMLNativeCalls.getFrameSize(ref config.frameWidth, ref config.frameHeight); HTMLNativeCalls.getScreenSize(ref config.screenWidth, ref config.screenHeight); if (config.autoSizeToFrame) { config.width = config.frameWidth; config.height = config.frameHeight; } bool wantwebgl = config.renderMode == RenderMode.Auto || config.renderMode == RenderMode.WebGL; iswebgl = HTMLNativeCalls.setCanvasSizeAndMode(config.width, config.height, wantwebgl); config.renderMode = iswebgl ? RenderMode.WebGL : RenderMode.Canvas; config.framebufferWidth = config.width; config.framebufferHeight = config.height; env.SetConfigData(config); frameTime = HTMLNativeCalls.time(); }