Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEditor;
- using System.Collections;
- [CustomEditor(typeof(DigitTotal))]
- public class DigitTotalEditor : Editor {
- private DigitTotal _dTarget;
- private const int _maxDigit = 335;
- private string _placeHolder = string.Empty;
- public override void OnInspectorGUI() {
- _dTarget = (DigitTotal)target;
- _placeHolder = _dTarget.mazeNumData;
- if(_placeHolder.Length > 335){
- // remember to reassign the value back to the place
- _dTarget.mazeNumData = _placeHolder.Substring(0, _maxDigit - 1);
- }
- DrawDefaultInspector();
- DrawCustomInspector();
- }
- void DrawCustomInspector() {
- GUIStyle guiStyle = EditorStyles.textArea;
- guiStyle.wordWrap = true;
- EditorGUI.BeginChangeCheck();
- _dTarget.mazeNumData = EditorGUILayout.TextArea(_dTarget.mazeNumData, guiStyle, new GUILayoutOption[]
- {
- GUILayout.Height(100f),
- GUILayout.Width(250f),
- });
- if(EditorGUI.EndChangeCheck()){
- if(_dTarget.mazeNumData.Length >= 338){
- _dTarget.mazeNumData.Remove((_dTarget.mazeNumData.Length - 1) - 3, 3);
- }
- }
- GUILayout.Space(5f);
- GUILayout.Label("Digits : " + _dTarget.mazeNumData.Length, EditorStyles.boldLabel);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement