Created
August 25, 2025 18:24
-
-
Save yoloroy/57c4325338f525108008b7c0bb7dfc7e to your computer and use it in GitHub Desktop.
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; | |
| using UnityEngine; | |
| #if UNITY_EDITOR | |
| using UnityEditor; | |
| #endif | |
| public class TitleInspectorDecorum : MonoBehaviour | |
| { | |
| #if UNITY_EDITOR | |
| [SerializeField] private string text = ""; | |
| public string Text | |
| { | |
| get => text; | |
| set => text = value; | |
| } | |
| #endif | |
| } | |
| #if UNITY_EDITOR | |
| [CustomEditor(typeof(TitleInspectorDecorum))] | |
| public class TitleInspectorDecorumEditor : Editor | |
| { | |
| private TitleInspectorDecorum _title; | |
| private GUIStyle _style; | |
| private void OnEnable() | |
| { | |
| _title = (TitleInspectorDecorum)target; | |
| _style = new GUIStyle(EditorStyles.boldLabel) | |
| { | |
| alignment = TextAnchor.MiddleCenter, | |
| fontSize = 18 | |
| }; | |
| } | |
| public override void OnInspectorGUI() | |
| { | |
| if (!_title) return; | |
| try | |
| { | |
| using (new EditorGUILayout.VerticalScope("box")) | |
| { | |
| _title.Text = EditorGUILayout.TextField(_title.Text) ?? ""; | |
| EditorGUILayout.SelectableLabel(_title.Text ?? "", _style); | |
| } | |
| } | |
| catch (Exception) | |
| { | |
| // ignored | |
| } | |
| } | |
| } | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment