Skip to content

Instantly share code, notes, and snippets.

@yoloroy
Created August 25, 2025 18:24
Show Gist options
  • Select an option

  • Save yoloroy/57c4325338f525108008b7c0bb7dfc7e to your computer and use it in GitHub Desktop.

Select an option

Save yoloroy/57c4325338f525108008b7c0bb7dfc7e to your computer and use it in GitHub Desktop.
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