├── Editor.meta ├── Editor ├── UniUGUIToolbar.asmdef ├── UniUGUIToolbar.asmdef.meta ├── uGUIToolbar.cs └── uGUIToolbar.cs.meta ├── LICENSE.md ├── LICENSE.md.meta ├── README.md ├── README.md.meta ├── package.json └── package.json.meta /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: de74dda411904c0409468ce6bc4bacbe 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/UniUGUIToolbar.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniUGUIToolbar", 3 | "references": [], 4 | "includePlatforms": [ 5 | "Editor" 6 | ], 7 | "excludePlatforms": [], 8 | "allowUnsafeCode": false, 9 | "overrideReferences": false, 10 | "precompiledReferences": [], 11 | "autoReferenced": false, 12 | "defineConstraints": [], 13 | "versionDefines": [], 14 | "noEngineReferences": false 15 | } -------------------------------------------------------------------------------- /Editor/UniUGUIToolbar.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70519932ad293504c913d1f2b707a869 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/uGUIToolbar.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | namespace UniUGUIToolbar 7 | { 8 | public sealed class uGUIToolbar : EditorWindow 9 | { 10 | private sealed class Data 11 | { 12 | public Type Type { get; } 13 | public string CommandRoot { get; } 14 | public string CommandName { get; } 15 | 16 | public Data() 17 | { 18 | } 19 | 20 | public Data( Type type, string commandRoot, string commandName ) 21 | { 22 | Type = type; 23 | CommandRoot = commandRoot; 24 | CommandName = commandName; 25 | } 26 | } 27 | 28 | private const string TITLE = "uGUI"; 29 | private const float WINDOW_WIDTH = 32; 30 | private const float WINDOW_HEIGHT = 28; 31 | 32 | private static readonly GUILayoutOption[] BUTTON_OPTIONS = 33 | { 34 | GUILayout.MinWidth( 28 ), 35 | GUILayout.MaxWidth( 48 ), 36 | GUILayout.Height( 24 ), 37 | }; 38 | 39 | private static readonly Data[] DATA_LIST = 40 | { 41 | new Data( typeof( GameObject ), "GameObject/", "Create Empty Child" ), 42 | new Data( typeof( Text ), "GameObject/UI/", "Text" ), 43 | new Data( typeof( Image ), "GameObject/UI/", "Image" ), 44 | new Data( typeof( RawImage ), "GameObject/UI/", "Raw Image" ), 45 | new Data( typeof( Button ), "GameObject/UI/", "Button" ), 46 | new Data( typeof( Toggle ), "GameObject/UI/", "Toggle" ), 47 | new Data( typeof( Slider ), "GameObject/UI/", "Slider" ), 48 | new Data( typeof( Scrollbar ), "GameObject/UI/", "Scrollbar" ), 49 | new Data( typeof( Dropdown ), "GameObject/UI/", "Dropdown" ), 50 | new Data( typeof( InputField ), "GameObject/UI/", "Input Field" ), 51 | new Data( typeof( Canvas ), "GameObject/UI/", "Canvas" ), 52 | new Data( typeof( ScrollRect ), "GameObject/UI/", "Scroll View" ), 53 | new Data(), 54 | new Data( typeof( Shadow ), "Component/UI/Effects/", "Shadow" ), 55 | new Data( typeof( Outline ), "Component/UI/Effects/", "Outline" ), 56 | new Data( typeof( PositionAsUV1 ), "Component/UI/Effects/", "Position As UV1" ), 57 | new Data( typeof( Mask ), "Component/UI/", "Mask" ), 58 | new Data( typeof( RectMask2D ), "Component/UI/", "Rect Mask 2D" ), 59 | }; 60 | 61 | private bool IsVertical => false; 62 | 63 | [MenuItem( "Window/UniUGUIToolbar" )] 64 | private static void Init() 65 | { 66 | var win = GetWindow( TITLE ); 67 | 68 | var pos = win.position; 69 | pos.width = 640; 70 | pos.height = WINDOW_HEIGHT; 71 | win.position = pos; 72 | 73 | win.minSize = new Vector2( WINDOW_WIDTH, WINDOW_HEIGHT ); 74 | 75 | var maxSize = win.maxSize; 76 | maxSize.y = WINDOW_HEIGHT; 77 | win.maxSize = maxSize; 78 | } 79 | 80 | private void OnGUI() 81 | { 82 | if ( IsVertical ) 83 | { 84 | GUILayout.BeginVertical(); 85 | } 86 | else 87 | { 88 | GUILayout.BeginHorizontal(); 89 | } 90 | 91 | foreach ( var n in DATA_LIST ) 92 | { 93 | var type = n.Type; 94 | if ( type == null ) 95 | { 96 | var options = IsVertical 97 | ? new[] { GUILayout.MinWidth( 28 ), GUILayout.MaxWidth( 48 ), GUILayout.Height( 1 ) } 98 | : new[] { GUILayout.Height( 24 ), GUILayout.Width( 1 ) } 99 | ; 100 | GUILayout.Box( string.Empty, options ); 101 | continue; 102 | } 103 | 104 | var commandName = n.CommandName; 105 | var src = EditorGUIUtility.ObjectContent( null, type ); 106 | var content = new GUIContent( src ) 107 | { 108 | text = string.Empty, 109 | tooltip = commandName, 110 | }; 111 | if ( !GUILayout.Button( content, BUTTON_OPTIONS ) ) continue; 112 | var commandRoot = n.CommandRoot; 113 | var menuItemPath = $"{commandRoot}{commandName}"; 114 | EditorApplication.ExecuteMenuItem( menuItemPath ); 115 | } 116 | 117 | if ( IsVertical ) 118 | { 119 | GUILayout.EndVertical(); 120 | } 121 | else 122 | { 123 | GUILayout.EndHorizontal(); 124 | } 125 | } 126 | 127 | //public void AddItemsToMenu( GenericMenu menu ) 128 | //{ 129 | // menu.AddItem 130 | // ( 131 | // new GUIContent( "Vertical" ), IsVertical, () => 132 | // { 133 | // IsVertical = !IsVertical; 134 | // } 135 | // ); 136 | //} 137 | } 138 | } -------------------------------------------------------------------------------- /Editor/uGUIToolbar.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6456c81716490464d8bdae4ce9d2a918 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 baba_s 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec61fdaf047be4946a40104cbacda477 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Uni UGUI Toolbar 2 | 3 | uGUI のオブジェクトを作成できるツールバーのエディタ拡張 4 | 5 | ## 使い方 6 | 7 | ![2020-04-22_231051](https://user-images.githubusercontent.com/6134875/79992698-d04cd300-84ee-11ea-9149-89e67cde7631.png) 8 | 9 | Unity メニューの「Window > UniUGUIToolbar」を選択すると 10 | 11 | ![2020-04-22_230814](https://user-images.githubusercontent.com/6134875/79992329-4d2b7d00-84ee-11ea-9d3c-10e75118b089.png) 12 | 13 | uGUI のオブジェクトを作成できるツールバーを表示できます 14 | 15 | ## 関連記事 16 | 17 | * http://baba-s.hatenablog.com/entry/2018/02/27/090000 18 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c5a22d09b975fa41949f6a1c109afa0 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.baba-s.uni-ugui-toolbar", 3 | "displayName": "UniUGUIToolbar", 4 | "version": "1.0.0", 5 | "unity": "2019.2", 6 | "author": "baba-s", 7 | "description": "", 8 | "dependencies": {} 9 | } -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 029a3b4ca551788488f97899dd936ba4 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------