-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRectTransformEditor.cs
executable file
·54 lines (49 loc) · 1.8 KB
/
RectTransformEditor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using CustomEditorUtil;
using UnityEngine;
using UnityEditor;
namespace Syy.Tool
{
[CustomEditor(typeof(RectTransform))]
[CanEditMultipleObjects]
public class RectTransformEditor : UnityProvideEditor
{
protected override UnityProvideEditorType EditorType { get { return UnityProvideEditorType.RectTransformEditor; } }
RectTransform[] _targets;
protected override void OnEnable()
{
base.OnEnable();
_targets = targets.Cast<RectTransform>().ToArray();
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
using (new EditorGUILayout.HorizontalScope("box", GUILayout.ExpandWidth(true)))
{
EditorGUILayout.LabelField("Pos & Size", GUILayout.Width(70));
if (GUILayout.Button("Round Point", GUILayout.Width(80)))
{
Undo.RegisterCompleteObjectUndo(_targets, "Round Point");
foreach (var r in _targets)
{
r.RoundPoint();
}
}
if (GUILayout.Button("Round Point (with children)", GUILayout.Width(160)))
{
foreach (var r in _targets)
{
var components = r.GetComponentsInChildren<RectTransform>();
Undo.RegisterCompleteObjectUndo(components, "Round Point");
foreach (var c in components)
{
c.RoundPoint();
}
}
}
}
}
}
}