はじめに
上記の記事の手順を踏むことで
Text の Inspector に ContentSizeFitter をアタッチするボタンを追加できます
概要
if ( GUILayout.Button( "Add ContentSizeFitter" ) ) { var text = target as Text; var gameObject = text.gameObject; if ( gameObject.GetComponent<ContentSizeFitter>() != null ) return; var fitter = Undo.AddComponent<ContentSizeFitter>( gameObject ); fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; }
TextEditor クラスの OnInspectorGUI 関数に上記のコードを追加することで
Text の Inspector に ContentSizeFitter をアタッチするボタンを追加できます