├── Images ├── console.png ├── inspector.png └── parameters.png ├── Assets ├── EasyButtons │ ├── Editor │ │ ├── Utils.meta │ │ ├── Button.cs.meta │ │ ├── ButtonsDrawer.cs.meta │ │ ├── ButtonWithParams.cs.meta │ │ ├── NonSerializedError.cs.meta │ │ ├── Utils │ │ │ ├── DrawUtility.cs.meta │ │ │ ├── EnumExtensions.cs.meta │ │ │ ├── StringExtensions.cs.meta │ │ │ ├── TypeExtensions.cs.meta │ │ │ ├── DefaultValuesUtility.cs.meta │ │ │ ├── ScriptableObjectCache.cs.meta │ │ │ ├── StringExtensions.cs │ │ │ ├── DrawUtility.cs │ │ │ ├── ScriptableObjectCache.cs │ │ │ ├── DefaultValuesUtility.cs │ │ │ ├── EnumExtensions.cs │ │ │ └── TypeExtensions.cs │ │ ├── ButtonWithParamsAsync.cs.meta │ │ ├── ButtonWithoutParams.cs.meta │ │ ├── NoScriptFieldEditor.cs.meta │ │ ├── EasyButtons.Editor.asmdef.meta │ │ ├── ObjectEditor.cs.meta │ │ ├── ButtonWithoutParamsAsync.cs.meta │ │ ├── EasyButtons.Editor.asmdef │ │ ├── NonSerializedError.cs │ │ ├── ButtonWithoutParamsAsync.cs │ │ ├── ObjectEditor.cs │ │ ├── ButtonWithoutParams.cs │ │ ├── ButtonWithParamsAsync.cs │ │ ├── ButtonsDrawer.cs │ │ ├── NoScriptFieldEditor.cs │ │ ├── Button.cs │ │ └── ButtonWithParams.cs │ ├── package.json.meta │ ├── Editor.meta │ ├── Runtime.meta │ ├── Samples.meta │ ├── Runtime │ │ ├── EasyButtons.asmdef.meta │ │ ├── ButtonAttribute.cs.meta │ │ ├── EasyButtons.asmdef │ │ └── ButtonAttribute.cs │ ├── Samples │ │ ├── ButtonsExample.meta │ │ ├── CustomEditorButtonsExample.meta │ │ ├── ScriptableObjectExample.meta │ │ ├── CustomEditorButtonsExample │ │ │ ├── Editor.meta │ │ │ ├── CustomEditorButtonsExample.cs.meta │ │ │ ├── Editor │ │ │ │ ├── CustomEditorButtonsExampleEditor.cs.meta │ │ │ │ └── CustomEditorButtonsExampleEditor.cs │ │ │ └── CustomEditorButtonsExample.cs │ │ ├── ButtonsExample │ │ │ ├── ButtonsExample.cs.meta │ │ │ └── ButtonsExample.cs │ │ └── ScriptableObjectExample │ │ │ ├── ScriptableObjectExample.cs.meta │ │ │ └── ScriptableObjectExample.cs │ └── package.json └── EasyButtons.meta ├── CHANGELOG.md ├── .releaserc.json ├── LICENSE.txt ├── .github └── workflows │ └── ci.yml ├── .gitignore └── README.md /Images/console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madsbangh/EasyButtons/HEAD/Images/console.png -------------------------------------------------------------------------------- /Images/inspector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madsbangh/EasyButtons/HEAD/Images/inspector.png -------------------------------------------------------------------------------- /Images/parameters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madsbangh/EasyButtons/HEAD/Images/parameters.png -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/Utils.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 792a4c9877db4b09953c4806f46702c4 3 | timeCreated: 1607333184 -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/Button.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b377c54771a4165ac6d1f6e29ae4881 3 | timeCreated: 1607259837 -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/ButtonsDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 261021260efd459caa00f9b4d2730b19 3 | timeCreated: 1612122787 -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/ButtonWithParams.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 547012a77e524de1ab552bc61fb2d86c 3 | timeCreated: 1607331593 -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/NonSerializedError.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae856c0314f04c6fbe79a26e72120a66 3 | timeCreated: 1607338452 -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/Utils/DrawUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cae5c4c4901c48e28018c254fa1c02ca 3 | timeCreated: 1607330049 -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/ButtonWithParamsAsync.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a48d172e2547fc4c933854b911246ab 3 | timeCreated: 1607331593 -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/ButtonWithoutParams.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b4207a27842d47e5a88925eff62b719c 3 | timeCreated: 1607331600 -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/NoScriptFieldEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87b76317e25d4e83a3efcaed567e25b7 3 | timeCreated: 1607178139 -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/Utils/EnumExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 41d3eb60b3e34bed966336bcbdadd884 3 | timeCreated: 1610878573 -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/Utils/StringExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19e7617480844aed83d94006c9bfeaa3 3 | timeCreated: 1607174721 -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/Utils/TypeExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef69f98eed3a436b94630cc2603a4d4e 3 | timeCreated: 1607338526 -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/Utils/DefaultValuesUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f517b5ce3b3f46569f718a63e197f837 3 | timeCreated: 1693851553 -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/Utils/ScriptableObjectCache.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 176d46099d46451485d24bf497902d84 3 | timeCreated: 1607173249 -------------------------------------------------------------------------------- /Assets/EasyButtons/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 135397adcb17a5e40996eb8bca0f39ad 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/EasyButtons.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22f76eb86a6118e40ae61f396abb39fb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9a882ead01ff7c4f97a493e20884f90 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b3450edb09e2f142b0e7a79683276a4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Samples.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b32bf1297abcba44a828360606451030 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Runtime/EasyButtons.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f24cf67903b27ae498b3069ecc30cc11 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/EasyButtons.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80120b1292c15624a97f2c7983a70cea 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Samples/ButtonsExample.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7e31e9ef19f2c5409591faae03ae593 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Samples/CustomEditorButtonsExample.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6abd78d298c0460489f0ca4eeeee598b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Samples/ScriptableObjectExample.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a98e7bef7713bd408bc9fba493e762d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Samples/CustomEditorButtonsExample/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 84113de9d8afe394491dbc39eecda8fb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/ObjectEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fdd835899c281654e8b195ef253430ee 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Runtime/ButtonAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ae9ef9818cee0749aec4e8bee4a50dd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/ButtonWithoutParamsAsync.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b250c1fbffc14964fb80e3bfd5be3643 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Samples/ButtonsExample/ButtonsExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc63a60957d42df44af3dada9768b5ad 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Samples/ScriptableObjectExample/ScriptableObjectExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29387bda94bad6043814982231628d6b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Samples/CustomEditorButtonsExample/CustomEditorButtonsExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d44ed66702a1b7498777dfb60046abb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Samples/CustomEditorButtonsExample/Editor/CustomEditorButtonsExampleEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 182f73d89d323c64294c6ef124838f11 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Runtime/EasyButtons.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "EasyButtons", 3 | "references": [], 4 | "optionalUnityReferences": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": false, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": true, 11 | "defineConstraints": [], 12 | "versionDefines": [] 13 | } 14 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/EasyButtons.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "EasyButtons.Editor", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:f24cf67903b27ae498b3069ecc30cc11" 6 | ], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": true, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [], 17 | "noEngineReferences": false 18 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # [1.3.0](https://github.com/madsbangh/EasyButtons/compare/v1.2.0...v1.3.0) (2021-06-15) 2 | 3 | 4 | ### Features 5 | 6 | * Bump package version to 1.3.0 ([cd274bc](https://github.com/madsbangh/EasyButtons/commit/cd274bc159149846469f589528032554c29dcf51)) 7 | 8 | # [1.2.0](https://github.com/madsbangh/EasyButtons/compare/v1.1.0...v1.2.0) (2021-02-05) 9 | 10 | 11 | ### Features 12 | 13 | * Started using semantic versioning ([8071bf9](https://github.com/madsbangh/EasyButtons/commit/8071bf95d2e3af651857a3b470017b371fb0cc45)) 14 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Samples/CustomEditorButtonsExample/CustomEditorButtonsExample.cs: -------------------------------------------------------------------------------- 1 | namespace EasyButtons.Example 2 | { 3 | using UnityEngine; 4 | 5 | public class CustomEditorButtonsExample : MonoBehaviour 6 | { 7 | [Button("Custom Editor Example")] 8 | private void SayHello() 9 | { 10 | Debug.Log("Hello from custom editor"); 11 | } 12 | 13 | [Button] 14 | private void SecondButton() 15 | { 16 | Debug.Log("Second button of the custom editor."); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.releaserc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tagFormat": "v${version}", 3 | "plugins": [ 4 | ["@semantic-release/commit-analyzer", { "preset": "angular" }], 5 | "@semantic-release/release-notes-generator", 6 | ["@semantic-release/changelog", { "preset": "angular" }], 7 | ["@semantic-release/npm", { "npmPublish": false, "pkgRoot": "Assets/EasyButtons" }], 8 | ["@semantic-release/git", { 9 | "assets": ["Assets/EasyButtons/package.json", "CHANGELOG.md"], 10 | "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" 11 | }], 12 | "@semantic-release/github" 13 | ] 14 | } -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/Utils/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace EasyButtons.Editor.Utils 2 | { 3 | using System; 4 | 5 | internal static class StringExtensions 6 | { 7 | public static string CapitalizeFirstChar(this string input) 8 | { 9 | if (input == null) 10 | throw new ArgumentNullException(nameof(input)); 11 | 12 | char firstChar = input[0]; 13 | 14 | if (char.IsUpper(firstChar)) 15 | return input; 16 | 17 | var chars = input.ToCharArray(); 18 | chars[0] = char.ToUpper(firstChar); 19 | return new string(chars); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/NonSerializedError.cs: -------------------------------------------------------------------------------- 1 | namespace EasyButtons.Editor 2 | { 3 | using System; 4 | using UnityEditor; 5 | using UnityEngine; 6 | 7 | [Serializable] 8 | internal class NonSerializedError { } 9 | 10 | [CustomPropertyDrawer(typeof(NonSerializedError))] 11 | internal class NonSerializedErrorDrawer : PropertyDrawer 12 | { 13 | public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label) 14 | { 15 | Rect rectWithoutLabel = EditorGUI.PrefixLabel(rect, label); 16 | 17 | EditorGUI.HelpBox(rectWithoutLabel, "Unable to draw a non-serialized type.", MessageType.Error); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/ButtonWithoutParamsAsync.cs: -------------------------------------------------------------------------------- 1 | namespace EasyButtons.Editor 2 | { 3 | using System.Reflection; 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | 7 | internal class ButtonWithoutParamsAsync : ButtonWithoutParams 8 | { 9 | public ButtonWithoutParamsAsync(MethodInfo method, ButtonAttribute buttonAttribute) 10 | : base(method, buttonAttribute) { } 11 | 12 | protected async override void InvokeMethod(IEnumerable targets) 13 | { 14 | foreach (object obj in targets) { 15 | Task task = (Task)Method.Invoke(obj, null); 16 | await task; 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/ObjectEditor.cs: -------------------------------------------------------------------------------- 1 | namespace EasyButtons.Editor 2 | { 3 | using UnityEditor; 4 | using Object = UnityEngine.Object; 5 | 6 | /// 7 | /// Custom inspector for including derived classes. 8 | /// 9 | [CustomEditor(typeof(Object), true)] 10 | [CanEditMultipleObjects] 11 | internal class ObjectEditor : Editor 12 | { 13 | private ButtonsDrawer _buttonsDrawer; 14 | 15 | private void OnEnable() 16 | { 17 | _buttonsDrawer = new ButtonsDrawer(target); 18 | } 19 | 20 | public override void OnInspectorGUI() 21 | { 22 | DrawDefaultInspector(); 23 | _buttonsDrawer.DrawButtons(targets); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Samples/ScriptableObjectExample/ScriptableObjectExample.cs: -------------------------------------------------------------------------------- 1 | namespace EasyButtons.Example 2 | { 3 | using UnityEngine; 4 | 5 | [CreateAssetMenu(fileName = "ScriptableObjectExample.asset", menuName = "EasyButtons/ScriptableObjectExample")] 6 | public class ScriptableObjectExample : ScriptableObject 7 | { 8 | [Button] 9 | public void SayHello() 10 | { 11 | Debug.Log("Hello"); 12 | } 13 | 14 | [Button(Mode = ButtonMode.DisabledInPlayMode)] 15 | public void SayHelloEditor() 16 | { 17 | Debug.Log("Hello from edit mode"); 18 | } 19 | 20 | [Button(Mode = ButtonMode.EnabledInPlayMode)] 21 | public void SayHelloPlayMode() 22 | { 23 | Debug.Log("Hello from play mode"); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/ButtonWithoutParams.cs: -------------------------------------------------------------------------------- 1 | namespace EasyButtons.Editor 2 | { 3 | using System.Reflection; 4 | using UnityEngine; 5 | using System.Collections.Generic; 6 | 7 | internal class ButtonWithoutParams : Button 8 | { 9 | public ButtonWithoutParams(MethodInfo method, ButtonAttribute buttonAttribute) 10 | : base(method, buttonAttribute) { } 11 | 12 | protected override void DrawInternal(IEnumerable targets) 13 | { 14 | if ( ! GUILayout.Button(DisplayName)) 15 | return; 16 | 17 | InvokeMethod(targets); 18 | } 19 | 20 | protected virtual void InvokeMethod(IEnumerable targets) 21 | { 22 | foreach (object obj in targets) { 23 | Method.Invoke(obj, null); 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/ButtonWithParamsAsync.cs: -------------------------------------------------------------------------------- 1 | namespace EasyButtons.Editor 2 | { 3 | using System.Linq; 4 | using System.Reflection; 5 | using UnityEditor; 6 | using System.Collections.Generic; 7 | using System.Threading.Tasks; 8 | 9 | internal class ButtonWithParamsAsync : ButtonWithParams 10 | { 11 | public ButtonWithParamsAsync(MethodInfo method, ButtonAttribute buttonAttribute, ParameterInfo[] parameters) 12 | : base(method, buttonAttribute, parameters) { } 13 | 14 | protected async override void InvokeMethod(IEnumerable targets) { 15 | var paramValues = _parameters.Select(param => param.Value).ToArray(); 16 | 17 | foreach (object obj in targets) { 18 | Task task = (Task)Method.Invoke(obj, paramValues); 19 | await task; 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Assets/EasyButtons/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.madsbangh.easybuttons", 3 | "version": "1.4.0", 4 | "displayName": "Easy Buttons", 5 | "description": "Add buttons to your inspector in Unity super easily with this simple attribute.", 6 | "keywords": [ 7 | "button", 8 | "editor", 9 | "inspector" 10 | ], 11 | "author": { 12 | "name": "Mads Bang Hoffensetz", 13 | "url": "https://twitter.com/madsbangh" 14 | }, 15 | "samples": [ 16 | { 17 | "displayName": "Buttons Example", 18 | "path": "Samples~/ButtonsExample" 19 | }, 20 | { 21 | "displayName": "Custom Editor Buttons Example", 22 | "path": "Samples~/CustomEditorButtonsExample" 23 | }, 24 | { 25 | "displayName": "Scriptable Object Example", 26 | "path": "Samples~/ScriptableObjectExample" 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /Assets/EasyButtons/Samples/CustomEditorButtonsExample/Editor/CustomEditorButtonsExampleEditor.cs: -------------------------------------------------------------------------------- 1 | namespace EasyButtons.Example 2 | { 3 | using System.Linq; 4 | using Editor; 5 | using UnityEditor; 6 | using UnityEngine; 7 | 8 | [CustomEditor(typeof(CustomEditorButtonsExample))] 9 | public class CustomEditorButtonsExampleEditor : Editor 10 | { 11 | private ButtonsDrawer _buttonsDrawer; 12 | 13 | // Instantiate ButtonsDrawer in OnEnable if possible. 14 | private void OnEnable() 15 | { 16 | _buttonsDrawer = new ButtonsDrawer(target); 17 | } 18 | 19 | public override void OnInspectorGUI() 20 | { 21 | DrawDefaultInspector(); 22 | 23 | EditorGUILayout.HelpBox("Message from the custom editor.", MessageType.Info); 24 | 25 | // You can draw all buttons at once. 26 | _buttonsDrawer.DrawButtons(targets); 27 | 28 | // As well as a specific button in the wanted place. 29 | _buttonsDrawer.Buttons.First(button => button.DisplayName == "Custom Editor Example").Draw(targets); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Mads Bang Hoffensetz 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. 22 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: 5 | - master 6 | jobs: 7 | release: 8 | name: release 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2.3.4 12 | with: 13 | fetch-depth: 0 14 | - name: Semantic release 15 | id: semantic 16 | uses: cycjimmy/semantic-release-action@v2.5.3 17 | with: 18 | extra_plugins: | 19 | @semantic-release/changelog 20 | @semantic-release/git 21 | branch: master 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | - name: Create upm branch 25 | run: | 26 | git branch -d upm &> /dev/null || echo upm branch not found 27 | git subtree split -P "$PKG_ROOT" -b upm 28 | git checkout upm 29 | if [[ -d "Samples" ]]; then 30 | git mv Samples Samples~ 31 | rm -f Samples.meta 32 | git config --global user.name 'github-bot' 33 | git config --global user.email 'github-bot@users.noreply.github.com' 34 | git commit -am "fix: Samples => Samples~" 35 | fi 36 | git push -f -u origin upm 37 | env: 38 | PKG_ROOT: Assets/EasyButtons 39 | - name: Create upm git tag 40 | if: steps.semantic.outputs.new_release_published == 'true' 41 | run: | 42 | git tag $TAG upm 43 | git push origin --tags 44 | env: 45 | TAG: upm/v${{ steps.semantic.outputs.new_release_version }} -------------------------------------------------------------------------------- /.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 | 12 | # MemoryCaptures can get excessive in size. 13 | # They also could contain extremely sensitive data 14 | /[Mm]emoryCaptures/ 15 | 16 | # Asset meta data should only be ignored when the corresponding asset is also ignored 17 | !/[Aa]ssets/**/*.meta 18 | 19 | # Uncomment this line if you wish to ignore the asset store tools plugin 20 | # /[Aa]ssets/AssetStoreTools* 21 | 22 | # Autogenerated Jetbrains Rider plugin 23 | /[Aa]ssets/Plugins/Editor/JetBrains* 24 | 25 | # Visual Studio cache directory 26 | .vs/ 27 | 28 | # Gradle cache directory 29 | .gradle/ 30 | 31 | # Autogenerated VS/MD/Consulo solution and project files 32 | ExportedObj/ 33 | .consulo/ 34 | *.csproj* 35 | *.unityproj 36 | *.sln 37 | *.suo 38 | *.tmp 39 | *.user 40 | *.userprefs 41 | *.pidb 42 | *.booproj 43 | *.svd 44 | *.pdb 45 | *.mdb 46 | *.opendb 47 | *.VC.db 48 | 49 | # Unity3D generated meta files 50 | *.pidb.meta 51 | *.pdb.meta 52 | *.mdb.meta 53 | 54 | # Unity project settings and packages 55 | /ProjectSettings/ 56 | /Packages/ 57 | 58 | # Unity3D generated file on crash reports 59 | sysinfo.txt 60 | 61 | # Builds 62 | *.apk 63 | *.unitypackage 64 | 65 | # Crashlytics generated file 66 | crashlytics-build.properties 67 | 68 | # Rider auto-generated files 69 | **/.idea/ 70 | 71 | # Editor settings 72 | UserSettings/EditorUserSettings.asset 73 | 74 | # Roslyn Analyzers 75 | RoslynAnalyzers* -------------------------------------------------------------------------------- /Assets/EasyButtons/Editor/ButtonsDrawer.cs: -------------------------------------------------------------------------------- 1 | namespace EasyButtons.Editor 2 | { 3 | using System.Collections.Generic; 4 | using System.Reflection; 5 | using JetBrains.Annotations; 6 | 7 | /// 8 | /// Helper class that can be used in custom Editors to draw methods marked with the as buttons. 9 | /// 10 | public class ButtonsDrawer 11 | { 12 | /// 13 | /// A list of buttons that can be drawn for the class. 14 | /// 15 | [PublicAPI] 16 | public readonly List