├── .gitignore ├── Assets ├── Editor.meta └── Editor │ ├── UGUIToolset.meta │ └── UGUIToolset │ ├── UGUIToolset.cs │ └── UGUIToolset.cs.meta ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | # MemoryCaptures can get excessive in size. 13 | # They also could contain extremely sensitive data 14 | /[Mm]emoryCaptures/ 15 | # Asset meta data should only be ignored when the corresponding asset is also ignored 16 | !/[Aa]ssets/**/*.meta 17 | # Uncomment this line if you wish to ignore the asset store tools plugin 18 | # /[Aa]ssets/AssetStoreTools* 19 | # Autogenerated Jetbrains Rider plugin 20 | /[Aa]ssets/Plugins/Editor/JetBrains* 21 | # Visual Studio cache directory 22 | .vs/ 23 | # Gradle cache directory 24 | .gradle/ 25 | # Autogenerated VS/MD/Consulo solution and project files 26 | ExportedObj/ 27 | .consulo/ 28 | *.csproj 29 | *.unityproj 30 | *.sln 31 | *.suo 32 | *.tmp 33 | *.user 34 | *.userprefs 35 | *.pidb 36 | *.booproj 37 | *.svd 38 | *.pdb 39 | *.mdb 40 | *.opendb 41 | *.VC.db 42 | # Unity3D generated meta files 43 | *.pidb.meta 44 | *.pdb.meta 45 | *.mdb.meta 46 | # Unity3D generated file on crash reports 47 | sysinfo.txt 48 | # Builds 49 | *.apk 50 | *.aab 51 | *.unitypackage 52 | # Crashlytics generated file 53 | crashlytics-build.properties 54 | # Packed Addressables 55 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 56 | # Temporary auto-generated Android Assets 57 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 58 | /[Aa]ssets/[Ss]treamingAssets/aa/* 59 | /.idea* 60 | /Assets/TextMesh Pro/* 61 | /ProjectSettings/* 62 | /Packages/* 63 | -------------------------------------------------------------------------------- /Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09d8ec616aa381a4fb862f28a2afffa9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Editor/UGUIToolset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 016f33e365d696240b26b2a15c333081 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Editor/UGUIToolset/UGUIToolset.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------- 2 | //UGUI Toolset v0.55 3 | //Author: Andrew Vasiliev [@AndrewChewie] 4 | //--------------------------------------- 5 | 6 | using System; 7 | using UnityEngine; 8 | using System.Collections; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using TMPro; 12 | using UnityEditor; 13 | using UnityEngine.UI; 14 | 15 | public class UGUIToolset : EditorWindow 16 | { 17 | [MenuItem("Window/UGUI Toolset")] 18 | public static void ShowWindow() 19 | { 20 | GetWindow(typeof(UGUIToolset)); 21 | } 22 | 23 | private class LayoutData 24 | { 25 | public UILayout LayoutType = UILayout.Vertical; 26 | public RectOffset padding = new RectOffset(); 27 | public TextAnchor childAlignment = TextAnchor.UpperLeft; 28 | public bool childForceExpandHeight; 29 | public bool childForceExpandWidth; 30 | public float spacing; 31 | 32 | public LayoutData() 33 | { 34 | 35 | } 36 | 37 | public LayoutData(HorizontalOrVerticalLayoutGroup layoutGroup) 38 | { 39 | if (layoutGroup != null) 40 | { 41 | if (layoutGroup.GetComponent() != null) 42 | LayoutType = UILayout.Vertical; 43 | 44 | if (layoutGroup.GetComponent() != null) 45 | LayoutType = UILayout.Horizontal; 46 | 47 | spacing = layoutGroup.spacing; 48 | padding = layoutGroup.padding; 49 | childAlignment = layoutGroup.childAlignment; 50 | childForceExpandHeight = layoutGroup.childForceExpandHeight; 51 | childForceExpandWidth = layoutGroup.childForceExpandWidth; 52 | } 53 | else 54 | { 55 | new LayoutData(); 56 | } 57 | } 58 | } 59 | 60 | private enum UILayout 61 | { 62 | Vertical, 63 | Horizontal 64 | } 65 | 66 | private GameObject SelectedObject 67 | { 68 | get 69 | { 70 | if (_selectedObjects == null || _selectedObjects.Count == 0) 71 | return null; 72 | 73 | return _selectedObjects[0].gameObject; 74 | } 75 | } 76 | 77 | private List _selectedObjects; 78 | private List SelectedObjects 79 | { 80 | get { 81 | if (IncludeChild) 82 | { 83 | var result = new HashSet(); 84 | foreach (Transform o in _selectedObjects) 85 | { 86 | result.Add(o); 87 | if (IncludeRecursively) 88 | { 89 | foreach (Transform c in o.GetComponentsInChildren(true)) 90 | { 91 | result.Add(c); 92 | } 93 | } 94 | else 95 | { 96 | foreach (Transform c in o.transform) 97 | { 98 | result.Add(c); 99 | } 100 | } 101 | } 102 | 103 | result.RemoveWhere(transform => transform.GetComponent() == null); 104 | 105 | return new List(result); 106 | } 107 | 108 | return _selectedObjects; 109 | } 110 | set { _selectedObjects = value; } 111 | } 112 | 113 | private bool IncludeChild = false; 114 | private bool IncludeRecursively = false; 115 | 116 | void OnEnable() 117 | { 118 | SceneView.onSceneGUIDelegate += OnSceneGui; 119 | } 120 | 121 | private void OnSceneGui(SceneView sceneView) 122 | { 123 | Event e = Event.current; 124 | 125 | Repaint(); 126 | } 127 | 128 | float buttonWidth = 100; 129 | float buttonHeight = 30; 130 | 131 | private void OnGUI() 132 | { 133 | RefreshSelection(); 134 | 135 | IncludeChild = GUILayout.Toggle(IncludeChild, "Include Child Objects", GUILayout.MinWidth(buttonWidth),GUILayout.MinHeight(20)); 136 | 137 | if(IncludeChild) 138 | IncludeRecursively = GUILayout.Toggle(IncludeRecursively, "Include Recursively", GUILayout.MinWidth(buttonWidth),GUILayout.MinHeight(20)); 139 | 140 | DrawUILine(Color.black); 141 | 142 | if (GUILayout.Button("Group selected", GUILayout.MinWidth(buttonWidth), GUILayout.MinHeight(buttonHeight))) 143 | { 144 | GroupSelected(); 145 | } 146 | if (GUILayout.Button("Add Child", GUILayout.MinWidth(buttonWidth), GUILayout.MinHeight(buttonHeight))) 147 | { 148 | AddEmptyChild(); 149 | } 150 | 151 | GUI.color = Color.white; 152 | 153 | if (!WrongObject && SelectedObject.GetComponent()) 154 | GUI.color = Color.green; 155 | 156 | if (GUILayout.Button("V Group", GUILayout.MinWidth(buttonWidth),GUILayout.MinHeight(buttonHeight))) 157 | { 158 | SetLayout(UILayout.Vertical); 159 | } 160 | 161 | GUI.color = Color.white; 162 | 163 | if (!WrongObject && SelectedObject.GetComponent()) 164 | GUI.color = Color.green; 165 | 166 | if (GUILayout.Button("H Group", GUILayout.MinWidth(buttonWidth), GUILayout.MinHeight(buttonHeight))) 167 | { 168 | SetLayout(UILayout.Horizontal); 169 | } 170 | 171 | GUI.color = Color.white; 172 | 173 | if (GUILayout.Button("Flip layout", GUILayout.MinWidth(buttonWidth), GUILayout.MinHeight(buttonHeight))) 174 | { 175 | FlipLayout(); 176 | } 177 | 178 | GUI.color = Color.white; 179 | 180 | if (!WrongObject && SelectedObject.GetComponent()) 181 | GUI.color = Color.green; 182 | 183 | if (GUILayout.Button("Content Size", GUILayout.MinWidth(buttonWidth), GUILayout.MinHeight(buttonHeight))) 184 | { 185 | AddContentSizeFitter(); 186 | } 187 | 188 | GUI.color = Color.white; 189 | 190 | if (!WrongObject && SelectedObject.GetComponent()) 191 | GUI.color = Color.green; 192 | 193 | if (GUILayout.Button("Layout Element", GUILayout.MinWidth(buttonWidth), GUILayout.MinHeight(buttonHeight))) 194 | { 195 | AddUIComponent(typeof(LayoutElement)); 196 | } 197 | 198 | GUI.color = Color.white; 199 | 200 | if (!WrongObject && SelectedObject.GetComponent()) 201 | GUI.color = Color.green; 202 | 203 | if (GUILayout.Button("Add Image", GUILayout.MinWidth(buttonWidth), GUILayout.MinHeight(buttonHeight))) 204 | { 205 | AddUIComponent(typeof(Image)); 206 | } 207 | 208 | GUI.color = Color.white; 209 | 210 | if (!WrongObject && SelectedObject.GetComponent