public static void IsTrue(bool b, FixedString128Bytes s) { if (!b) { Debug.Log(FixedString.Format("<color=red>##### ASSERT => {0}</color>", s)); throw new AssertException(); } }
/// <summary> /// Writes the string representation of a specified 32-bit floating-point number to the buffer. This method will allocate. /// </summary> /// <param name="value">The value to write.</param> public void Write(float value) { Write(FixedString.Format("{0}", value)); }
public void FixedStringFormat() { Assert.AreEqual("1 0", FixedString.Format("{0} {1}", 1, 0)); Assert.AreEqual("0.1 1.2", FixedString.Format("{0} {1}", 0.1f, 1.2f)); Assert.AreEqual("error 500 in line 350: bubbly", FixedString.Format("error {0} in line {1}: {2}", 500, 350, "bubbly")); }
/// <summary> /// Writes the string representation of a specified 64-bit signed integer to the buffer. /// </summary> /// <param name="value">The value to write.</param> public void Write(long value) { Write(FixedString.Format("{0}", value)); }
protected unsafe override void OnUpdate() { var input = World.GetExistingSystem <InputSystem>(); var renderer = World.GetExistingSystem <RendererBGFXSystem>(); var rendererInstance = renderer.InstancePointer(); bool anyShift = input.GetKey(KeyCode.LeftShift) || input.GetKey(KeyCode.RightShift); bool anyCtrl = input.GetKey(KeyCode.LeftControl) || input.GetKey(KeyCode.RightControl); bool anyAlt = input.GetKey(KeyCode.LeftAlt) || input.GetKey(KeyCode.RightAlt); if (!m_configAlwaysRun && !anyShift) { return; } // debug bgfx stuff if (input.GetKey(KeyCode.F2) || (input.GetKey(KeyCode.Alpha2) && anyAlt)) { rendererInstance->SetFlagThisFrame(bgfx.DebugFlags.Stats); } if (input.GetKeyDown(KeyCode.F3) || (input.GetKeyDown(KeyCode.Alpha3) && anyAlt)) { var di = GetSingleton <DisplayInfo>(); if (di.colorSpace == ColorSpace.Gamma) { di.colorSpace = ColorSpace.Linear; } else { di.colorSpace = ColorSpace.Gamma; } SetSingleton(di); renderer.DestroyAllTextures(); renderer.ReloadAllImages(); Debug.LogFormatAlways("Color space is now {0}.", di.colorSpace == ColorSpace.Gamma ? "Gamma (no srgb sampling)" : "Linear"); } if (input.GetKeyDown(KeyCode.F4) || (input.GetKeyDown(KeyCode.Alpha4) && anyAlt)) { var di = GetSingleton <DisplayInfo>(); di.disableVSync = !di.disableVSync; SetSingleton(di); Debug.LogFormatAlways("VSync is now {0}.", di.disableVSync ? "disabled" : "enabled"); } if (input.GetKeyDown(KeyCode.F5) || (input.GetKeyDown(KeyCode.Alpha5) && anyAlt)) { var s = GetSingleton <RenderGraphState>(); Debug.LogFormatAlways("Render buffer size was: {0}*{1}.", s.RenderBufferCurrentWidth, s.RenderBufferCurrentHeight); RenderGraphConfig cfg = GetNextConfig(); SetSingleton(cfg); Debug.LogFormatAlways("Target config is now {0}*{1} {2}.", cfg.RenderBufferHeight, cfg.RenderBufferWidth, cfg.Mode == RenderGraphMode.DirectToFrontBuffer?"direct":"buffer"); } rendererInstance->m_outputDebugSelect = new float4(0, 0, 0, 0); if (input.GetKey(KeyCode.Alpha1)) { rendererInstance->m_outputDebugSelect = new float4(1, 0, 0, 0); } if (input.GetKey(KeyCode.Alpha2)) { rendererInstance->m_outputDebugSelect = new float4(0, 1, 0, 0); } if (input.GetKey(KeyCode.Alpha3)) { rendererInstance->m_outputDebugSelect = new float4(0, 0, 1, 0); } if (input.GetKey(KeyCode.Alpha4)) { rendererInstance->m_outputDebugSelect = new float4(0, 0, 0, 1); } if (input.GetKeyDown(KeyCode.Z)) { renderer.RequestScreenShot(FixedString.Format("screenshot{0}.tga", m_nshots++).ToString()); } if (input.GetKeyDown(KeyCode.Escape)) { Debug.LogFormatAlways("Reloading all textures."); // free all textures - this releases the bgfx textures and invalidates all cached bgfx state that might contain texture handles // note that this does not free system textures like single pixel white, default spotlight etc. renderer.DestroyAllTextures(); // now force a reload on all image2d's from files renderer.ReloadAllImages(); // once images are loaded, but don't have a texture, the texture will be uploaded and the cpu memory freed } if (renderer.HasScreenShot()) { // TODO: save out 32bpp pixel data: Debug.LogFormat("Write screen shot to disk: {0}, {1}*{2}", renderer.m_screenShotPath, renderer.m_screenShotWidth, renderer.m_screenShotHeight); renderer.ResetScreenShot(); } // camera related stuff var ecam = FindCamera(); if (ecam == Entity.Null) { return; } // sync scene camera with game camera position if (input.GetKeyDown(KeyCode.F)) { SyncSceneViewToCamera(ref ecam); } ControlCamera(ecam); Entities.WithoutBurst().WithAll <Light>().ForEach( (Entity eLight, ref LightFromCameraByKey lk, ref Translation tPos, ref Rotation tRot) => { if (input.GetKeyDown(lk.key)) { tPos = EntityManager.GetComponentData <Translation>(ecam); tRot = EntityManager.GetComponentData <Rotation>(ecam); Debug.LogFormat("Set light {0} to {1} {2}", eLight, tPos.Value, tRot.Value.value); } }).Run(); }