/// <inheritdoc/> protected override void Setup() { label = GUIContentPool.Create(inspector.Preferences.graphics.DebugModeOnIcon, "Debug Mode+: On\nAll class members will be listed even if normally hidden."); }
private static void DrawObjects() { var selObjs = Selection.gameObjects; bool isHadUIRect = false; if (selObjs == null || selObjs.Length <= 0) { } GetUIRoot(); if (UIRoot == null) { return; } Handles.BeginGUI(); { float VEC2_WIDTH = 160; Vector2 size = new Vector2(0, 60); for (int i = 0; i < selObjs.Length; ++i) { if (selObjs[i].transform is RectTransform rectTransform) { isHadUIRect = true; var guiContent = GUIContentPool.Get(selObjs[i].name); var s = GUI.skin.label.CalcSize(guiContent); GUIContentPool.Release(guiContent); if (s.x + VEC2_WIDTH > size.x) { size.x = s.x + VEC2_WIDTH; } size.y += s.y; } } size.x += 16; size.x = Mathf.Max(200, size.x); var prevColor = GUI.color; GUI.color = new Color(0.7f, 0.7f, 0.7f, 1f); GUILayout.BeginArea(new Rect(5, 5, size.x, size.y)); { _isExpandWin = GUILayout.Toggle(_isExpandWin, "选中物体的坐标", (GUIStyle)"ShurikenModuleTitle"); if (_isExpandWin) { GUI.color = prevColor; GUILayout.BeginArea(new Rect(0, 16, size.x, size.y - 16), GUIContent.none, "Badge"); { GUILayout.BeginVertical(); { if (isHadUIRect) { for (int i = 0; i < selObjs.Length; ++i) { if (selObjs[i].transform is RectTransform rectTransform) { GUILayout.BeginHorizontal(); GUILayout.Label(selObjs[i].name, GUILayout.ExpandWidth(false)); var pos = RectTransformPosToLTPos(rectTransform); var pos2 = EditorGUILayout.Vector2Field(GUIContent.none, HandlePrecision(pos), GUILayout.Width(VEC2_WIDTH)); var delta = pos2 - pos; if (delta != Vector2.zero) { delta.y *= -1; rectTransform.anchoredPosition += delta; } GUILayout.EndHorizontal(); } } } else { GUILayout.Label("请选中一个UI对象", "AM MixerHeader"); } GUILayout.EndVertical(); } GUILayout.EndArea(); } } GUILayout.EndArea(); } Handles.EndGUI(); GUI.color = prevColor; } }