Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections;
  4.  
  5. [CustomEditor(typeof(DigitTotal))]
  6. public class DigitTotalEditor : Editor {
  7.  
  8.     private DigitTotal _dTarget;
  9.  
  10.     private const int _maxDigit = 335;
  11.     private string _placeHolder = string.Empty;
  12.  
  13.     public override void OnInspectorGUI() {
  14.         _dTarget = (DigitTotal)target;
  15.        
  16.         _placeHolder = _dTarget.mazeNumData;
  17.         if(_placeHolder.Length > 335){
  18.             _placeHolder = _placeHolder.Substring(0, _maxDigit - 1);
  19.         }
  20.  
  21.         DrawDefaultInspector();
  22.         DrawCustomInspector();
  23.     }
  24.  
  25.     void DrawCustomInspector() {
  26.         GUIStyle guiStyle = EditorStyles.textArea;
  27.         guiStyle.wordWrap = true;
  28.  
  29.         EditorGUI.BeginChangeCheck();
  30.  
  31.         _dTarget.mazeNumData = EditorGUILayout.TextArea(_dTarget.mazeNumData, guiStyle, new GUILayoutOption[]
  32.         {
  33.             GUILayout.Height(100f),
  34.             GUILayout.Width(250f),
  35.         });
  36.  
  37.         if(EditorGUI.EndChangeCheck()){
  38.             if(_dTarget.mazeNumData.Length >= 338){
  39.                 _dTarget.mazeNumData.Remove((_dTarget.mazeNumData.Length - 1) - 3, 3);
  40.             }
  41.         }
  42.  
  43.         GUILayout.Space(5f);
  44.         GUILayout.Label("Digits : " + _dTarget.mazeNumData.Length, EditorStyles.boldLabel);
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement