mirror of
https://github.com/DCFApixels/Unity-DebugX.git
synced 2025-09-18 10:04:38 +08:00
refactor: skipping gizmos list iteration and camera zoom search if a list is empty.
This commit is contained in:
parent
e8c9fce40e
commit
eff3652307
@ -95,35 +95,22 @@ namespace DCFApixels {
|
|||||||
_labelStyle.richText = false;
|
_labelStyle.richText = false;
|
||||||
_labelDummy = new GUIContent();
|
_labelDummy = new GUIContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (list.Count == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var zoom = GetCameraZoom();
|
||||||
|
|
||||||
Handles.BeginGUI();
|
Handles.BeginGUI();
|
||||||
foreach (ref readonly var item in list)
|
foreach (ref readonly var item in list)
|
||||||
{
|
{
|
||||||
GUI.color = item.Color * GlobalColor;
|
GUI.color = item.Color * GlobalColor;
|
||||||
_labelDummy.text = item.Value.TextBuilderInstance.Text.ToString();
|
_labelDummy.text = item.Value.TextBuilderInstance.Text.ToString();
|
||||||
|
|
||||||
if (item.Value.TextBuilderInstance.UseWorldScale) {
|
_labelStyle.fontSize = item.Value.TextBuilderInstance.UseWorldScale
|
||||||
var zoom = 1f;
|
? Mathf.FloorToInt(item.Value.TextBuilderInstance.FontSize / zoom)
|
||||||
|
: item.Value.TextBuilderInstance.FontSize;
|
||||||
var cam = GetCurrentCamera();
|
|
||||||
if (cam != null) {
|
|
||||||
zoom = cam.orthographicSize;
|
|
||||||
} else {
|
|
||||||
var currentDrawingSceneView = SceneView.currentDrawingSceneView;
|
|
||||||
|
|
||||||
if (currentDrawingSceneView != null
|
|
||||||
&& SceneView.currentDrawingSceneView.camera != null) {
|
|
||||||
cam = currentDrawingSceneView.camera;
|
|
||||||
|
|
||||||
if (camera != null) {
|
|
||||||
zoom = cam.orthographicSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_labelStyle.fontSize = Mathf.FloorToInt(item.Value.TextBuilderInstance.FontSize / zoom);
|
|
||||||
} else {
|
|
||||||
_labelStyle.fontSize = item.Value.TextBuilderInstance.FontSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
_labelStyle.alignment = item.Value.TextBuilderInstance.TextAnchor;
|
_labelStyle.alignment = item.Value.TextBuilderInstance.TextAnchor;
|
||||||
|
|
||||||
@ -149,6 +136,29 @@ namespace DCFApixels {
|
|||||||
}
|
}
|
||||||
Handles.EndGUI();
|
Handles.EndGUI();
|
||||||
GUI.color = defaultColor;
|
GUI.color = defaultColor;
|
||||||
|
|
||||||
|
float GetCameraZoom() {
|
||||||
|
const float DEFAULT_ZOOM = 1f;
|
||||||
|
|
||||||
|
var localCamera = GetCurrentCamera();
|
||||||
|
if (localCamera != null) {
|
||||||
|
return localCamera.orthographicSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
var currentDrawingSceneView = SceneView.currentDrawingSceneView;
|
||||||
|
|
||||||
|
if (currentDrawingSceneView == null) {
|
||||||
|
return DEFAULT_ZOOM;
|
||||||
|
}
|
||||||
|
|
||||||
|
localCamera = currentDrawingSceneView.camera;
|
||||||
|
|
||||||
|
if (camera != null) {
|
||||||
|
return localCamera.orthographicSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DEFAULT_ZOOM;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user