fix text render

This commit is contained in:
DCFApixels 2025-02-27 16:46:55 +08:00
parent 60938c4d95
commit c5703adc4d
2 changed files with 13 additions and 22 deletions

View File

@ -305,10 +305,10 @@ namespace DCFApixels
if (DebugXUtility.IsGizmosRender()) if (DebugXUtility.IsGizmosRender())
{ {
CallDrawGizmos(camera);
RenderContextController.StaicContextController.Prepare(); RenderContextController.StaicContextController.Prepare();
RenderContextController.StaicContextController.Render(cbExecutor); RenderContextController.StaicContextController.Render(cbExecutor);
CallDrawGizmos(camera);
} }
if (camera == null) { return; } if (camera == null) { return; }
@ -347,7 +347,6 @@ namespace DCFApixels
Color handlesColor = Handles.color; Color handlesColor = Handles.color;
GL.MultMatrix(Handles.matrix); GL.MultMatrix(Handles.matrix);
//TODO ðàñêîìåíòèòü
RenderContextController.StaicContextController.Render_UnityGizmos(); RenderContextController.StaicContextController.Render_UnityGizmos();
if (camera == null) { return; } if (camera == null) { return; }
@ -600,7 +599,7 @@ namespace DCFApixels
_buffers[i].Render_UnityGizmos(); _buffers[i].Render_UnityGizmos();
} }
RunEnd(); //RunEnd();
} }
} }
@ -800,7 +799,7 @@ namespace DCFApixels
public override void Render_UnityGizmos() public override void Render_UnityGizmos()
{ {
if (_rendererUnityGizmos == null) { return; } if (_rendererUnityGizmos == null) { return; }
Debug.Log(_gizmos._count); //Debug.Log(_gizmos._count);
if (_gizmos.Count <= 0) { return; } if (_gizmos.Count <= 0) { return; }
#if DEV_MODE #if DEV_MODE
using (_renderMarker.Auto()) using (_renderMarker.Auto())

View File

@ -39,9 +39,6 @@ namespace DCFApixels
#region Renderer #region Renderer
private class Renderer : IGizmoRenderer_UnityGizmos<TextGizmo> private class Renderer : IGizmoRenderer_UnityGizmos<TextGizmo>
{ {
private static Color32[] _backgroundTexturePixels;
private static Texture2D _backgroundTexture;
private static GUIStyle _labelStyle; private static GUIStyle _labelStyle;
private static GUIStyle _labelStyleWithBackground; private static GUIStyle _labelStyleWithBackground;
private static GUIContent _labelDummy; private static GUIContent _labelDummy;
@ -58,11 +55,8 @@ namespace DCFApixels
Handles.BeginGUI(); Handles.BeginGUI();
foreach (ref readonly var item in list) foreach (ref readonly var item in list)
{ {
GUI.contentColor = item.Color * GlobalColor;
GUI.backgroundColor = item.Value.Settings.BackgroundColor * GlobalColor;
_labelDummy.text = item.Value.Text; _labelDummy.text = item.Value.Text;
GUIStyle style = item.Value.Settings.IsHasBackground ? _labelStyleWithBackground : _labelStyle; GUIStyle style = _labelStyle;
style.fontSize = item.Value.IsWorldSpaceScale style.fontSize = item.Value.IsWorldSpaceScale
? Mathf.FloorToInt(item.Value.Settings.FontSize / zoom) ? Mathf.FloorToInt(item.Value.Settings.FontSize / zoom)
@ -70,15 +64,16 @@ namespace DCFApixels
style.alignment = item.Value.Settings.TextAnchor; style.alignment = item.Value.Settings.TextAnchor;
_labelStyle.normal = new GUIStyleState
{
textColor = item.Color * GlobalColor,
};
if (!(HandleUtility.WorldToGUIPointWithDepth(item.Value.Position).z < 0f)) if (!(HandleUtility.WorldToGUIPointWithDepth(item.Value.Position).z < 0f))
{ {
GUI.Label(HandleUtility.WorldPointToSizedRect(item.Value.Position, _labelDummy, _labelStyle), _labelDummy, style);
Rect rect = HandleUtility.WorldPointToSizedRect(item.Value.Position, _labelDummy, _labelStyle);
Color c = item.Value.Settings.BackgroundColor * GlobalColor;
GUI.color = c;
EditorGUI.DrawRect(rect, c);
GUI.color = item.Color * GlobalColor;
GUI.Label(rect, _labelDummy, style);
} }
} }
Handles.EndGUI(); Handles.EndGUI();
@ -105,14 +100,11 @@ namespace DCFApixels
{ {
backgroundTexturePixels[i] = new Color32(255, 255, 255, 255); backgroundTexturePixels[i] = new Color32(255, 255, 255, 255);
} }
_backgroundTexturePixels = backgroundTexturePixels;
var backgroundTexture = new Texture2D(BACKGROUND_TEXTURE_WIDTH, BACKGROUND_TEXTURE_HEIGHT); var backgroundTexture = new Texture2D(BACKGROUND_TEXTURE_WIDTH, BACKGROUND_TEXTURE_HEIGHT);
backgroundTexture.SetPixels32(backgroundTexturePixels); backgroundTexture.SetPixels32(backgroundTexturePixels);
backgroundTexture.Apply(); backgroundTexture.Apply();
_backgroundTexture = backgroundTexture;
_labelStyleWithBackground = new GUIStyle(_labelStyle); _labelStyleWithBackground = new GUIStyle(_labelStyle);
_labelStyleWithBackground.normal.background = backgroundTexture; _labelStyleWithBackground.normal.background = backgroundTexture;
_labelStyleWithBackground.active.background = backgroundTexture; _labelStyleWithBackground.active.background = backgroundTexture;