static void DrawSims <SimType>(LodDataMgr lodData, bool showByDefault, ref float offset) where SimType : LodDataMgr { if (lodData == null) { return; } var type = typeof(SimType); if (!_drawTargets.ContainsKey(type)) { _drawTargets.Add(type, showByDefault); } if (!_simNames.ContainsKey(type)) { _simNames.Add(type, type.Name.Substring(10)); } float b = 7f; float h = Screen.height / (float)lodData.DataTexture.volumeDepth; float w = h + b; float x = Screen.width - w * offset + b * (offset - 1f); if (_drawTargets[type]) { for (int idx = 0; idx < lodData.DataTexture.volumeDepth; idx++) { float y = idx * h; if (offset == 1f) { w += b; } // We cannot debug draw texture arrays directly // (unless we write our own system for doing so). // So for now, we just copy each texture and then draw that. if (!shapes.ContainsKey(lodData.DataTexture.format)) { var rt = new RenderTexture(lodData.DataTexture); rt.dimension = UnityEngine.Rendering.TextureDimension.Tex2D; rt.Create(); shapes.Add(lodData.DataTexture.format, rt); } RenderTexture shape = shapes[lodData.DataTexture.format]; Graphics.CopyTexture(lodData.DataTexture, idx, 0, shape, 0, 0); GUI.color = Color.black * 0.7f; GUI.DrawTexture(new Rect(x, y, w - b, h), Texture2D.whiteTexture); GUI.color = Color.white; GUI.DrawTexture(new Rect(x + b, y + b / 2f, h - b, h - b), shape, ScaleMode.ScaleAndCrop, false); } } _drawTargets[type] = GUI.Toggle(new Rect(x + b, Screen.height - 25f, w - 2f * b, 25f), _drawTargets[type], _simNames[type]); offset++; }
static void DrawSims <SimType>(LodDataMgr lodData, bool showByDefault, ref float offset) where SimType : LodDataMgr { if (lodData == null) { return; } var type = typeof(SimType); if (!_drawTargets.ContainsKey(type)) { _drawTargets.Add(type, showByDefault); } if (!_simNames.ContainsKey(type)) { _simNames.Add(type, type.Name.Substring(10)); } float togglesBegin = Screen.height - _bottomPanelHeight; float b = 7f; float h = togglesBegin / (float)lodData.DataTexture.volumeDepth; float w = h + b; float x = Screen.width - w * offset + b * (offset - 1f); if (_drawTargets[type]) { GUI.color = _guiColor; GUI.DrawTexture(new Rect(x, 0, offset == 1f ? w : w - b, Screen.height - _bottomPanelHeight), Texture2D.whiteTexture); GUI.color = Color.white; // Only use Graphics.DrawTexture in EventType.Repaint events if called in OnGUI if (Event.current.type.Equals(EventType.Repaint)) { for (int idx = 0; idx < lodData.DataTexture.volumeDepth; idx++) { float y = idx * h; if (offset == 1f) { w += b; } // Render specific slice of 2D texture array textureArrayMaterial.SetInt("_Depth", idx); Graphics.DrawTexture(new Rect(x + b, y + b / 2f, h - b, h - b), lodData.DataTexture, textureArrayMaterial); } } } _drawTargets[type] = GUI.Toggle(new Rect(x + b, togglesBegin, w - 2f * b, _bottomPanelHeight), _drawTargets[type], _simNames[type]); offset++; }
static void DrawSims <SimType>(LodDataMgr lodData, bool showByDefault, ref float offset) where SimType : LodDataMgr { if (lodData == null) { return; } var type = typeof(SimType); if (!_drawTargets.ContainsKey(type)) { _drawTargets.Add(type, showByDefault); } if (!_simNames.ContainsKey(type)) { _simNames.Add(type, type.Name.Substring(10)); } float b = 7f; float h = Screen.height / (float)OceanRenderer.Instance._lods.Length; float w = h + b; float x = Screen.width - w * offset + b * (offset - 1f); if (_drawTargets[type]) { for (int idx = 0; idx < OceanRenderer.Instance.CurrentLodCount; idx++) { float y = idx * h; if (offset == 1f) { w += b; } RenderTexture shape; shape = lodData.DataTexture(idx); if (shape == null) { continue; } GUI.color = Color.black * 0.7f; GUI.DrawTexture(new Rect(x, y, w - b, h), Texture2D.whiteTexture); GUI.color = Color.white; GUI.DrawTexture(new Rect(x + b, y + b / 2f, h - b, h - b), shape, ScaleMode.ScaleAndCrop, false); } } _drawTargets[type] = GUI.Toggle(new Rect(x + b, Screen.height - 25f, w - 2f * b, 25f), _drawTargets[type], _simNames[type]); offset++; }