blob: de120b876a52f1abaab651f8433d85ae0ff9eb8f (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using UniToolsEditor;
namespace AdvancedInspector
{
public class DateTimeEditor : FieldEditor, IModal
{
private InspectorField field;
public override Type[] EditedTypes
{
get { return new Type[] { typeof(DateTime) }; }
}
private static Texture calendar;
internal static Texture Calendar
{
get
{
if (calendar == null)
calendar = Helper.Load(EditorResources.Calendar);
return calendar;
}
}
public override void Draw(InspectorField field, GUIStyle style)
{
DateTime time = field.GetValue<DateTime>();
if (time == DateTime.MinValue)
time = DateTime.Now;
string title = time.ToString();
if (field.Mixed)
title = " - - - ";
EditorGUILayout.BeginHorizontal();
EditorGUILayout.Space();
if (GUILayout.Button(Calendar, GUIStyle.none, GUILayout.Width(18), GUILayout.Height(18)))
{
this.field = field;
DateTimeDialog.Create(this, time, GUIUtility.GUIToScreenPoint(Event.current.mousePosition));
}
TextAnchor anchor = GUI.skin.label.alignment;
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
GUILayout.Label(title);
GUI.skin.label.alignment = anchor;
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
}
public void ModalRequest(bool shift) { }
public void ModalClosed(ModalWindow window)
{
if (window.Result != WindowResult.Ok)
return;
field.SetValue(((DateTimeDialog)window).Time);
}
}
}
|