blob: 2a82f0eae4181ef0695fa760792e9f6bf23d7fb7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
namespace AdvancedInspector
{
public class CharEditor : FieldEditor
{
public override Type[] EditedTypes
{
get { return new Type[] { typeof(char) }; }
}
public override void Draw(InspectorField field, GUIStyle style)
{
GUILayout.BeginHorizontal();
object value = GetValue(field);
string text = "";
if (value != null)
text = value.ToString();
EditorGUI.BeginChangeCheck();
string result = EditorGUILayout.TextField(text);
char c;
if (result.Length == 0)
c = '\0';
else
c = result[0];
if (EditorGUI.EndChangeCheck())
field.SetValue(c);
GUILayout.EndHorizontal();
}
}
}
|