Created
June 6, 2025 09:17
-
-
Save NamPhuThuy/cbc9fbdc918b197cb46b4411db664602 to your computer and use it in GitHub Desktop.
Add this file into Assest/ScriptTemplates of any Unity project to custom the Default Script Template (the script that is generated when create a new script in Unity))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| #if UNITY_EDITOR | |
| using UnityEditor; | |
| #endif | |
| public class #SCRIPTNAME# : MonoBehaviour | |
| { | |
| #region MonoBehaviour Methods | |
| void Start() | |
| { | |
| } | |
| void Update() | |
| { | |
| } | |
| #endregion | |
| #region Private Methods | |
| #endregion | |
| #region Public Methods | |
| #endregion | |
| #region Editor Methods | |
| public void ResetValues() | |
| { | |
| // Add default reset values logic here | |
| } | |
| #endregion | |
| } | |
| #if UNITY_EDITOR | |
| [CustomEditor(typeof(#SCRIPTNAME#))] | |
| [CanEditMultipleObjects] | |
| public class #SCRIPTNAME#Editor : Editor | |
| { | |
| public override void OnInspectorGUI() | |
| { | |
| // Draw the default inspector | |
| DrawDefaultInspector(); | |
| // Get a reference to the script | |
| #SCRIPTNAME# script = (#SCRIPTNAME#)target; | |
| // Add a button to call ResetValues() | |
| if (GUILayout.Button("Reset Values")) | |
| { | |
| script.ResetValues(); | |
| EditorUtility.SetDirty(script); // Mark the object as dirty | |
| } | |
| } | |
| } | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment