Релиз от 24.04.2025

This commit is contained in:
Станислав Хозяенок 2025-04-25 08:32:09 +07:00
parent 09ad3fc278
commit b6c87d8b70
177 changed files with 393494 additions and 1 deletions

@ -1 +0,0 @@
Subproject commit df6e2fe0699e4c1347d1bbddb4e3a44fc60a8aa8

View File

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
class SceneParams
{
static private SceneParams _instance;
static public SceneParams Instance
{
get
{
if (_instance == null)
{
_instance = new SceneParams();
}
return _instance;
}
}
public class CameraSettings
{
private bool isBlockMove = true;
private bool isBlockZoom = true;
// Запретить переход
public bool IsBlockMove {
get => isBlockMove;
set
{
if (Instance.IsDataHistoryLoadged)
isBlockMove = value;
}
}
public bool IsBlockZoom {
get => isBlockZoom;
set
{
if (Instance.IsDataHistoryLoaded)
isBlockZoom = value;
}
}
public Transform DefaultTransform = null;
public bool IsStartPos { get; set; } = true;
}
public class SpawnMovePoint
{
private bool isSpawnMTEPoint = false;
private bool isSpawnRTLSPoint = false;
public bool IsSpawnMTEPoint { get => isSpawnMTEPoint; set => isSpawnMTEPoint = value; }
public bool IsSpawnRTLSPoint { get => isSpawnRTLSPoint; set => isSpawnRTLSPoint = value; }
}
public class Person
{
private Vector3 startPosition;
public Vector3 StartPosition { get => startPosition; set => startPosition = value; }
}
public CameraSettings cameraSettings = new CameraSettings();
public SpawnMovePoint spawnMovePoint = new SpawnMovePoint();
public Person person = new Person();
public bool IsDataHistoryLoaded { get; set; } = false;
}

8
Assets/UI.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: aee62a1cbad12f040afd0542e625c849
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f0eb457bbed30d14ba2f845dc53612bc
folderAsset: yes
timeCreated: 1467636598
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3467a7c36069e414f9a7fb67503aaf21
folderAsset: yes
timeCreated: 1469019442
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,265 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: DatePickerAnimationController
serializedVersion: 5
m_AnimatorParameters: []
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: 110777036}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1102 &110207658
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Show_Slide_Below
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 3e29f803e4198334b90aacf11d1a41ac, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &110209270
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Show_Slide_Above
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 3e29f803e4198334b90aacf11d1a41ac, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &110212962
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Default
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 0}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &110231856
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: SlideIn_Left
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: a1fa32b1afb362844897299b7a0f3437, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &110232760
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Hide_Slide_Above
m_Speed: -1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 3e29f803e4198334b90aacf11d1a41ac, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &110236750
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Hide_Slide_Below
m_Speed: -1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 3e29f803e4198334b90aacf11d1a41ac, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &110251916
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: SlideDown
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 3e29f803e4198334b90aacf11d1a41ac, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &110281700
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: SlideIn_Right
m_Speed: -1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 3fd038a8db8f02246b50a68bbb66ad1c, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1107 &110777036
AnimatorStateMachine:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 110212962}
m_Position: {x: 216, y: 732, z: 0}
- serializedVersion: 1
m_State: {fileID: 110231856}
m_Position: {x: 48, y: -48, z: 0}
- serializedVersion: 1
m_State: {fileID: 110281700}
m_Position: {x: 348, y: -48, z: 0}
- serializedVersion: 1
m_State: {fileID: 110251916}
m_Position: {x: 383, y: 17, z: 0}
- serializedVersion: 1
m_State: {fileID: 110207658}
m_Position: {x: 60, y: 492, z: 0}
- serializedVersion: 1
m_State: {fileID: 110236750}
m_Position: {x: 60, y: 540, z: 0}
- serializedVersion: 1
m_State: {fileID: 110209270}
m_Position: {x: 408, y: 492, z: 0}
- serializedVersion: 1
m_State: {fileID: 110232760}
m_Position: {x: 408, y: 540, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 228, y: -144, z: 0}
m_EntryPosition: {x: 240, y: 648, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 110212962}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7007f7b85352a5c41bc151217c657528
timeCreated: 1469020952
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,232 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Slide_Below
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: {x: 1, y: 0, z: 1}
inSlope: {x: 0, y: 4, z: 0}
outSlope: {x: 0, y: 4, z: 0}
tangentMode: 0
weightedMode: 0
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
- serializedVersion: 3
time: 0.25
value: {x: 1, y: 1, z: 1}
inSlope: {x: 0, y: 4, z: 0}
outSlope: {x: 0, y: 4, z: 0}
tangentMode: 0
weightedMode: 0
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
path:
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 4
outSlope: 4
tangentMode: 34
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.25
value: 1
inSlope: 4
outSlope: 4
tangentMode: 34
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Alpha
path:
classID: 225
script: {fileID: 0}
m_PPtrCurves: []
m_SampleRate: 120
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 0
attribute: 3
script: {fileID: 0}
typeID: 4
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 0
attribute: 1574349066
script: {fileID: 0}
typeID: 225
customType: 0
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.25
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 34
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.25
value: 1
inSlope: 0
outSlope: 0
tangentMode: 34
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalScale.x
path:
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 4
outSlope: 4
tangentMode: 34
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.25
value: 1
inSlope: 4
outSlope: 4
tangentMode: 34
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalScale.y
path:
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 34
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.25
value: 1
inSlope: 0
outSlope: 0
tangentMode: 34
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalScale.z
path:
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 4
outSlope: 4
tangentMode: 34
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.25
value: 1
inSlope: 4
outSlope: 4
tangentMode: 34
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Alpha
path:
classID: 225
script: {fileID: 0}
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_GenerateMotionCurves: 0
m_Events: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3e29f803e4198334b90aacf11d1a41ac
timeCreated: 1469104120
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 53ad93d5d824d8f4f98ae5c68f09a2bc
timeCreated: 1467637034
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,13 @@
using UnityEngine;
using System;
using System.Collections;
using System.Globalization;
using System.Collections.Generic;
namespace UI.Dates
{
public static class DatePickerCache
{
internal static Dictionary<string, bool> _DateFallsWithinMonthResults = new Dictionary<string, bool>();
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 32d47812cd9d1e241a278efb2e170282
timeCreated: 1468330494
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
using UnityEngine;
using System;
using System.Collections;
using System.Globalization;
using System.Collections.Generic;
using UnityEngine.UI;
namespace UI.Dates
{
public static class DatePickerExtensions
{
public static void Apply(this ColorBlock colors, ColorBlock newColors)
{
colors.colorMultiplier = newColors.colorMultiplier;
colors.disabledColor = newColors.disabledColor;
colors.fadeDuration = newColors.fadeDuration;
colors.highlightedColor = newColors.highlightedColor;
colors.normalColor = newColors.normalColor;
colors.pressedColor = newColors.pressedColor;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 44987c61f7f0b134db5efb0dca34fa1e
timeCreated: 1487928166
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,147 @@
using UnityEngine;
using System;
using System.Collections;
using System.Linq;
using System.Globalization;
using System.Collections.Generic;
namespace UI.Dates
{
internal class DelayedEditorAction
{
internal double TimeToExecute;
internal Action Action;
internal MonoBehaviour ActionTarget;
internal bool ForceEvenIfTargetIsGone;
public DelayedEditorAction(double timeToExecute, Action action, MonoBehaviour actionTarget, bool forceEvenIfTargetIsGone = false)
{
TimeToExecute = timeToExecute;
Action = action;
ActionTarget = actionTarget;
ForceEvenIfTargetIsGone = forceEvenIfTargetIsGone;
}
}
public static class DatePickerTimer
{
private static DatePickerTimerComponent _timerComponent;
private static DatePickerTimerComponent timerComponent
{
get
{
if (_timerComponent == null)
{
_timerComponent = GameObject.FindObjectOfType<DatePickerTimerComponent>();
if (_timerComponent == null && !IsQuitting)
{
var timerGO = new GameObject("DatePickerTimer");
_timerComponent = timerGO.AddComponent<DatePickerTimerComponent>();
GameObject.DontDestroyOnLoad(timerGO);
}
}
return _timerComponent;
}
}
public static bool IsFirstFrame
{
/*get { return timerComponent.IsFirstFrame; } */
get { return Time.frameCount <= 1; }
}
private static bool IsQuitting { get; set; }
public static void StartCoroutine(IEnumerator coroutine)
{
if (Application.isPlaying) timerComponent.StartCoroutine(coroutine);
}
#if UNITY_2018_1_OR_NEWER
[RuntimeInitializeOnLoadMethod()]
public static void OnLoad()
{
Application.quitting += () => IsQuitting = true;
}
#endif
#if UNITY_EDITOR
static List<DelayedEditorAction> delayedEditorActions = new List<DelayedEditorAction>();
static DatePickerTimer()
{
UnityEditor.EditorApplication.update += EditorUpdate;
}
#endif
public static WaitForSecondsRealtime GetWaitForSecondsRealtimeInstruction(float seconds)
{
return new WaitForSecondsRealtime(seconds);
}
public static WaitForSeconds GetWaitForSecondsInstruction(float seconds)
{
return new WaitForSeconds(seconds);
}
static void EditorUpdate()
{
#if UNITY_EDITOR
if (Application.isPlaying) return;
var actionsToExecute = delayedEditorActions.Where(dea => UnityEditor.EditorApplication.timeSinceStartup >= dea.TimeToExecute).ToList();
if (actionsToExecute.Count == 0) return;
foreach (var actionToExecute in actionsToExecute)
{
try
{
if (actionToExecute.ActionTarget != null || actionToExecute.ForceEvenIfTargetIsGone) // don't execute if the target is gone
{
actionToExecute.Action.Invoke();
}
}
finally
{
delayedEditorActions.Remove(actionToExecute);
}
}
#endif
}
/// <summary>
/// Call Action 'action' after the specified delay, provided the 'actionTarget' is still present and active in the scene at that time.
/// Can be used in both edit and play modes.
/// </summary>
/// <param name="delay"></param>
/// <param name="action"></param>
/// <param name="actionTarget"></param>
public static void DelayedCall(float delay, Action action, MonoBehaviour actionTarget, bool forceEvenIfObjectIsInactive = false)
{
if (Application.isPlaying)
{
if (timerComponent != null) timerComponent.DelayedCall(delay, action, actionTarget, forceEvenIfObjectIsInactive);
}
#if UNITY_EDITOR
else
{
delayedEditorActions.Add(new DelayedEditorAction(UnityEditor.EditorApplication.timeSinceStartup + delay, action, actionTarget, forceEvenIfObjectIsInactive));
}
#endif
}
/// <summary>
/// Shorthand for DelayedCall(0, action, actionTarget)
/// </summary>
/// <param name="action"></param>
/// <param name="actionTarget"></param>
public static void AtEndOfFrame(Action action, MonoBehaviour actionTarget, bool forceEvenIfObjectIsInactive = false)
{
DelayedCall(0, action, actionTarget, forceEvenIfObjectIsInactive);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1c9ccb654fb05db4cb6f1a89feb3e042
timeCreated: 1468243048
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,64 @@
using System;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UI.Tables;
using System.Collections.Generic;
using System.Linq;
namespace UI.Dates
{
public class DatePickerTimerComponent : MonoBehaviour
{
public List<DelayedAction> delayedActions = new List<DelayedAction>();
public void DelayedCall(float delay, Action action, MonoBehaviour target, bool forceEvenIfTargetIsInactive)
{
this.enabled = true;
delayedActions.Add(new DelayedAction { timeToExecute = Time.unscaledTime + delay, action = action, target = target, forceEvenIfTargetIsInactive = forceEvenIfTargetIsInactive });
}
private void Update()
{
List<DelayedAction> actionsToExecute = null;
foreach (var action in delayedActions)
{
if (Time.unscaledTime >= action.timeToExecute)
{
if (actionsToExecute == null) actionsToExecute = new List<DelayedAction>();
actionsToExecute.Add(action);
}
}
if (actionsToExecute == null || actionsToExecute.Count == 0) return;
foreach (var action in actionsToExecute)
{
try
{
if ((action.forceEvenIfTargetIsInactive)
|| (action.target != null && action.target.gameObject.activeInHierarchy))
{
action.action.Invoke();
}
}
finally
{
delayedActions.Remove(action);
}
}
// stop calling update if we have nothing scheduled (DelayedCall will re-enable this)
if (delayedActions.Count == 0) this.enabled = false;
}
}
public class DelayedAction
{
public float timeToExecute;
public Action action;
public MonoBehaviour target;
public bool forceEvenIfTargetIsInactive;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eacc0f717a736fe409e8e7ff365401d9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,76 @@
using UnityEngine;
using System;
using System.Collections;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
namespace UI.Dates
{
public static class DatePickerUtilities
{
public static string DateFormat = "yyyy-MM-dd";
public static string ToDateString(this SerializableDate date)
{
return date.HasValue ? date.Date.ToDateString() : null;
}
public static string ToDateString(this DateTime date)
{
return date.ToString(DateFormat);
}
public static string[] GetAbbreviatedDayNames()
{
//return Shift(DateTimeFormatInfo.CurrentInfo.AbbreviatedDayNames, (int)DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek);
return Shift(DateTimeFormatInfo.CurrentInfo.AbbreviatedDayNames.Where(d => d != "").ToArray(), (int)DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek);
}
public static List<DateTime> GetDateRangeForDisplay(DateTime date)
{
var list = new List<DateTime>();
var firstDayOfMonth = new DateTime(date.Year, date.Month, 1);
var firstDayOfWeekInCulture = DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek;
var day = firstDayOfMonth;
while (day.DayOfWeek != firstDayOfWeekInCulture)
{
day = day.AddDays(-1);
}
for (var x = 0; x < 42; x++)
{
list.Add(day);
day = day.AddDays(1);
}
return list;
}
public static bool DateFallsWithinMonth(DateTime date, DateTime month)
{
// We cache the results of this check because it will be performed often
var key = date.ToDateString() + "|" + month.ToDateString();
if (!DatePickerCache._DateFallsWithinMonthResults.ContainsKey(key))
{
var firstDay = new DateTime(month.Year, month.Month, 1);
var lastDay = new DateTime(month.Year, month.Month, DateTime.DaysInMonth(month.Year, month.Month)).AddDays(1).AddTicks(-1);
DatePickerCache._DateFallsWithinMonthResults.Add(key, date.CompareTo(firstDay) >= 0 && date.CompareTo(lastDay) <= 0);
}
return DatePickerCache._DateFallsWithinMonthResults[key];
}
internal static T[] Shift<T>(T[] array, int positions)
{
T[] copy = new T[array.Length];
Array.Copy(array, 0, copy, array.Length - positions, positions);
Array.Copy(array, positions, copy, 0, array.Length - positions);
return copy;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 70300bc161a3bcd409f1d47f6071b16d
timeCreated: 1467647761
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,192 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace UI.Dates
{
// Was having some positioning issues with the default Animator component, so I wrote a simple animator here
// It turned out that the Animator component wasn't responsible, but I've decided to leave the simpler implementation in place for now
[RequireComponent(typeof(RectTransform)), RequireComponent(typeof(CanvasGroup))]
public class DatePicker_Animator : MonoBehaviour
{
protected List<DatePicker_Animation> animations = new List<DatePicker_Animation>();
private CanvasGroup m_canvasGroup = null;
protected CanvasGroup canvasGroup
{
get
{
if (m_canvasGroup == null) m_canvasGroup = GetComponent<CanvasGroup>();
return m_canvasGroup;
}
}
private RectTransform m_rectTransform = null;
protected RectTransform rectTransform
{
get
{
if (m_rectTransform == null) m_rectTransform = GetComponent<RectTransform>();
return m_rectTransform;
}
}
public bool ResetWhenAnimationComplete = true;
public float AnimationDuration = 0.25f;
public void PlayAnimation(Animation animation, AnimationType animationType, Action onComplete = null)
{
if (animationType == AnimationType.Show)
{
switch (animation)
{
case Animation.Slide:
{
// Start off by setting our Y scale to zero;
SetPropertyValue(DatePicker_Animation_Property.ScaleY, 0);
// Then animate to full size
Animate(DatePicker_Animation_Property.ScaleY, 1, AnimationDuration, onComplete);
}
break;
case Animation.Fade:
{
SetPropertyValue(DatePicker_Animation_Property.Alpha, 0);
Animate(DatePicker_Animation_Property.Alpha, 1, AnimationDuration, onComplete);
}
break;
}
}
else
{
switch (animation)
{
case Animation.Slide:
{
Animate(DatePicker_Animation_Property.ScaleY, 0f, AnimationDuration, onComplete);
}
break;
case Animation.Fade:
{
Animate(DatePicker_Animation_Property.Alpha, 0f, AnimationDuration, onComplete);
}
break;
}
}
}
public void Animate(DatePicker_Animation_Property property, float desiredValue, float duration, Action onComplete = null)
{
if (!Application.isPlaying)
{
SetPropertyValue(property, desiredValue);
if (onComplete != null) onComplete.Invoke();
return;
}
var animation = animations.FirstOrDefault(a => a.property == property);
if (animation == null)
{
animation = new DatePicker_Animation
{
property = property
};
animations.Add(animation);
}
animation.initialValue = GetPropertyValue(animation.property);
animation.desiredValue = desiredValue;
animation.percentageComplete = 0;
animation.startTime = Time.time;
animation.duration = duration;
animation.onComplete = onComplete;
}
void Update()
{
if (!animations.Any()) return;
foreach (var animation in animations)
{
animation.percentageComplete = (Time.time - animation.startTime) / animation.duration;
SetPropertyValue(animation.property, animation.currentValue);
if (animation.percentageComplete >= 1)
{
if (animation.onComplete != null) animation.onComplete.Invoke();
}
}
animations.RemoveAll(a => a.percentageComplete >= 1);
if (ResetWhenAnimationComplete && !animations.Any())
{
SetPropertyValue(DatePicker_Animation_Property.Alpha, 1);
SetPropertyValue(DatePicker_Animation_Property.ScaleX, 1);
SetPropertyValue(DatePicker_Animation_Property.ScaleY, 1);
}
}
float GetPropertyValue(DatePicker_Animation_Property property)
{
switch (property)
{
case DatePicker_Animation_Property.Alpha:
return canvasGroup.alpha;
case DatePicker_Animation_Property.ScaleX:
return rectTransform.localScale.x;
case DatePicker_Animation_Property.ScaleY:
return rectTransform.localScale.y;
}
return 0f;
}
void SetPropertyValue(DatePicker_Animation_Property property, float newValue)
{
switch (property)
{
case DatePicker_Animation_Property.Alpha:
canvasGroup.alpha = newValue;
break;
case DatePicker_Animation_Property.ScaleX:
rectTransform.localScale = new Vector3(newValue, rectTransform.localScale.y, rectTransform.localScale.z);
break;
case DatePicker_Animation_Property.ScaleY:
rectTransform.localScale = new Vector3(rectTransform.localScale.x, newValue, rectTransform.localScale.z);
break;
}
}
protected class DatePicker_Animation
{
public DatePicker_Animation_Property property;
public float initialValue;
public float desiredValue;
public float startTime;
public float percentageComplete;
public float duration;
public Action onComplete;
public float currentValue
{
get
{
return Mathf.Lerp(initialValue, desiredValue, percentageComplete);
}
}
}
public enum DatePicker_Animation_Property
{
Alpha,
ScaleX,
ScaleY
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ecbabc5a850c4304dadacf1b49b0ef88
timeCreated: 1469109423
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,59 @@
using System;
using System.Collections;
using System.Globalization;
using UnityEngine;
using UnityEngine.UI;
using UI.Tables;
using UnityEngine.Serialization;
using TMPro;
namespace UI.Dates
{
public class DatePicker_Button : MonoBehaviour
{
public Button Button;
#pragma warning disable
[SerializeField, FormerlySerializedAs("Text"), HideInInspector]
private Text oldText;
#pragma warning restore
[SerializeField]
private TextMeshProUGUI m_Text;
public TextMeshProUGUI Text
{
get
{
if (m_Text == null)
{
if (oldText == null)
{
Debug.LogError("[DatePicker] An error ocurred while upgrading to TextMesh Pro - unable to locate original text element for a button.");
return null;
}
m_Text = DatePicker_TextMeshProUtilities.ReplaceTextElementWithTextMeshPro(oldText);
}
return m_Text;
}
}
public bool IsTemplate = true;
[SerializeField]
private TableCell m_Cell = null;
public TableCell Cell
{
get
{
if (m_Cell == null) m_Cell = GetComponent<TableCell>(); // as used by DayButton
if (m_Cell == null) m_Cell = GetComponentInParent<TableCell>(); // as used by header buttons
return m_Cell;
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: aca775cb21cc5c84b8002986bfa21acb
timeCreated: 1467803686
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,478 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UI;
using UnityEngine.Events;
using System.Linq;
using TMPro;
namespace UI.Dates
{
[Serializable]
public class DatePickerEvent : UnityEvent<DateTime> { }
[Serializable]
public struct DatePickerConfig
{
public DatePickerMiscConfig Misc;
[Space]
public DatePickerSizeConfig Sizing;
[Space]
public DatePickerModalConfig Modal;
[Space]
public DatePickerDateRangeConfig DateRange;
[Space]
public DatePickerFormatConfig Format;
[Space]
public DatePickerBorderConfig Border;
[Space]
public DatePickerHeaderConfig Header;
[Space]
public DatePickerWeekDaysConfig WeekDays;
[Space]
public DatePickerDayConfig Days;
[Space]
public DatePickerAnimationConfig Animation;
[Space]
public DatePickerInputFieldConfig InputField;
[Space]
public DatePickerEventConfig Events;
}
[Serializable]
public class DatePickerSizeConfig
{
public bool OverrideTransformHeight = false;
public float PreferredHeight = 256f;
public bool UsePreferredWidthInsteadOfInputFieldWidth = false;
public float PreferredWidth = 256f;
}
[Serializable]
public class DatePickerDayConfig
{
public Color BackgroundColor;
#pragma warning disable
[SerializeField, FormerlySerializedAs("Font"), HideInInspector]
private Font oldFont;
#pragma warning restore
public TMP_FontAsset Font;
public int FontSize;
public bool FontAutoSize = true;
public int FontSizeMin = 2;
public int FontSizeMax = 16;
public DatePickerDayButtonConfig CurrentMonth;
public DatePickerDayButtonConfig OtherMonths;
public DatePickerDayButtonConfig Today;
public DatePickerDayButtonConfig SelectedDay;
public void Validate()
{
if (Font == null && oldFont != null)
{
Font = DatePicker_TextMeshProUtilities.GetTMPFontFromOldFont(oldFont);
}
}
}
[Serializable]
public class DatePickerBorderConfig
{
public RectOffset Size = null;
public Color Color;
}
[Serializable]
public class DatePickerDayButtonConfig
{
[Tooltip("If this value is set, then the values provided here will override the values of the template. If you wish to modify the template directly, this value should be cleared.")]
public bool OverrideTemplate = true;
[Header("Text")]
public Color TextColor;
[Header("Background")]
public Sprite BackgroundImage;
public ColorBlock BackgroundColors;
public void ApplyConfig(DatePicker_Button button)
{
if (!OverrideTemplate) return;
button.Text.color = TextColor;
button.Button.colors = BackgroundColors;
//button.Button.colors.Apply(BackgroundColors);
button.Button.image.sprite = BackgroundImage;
}
}
[Serializable]
public class DatePickerWeekDaysConfig
{
[Header("Week Numbers")]
public bool ShowWeekNumbers = false;
public WeekNumberMode WeekNumberMode = WeekNumberMode.WeekOfYear;
public CalendarWeekRule CalendarWeekRule = CalendarWeekRule.FirstFullWeek;
[Tooltip("0 == Auto")]
public float WeekNumberColumnWidth = 0f;
[Header("Appearance")]
[Tooltip("If this value is set, then the values provided here will override the values of the template. If you wish to modify the template directly, this value should be cleared.")]
public bool OverrideTemplate = true;
[Header("Text")]
public Color TextColor;
#pragma warning disable
[SerializeField, FormerlySerializedAs("Font"), HideInInspector]
private Font oldFont;
#pragma warning restore
public TMP_FontAsset Font;
public int FontSize;
public bool FontAutoSize = true;
public int FontSizeMin = 2;
public int FontSizeMax = 16;
[Header("Background")]
public Sprite BackgroundImage;
public Color BackgroundColor;
public void ApplyConfig(DatePicker_DayHeader header)
{
if (!OverrideTemplate) return;
header.HeaderText.color = TextColor;
if (Font == null && oldFont != null)
{
Font = DatePicker_TextMeshProUtilities.GetTMPFontFromOldFont(oldFont);
}
if (Font != null) header.HeaderText.font = Font;
header.HeaderText.fontSize = FontSize;
header.HeaderText.fontSizeMin = FontSizeMin;
header.HeaderText.fontSizeMax = FontSizeMax;
header.HeaderText.enableAutoSizing = FontAutoSize;
header.Cell.image.sprite = BackgroundImage;
header.Cell.image.color = BackgroundColor;
}
}
[Serializable]
public class DatePickerButtonConfig
{
public Sprite Image;
public ColorBlock Colors;
public bool PreserveAspect = true;
public void ApplyConfig(DatePicker_Button button)
{
//button.Button.colors = Colors;
button.Button.colors.Apply(Colors);
button.Button.image.sprite = Image;
button.Button.image.preserveAspect = PreserveAspect;
}
}
[Serializable]
public class DatePickerHeaderConfig
{
public bool ShowHeader = true;
[Header("Background")]
public Color BackgroundColor;
[Header("Text")]
public Color TextColor;
#pragma warning disable
[SerializeField, FormerlySerializedAs("Font"), HideInInspector]
private Font oldFont;
#pragma warning restore
public TMP_FontAsset Font;
public int FontSize = 22;
public bool FontAutoSize = true;
public int FontSizeMin = 2;
public int FontSizeMax = 24;
[Header("Height")]
public float Height = 48f;
[Header("Buttons")]
public bool ShowNextAndPreviousMonthButtons = true;
public bool ShowNextAndPreviousYearButtons = true;
[Space]
public float MonthButtonCellWidth = 48f;
public RectOffset MonthButtonCellPadding = null;
[Space]
public float YearButtonCellWidth = 48f;
public RectOffset YearButtonCellPadding = null;
[Space]
public DatePickerButtonConfig PreviousMonthButton;
public DatePickerButtonConfig NextMonthButton;
public DatePickerButtonConfig PreviousYearButton;
public DatePickerButtonConfig NextYearButton;
[SerializeField, HideInInspector]
private bool m_newPaddingValuesApplied = false;
public void Apply(DatePicker_Header header)
{
if (header == null) return;
if (ShowHeader)
{
header.gameObject.SetActive(true);
}
else
{
header.gameObject.SetActive(false);
return;
}
header.Background.color = BackgroundColor;
header.HeaderText.color = TextColor;
if (Font == null && oldFont != null)
{
Font = DatePicker_TextMeshProUtilities.GetTMPFontFromOldFont(oldFont);
}
if (Font != null) header.HeaderText.font = Font;
header.HeaderText.fontSize = FontSize;
header.HeaderText.fontSizeMin = FontSizeMin;
header.HeaderText.fontSizeMax = FontSizeMax;
header.HeaderText.enableAutoSizing = FontAutoSize;
if (ShowNextAndPreviousMonthButtons)
{
header.NextMonthButton.gameObject.SetActive(true);
header.PreviousMonthButton.gameObject.SetActive(true);
NextMonthButton.ApplyConfig(header.NextMonthButton);
PreviousMonthButton.ApplyConfig(header.PreviousMonthButton);
}
else
{
header.NextMonthButton.gameObject.SetActive(false);
header.PreviousMonthButton.gameObject.SetActive(false);
}
if (ShowNextAndPreviousYearButtons)
{
header.NextYearButton.gameObject.SetActive(true);
header.PreviousYearButton.gameObject.SetActive(true);
NextYearButton.ApplyConfig(header.NextYearButton);
PreviousYearButton.ApplyConfig(header.PreviousYearButton);
}
else
{
header.NextYearButton.gameObject.SetActive(false);
header.PreviousYearButton.gameObject.SetActive(false);
}
if (header.Row.preferredHeight != Height)
{
header.Row.preferredHeight = Height;
header.Row.NotifyTableRowPropertiesChanged();
}
if (header.TableLayout == null) header.TableLayout = header.Row.GetTable();
header.TableLayout.ColumnWidths = new List<float>() { YearButtonCellWidth, MonthButtonCellWidth, 0, MonthButtonCellWidth, YearButtonCellWidth };
if (!m_newPaddingValuesApplied)
{
MonthButtonCellPadding = new RectOffset(8, 8, 8, 8);
YearButtonCellPadding = new RectOffset(8, 8, 8, 8);
m_newPaddingValuesApplied = true;
}
if (header.NextMonthButton.Cell != null)
{
header.NextMonthButton.Cell.padding = MonthButtonCellPadding;
LayoutRebuilder.MarkLayoutForRebuild(header.NextMonthButton.Cell.transform as RectTransform);
}
if (header.NextYearButton.Cell != null)
{
header.NextYearButton.Cell.padding = YearButtonCellPadding;
LayoutRebuilder.MarkLayoutForRebuild(header.NextYearButton.Cell.transform as RectTransform);
}
if (header.PreviousMonthButton.Cell != null)
{
header.PreviousMonthButton.Cell.padding = MonthButtonCellPadding;
LayoutRebuilder.MarkLayoutForRebuild(header.PreviousMonthButton.Cell.transform as RectTransform);
}
if (header.PreviousYearButton.Cell != null)
{
header.PreviousYearButton.Cell.padding = YearButtonCellPadding;
LayoutRebuilder.MarkLayoutForRebuild(header.PreviousYearButton.Cell.transform as RectTransform);
}
header.TableLayout.UpdateLayout();
}
}
[Serializable]
public struct DatePickerEventConfig
{
[SerializeField]
public DatePickerEvent OnDaySelected;
[SerializeField]
public DatePickerEvent OnDayMouseOver;
}
[Serializable]
public class DatePickerMiscConfig
{
[Tooltip("If this is set, the DatePicker will always switch to the selected month when a new date is selected.")]
public bool SwitchToSelectedMonthWhenDateSelected = true;
public bool ShowDatesInOtherMonths = true;
[Tooltip("If this is set, then the DatePicker will be closed when a date is selected. Useful for popup datepicker dialogs.")]
public bool CloseWhenDateSelected = false;
public DatePickerMiscConfig Clone()
{
return new DatePickerMiscConfig
{
SwitchToSelectedMonthWhenDateSelected = SwitchToSelectedMonthWhenDateSelected,
ShowDatesInOtherMonths = ShowDatesInOtherMonths,
CloseWhenDateSelected = CloseWhenDateSelected
};
}
}
[Serializable]
public class DatePickerFormatConfig
{
public string DateFormat = DatePickerUtilities.DateFormat;
}
[Serializable]
public class DatePickerModalConfig
{
[Tooltip("If this is set to true, then the DatePicker will be the only thing on the screen which can be interacted with when it is active.")]
public bool IsModal = false;
[Tooltip("If this is set to true, then the DatePicker will be closed when the screen overlay is clicked. Relevant to Modal DatePickers only.")]
public bool CloseWhenModalOverlayClicked = true;
public Color ScreenOverlayColor;
}
[Serializable]
public class DatePickerDateRangeConfig
{
public bool RestrictFromDate = false;
public SerializableDate FromDate;
public bool RestrictToDate = false;
public SerializableDate ToDate;
public List<SerializableDate> ProhibitedDates = new List<SerializableDate>();
public DatePickerPermittedWeekDaysConfig PermittedWeekDays = new DatePickerPermittedWeekDaysConfig();
public bool Validate(bool silent = false)
{
if (RestrictFromDate && !FromDate.HasValue)
{
if (!silent) Debug.Log("[DatePicker] Restrict From Date requires a 'From Date' to be specified.");
return false;
}
if (RestrictToDate && !ToDate.HasValue)
{
if (!silent) Debug.Log("[DatePicker] Restrict To Date requires a 'To Date' to be specified.");
return false;
}
if (RestrictFromDate && RestrictToDate)
{
if (ToDate.Date.CompareTo(FromDate.Date) < 0)
{
if (!silent) Debug.Log("[DatePicker] Invalid Date range specified.");
return false;
}
}
return true;
}
public DatePickerDateRangeConfig Clone()
{
return new DatePickerDateRangeConfig
{
RestrictFromDate = RestrictFromDate,
RestrictToDate = RestrictToDate,
FromDate = new SerializableDate(FromDate),
ToDate = new SerializableDate(ToDate),
ProhibitedDates = ProhibitedDates.ToList(),
PermittedWeekDays = PermittedWeekDays.Clone()
};
}
}
[Serializable]
public class DatePickerPermittedWeekDaysConfig
{
public bool Monday = true;
public bool Tuesday = true;
public bool Wednesday = true;
public bool Thursday = true;
public bool Friday = true;
public bool Saturday = true;
public bool Sunday = true;
public DatePickerPermittedWeekDaysConfig Clone()
{
return new DatePickerPermittedWeekDaysConfig()
{
Monday = Monday,
Tuesday = Tuesday,
Wednesday = Wednesday,
Thursday = Thursday,
Friday = Friday,
Saturday = Saturday,
Sunday = Sunday
};
}
}
[Serializable]
public class DatePickerInputFieldConfig
{
public bool ToggleDisplayWhenInputFieldClicked = true;
public bool ShowToggleButton = true;
public float ToggleButtonWidth = 64f;
public Dates.Alignment DatePickerAlignmentRelativeToInputField = Dates.Alignment.Left;
}
[Serializable]
public class DatePickerAnimationConfig
{
public Animation ShowAnimation = Animation.None;
public Animation HideAnimation = Animation.None;
public Animation MonthChangedAnimation = Animation.None;
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2a19bba98d87f014cb89bf2cb1067bae
timeCreated: 1467815858
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,41 @@
using System;
using System.Collections;
using System.Globalization;
using UnityEngine;
using UnityEngine.UI;
using UI.Tables;
namespace UI.Dates
{
public class DatePicker_ContentLayout : MonoBehaviour
{
public DatePicker DatePicker;
private RectTransform m_rectTransform = null;
protected RectTransform rectTransform
{
get
{
if (m_rectTransform == null) m_rectTransform = this.GetComponent<RectTransform>();
return m_rectTransform;
}
}
public void SetBorderSize(RectOffset borderSize)
{
rectTransform.offsetMin = new Vector2(borderSize.right, borderSize.bottom);
rectTransform.offsetMax = new Vector2(-borderSize.left, -borderSize.top);
}
public void SetBorderSize(int borderSize)
{
SetBorderSize(new RectOffset(borderSize, borderSize, borderSize, borderSize));
}
void OnRectTransformDimensionsChanged()
{
DatePicker.UpdateDisplay();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 225c28f22f54c8d44967529493e1caa2
timeCreated: 1467809084
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,161 @@
using System;
using System.Collections;
using System.Globalization;
using UnityEngine;
using UnityEngine.UI;
using UI.Tables;
namespace UI.Dates
{
[ExecuteInEditMode]
public class DatePicker_DateRange : MonoBehaviour
{
[SerializeField]
private SerializableDate m_FromDate;
public SerializableDate FromDate
{
get { return m_FromDate; }
set
{
SetProperty(ref m_FromDate, value);
Ref_DatePicker_From.SelectedDate = new SerializableDate(value);
}
}
[SerializeField]
private SerializableDate m_ToDate;
public SerializableDate ToDate
{
get { return m_ToDate; }
set
{
SetProperty(ref m_ToDate, value);
Ref_DatePicker_To.SelectedDate = new SerializableDate(value);
}
}
public DatePickerConfig Config;
public DatePicker Ref_DatePicker_From;
public DatePicker Ref_DatePicker_To;
public void UpdateDisplay()
{
if (!this.gameObject.activeInHierarchy) return;
m_FromDate = FromDate;
m_ToDate = ToDate;
ApplyConfig(Ref_DatePicker_From);
ApplyConfig(Ref_DatePicker_To);
if (Ref_DatePicker_From.SelectedDate.HasValue)
{
Ref_DatePicker_To.Config.DateRange.FromDate = Ref_DatePicker_From.SelectedDate;
Ref_DatePicker_To.Config.DateRange.RestrictFromDate = true;
}
if (Ref_DatePicker_To.SelectedDate.HasValue)
{
Ref_DatePicker_From.Config.DateRange.ToDate = Ref_DatePicker_To.SelectedDate;
Ref_DatePicker_From.Config.DateRange.RestrictToDate = true;
}
Ref_DatePicker_From.UpdateDisplay();
Ref_DatePicker_To.UpdateDisplay();
}
public void InputFieldClicked()
{
if (Config.InputField.ToggleDisplayWhenInputFieldClicked) ToggleDisplay();
}
public void ToggleDisplay()
{
if (Ref_DatePicker_From.IsVisible || Ref_DatePicker_To.IsVisible)
{
Hide();
}
else
{
Show();
}
}
public void Show()
{
Ref_DatePicker_From.Show();
Ref_DatePicker_To.Show();
}
public void Hide()
{
Ref_DatePicker_From.Hide();
Ref_DatePicker_To.Hide();
}
void ApplyConfig(DatePicker datePicker)
{
datePicker.Config = Config;
// we manipulate the DateRange configuration object afterwards, so we need to ensure that it is a unique instance or the changes will be applied to both DatePickers
datePicker.Config.DateRange = datePicker.Config.DateRange.Clone();
datePicker.Config.Misc = datePicker.Config.Misc.Clone();
datePicker.Config.Misc.CloseWhenDateSelected = false;
}
/// <summary>
/// Called by the DatePicker instances
/// </summary>
/// <param name="date"></param>
public void DateSelected(DateTime date)
{
FromDate = new SerializableDate(Ref_DatePicker_From.SelectedDate);
ToDate = new SerializableDate(Ref_DatePicker_To.SelectedDate);
this.UpdateDisplay();
DatePickerTimer.DelayedCall(0.1f,
() =>
{
if (Config.Misc.CloseWhenDateSelected)
{
// Only close if we have both from and to dates selected
if (FromDate.HasValue && ToDate.HasValue)
{
Hide();
}
}
},
this);
}
public void ModalOverlayClicked()
{
if (Config.Modal.CloseWhenModalOverlayClicked) Hide();
}
protected void SetProperty<T>(ref T currentValue, T newValue)
{
if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue)))
return;
currentValue = newValue;
UpdateDisplay();
}
/*void OnValidate()
{
if (!this.gameObject.activeInHierarchy) return;
DatePickerTimer.DelayedCall(0f, () =>
{
FromDate = m_FromDate;
ToDate = m_ToDate;
}, this, false);
}*/
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a14d9d0f3e6133f47971e80348738636
timeCreated: 1469620780
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,32 @@
using System;
using System.Collections;
using System.Globalization;
using UnityEngine;
using UnityEngine.UI;
using UI.Tables;
namespace UI.Dates
{
public class DatePicker_DayButton : DatePicker_Button
{
public DateTime Date;
public DatePickerDayButtonType Type;
[HideInInspector]
public DatePicker DatePicker;
public void Clicked()
{
if (!Button.interactable) return;
DatePicker.DayButtonClicked(Date);
}
public void MouseOver()
{
if (!Button.interactable) return;
DatePicker.DayButtonMouseOver(Date);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: cab375c3d71687b43bdfe322a109d817
timeCreated: 1467814440
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,205 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Linq;
namespace UI.Dates
{
public class DatePicker_DayButton_Pool : MonoBehaviour
{
private DatePicker _datePicker;
private DatePicker datePicker
{
get
{
if (_datePicker == null) _datePicker = this.GetComponent<DatePicker>();
return _datePicker;
}
}
[SerializeField]
private RectTransform _poolRect;
private RectTransform poolRect
{
get
{
if (_poolRect == null)
{
_poolRect = (RectTransform)(new GameObject("Pool Rect", typeof(RectTransform)).transform);
_poolRect.SetParent(this.transform);
_poolRect.gameObject.SetActive(false);
}
return _poolRect;
}
}
private Dictionary<DatePickerDayButtonType, DatePicker_DayButton_Pool_List> pool = new Dictionary<DatePickerDayButtonType, DatePicker_DayButton_Pool_List>();
public void AddExistingButton(DatePicker_DayButton button)
{
GetPoolList(button.Type).AddExistingButtonToPool(button);
}
public DatePicker_DayButton GetButton(DatePickerDayButtonType type)
{
return GetPoolList(type).GetButton();
}
private DatePicker_DayButton_Pool_List GetPoolList(DatePickerDayButtonType type)
{
DatePicker_DayButton_Pool_List poolList = null;
if (!pool.ContainsKey(type))
{
poolList = new DatePicker_DayButton_Pool_List(type, poolRect);
pool.Add(type, poolList);
var template = GetTemplate(type);
poolList.SetTemplate(template);
}
else
{
poolList = pool[type];
}
return poolList;
}
public void FreeAll()
{
foreach (var kvp in pool)
{
kvp.Value.FreeAll();
}
}
public void InvalidateAll()
{
foreach (var kvp in pool)
{
kvp.Value.Invalidate();
}
}
public void InvalidateType(DatePickerDayButtonType type)
{
if (!pool.ContainsKey(type)) return;
pool[type].Invalidate();
}
private DatePicker_DayButton GetTemplate(DatePickerDayButtonType type)
{
switch (type)
{
case DatePickerDayButtonType.Today:
return datePicker.Ref_Template_Day_Today;
case DatePickerDayButtonType.SelectedDay:
return datePicker.Ref_Template_Day_SelectedDay;
case DatePickerDayButtonType.CurrentMonth:
return datePicker.Ref_Template_Day_CurrentMonth;
case DatePickerDayButtonType.OtherMonths:
return datePicker.Ref_Template_Day_OtherMonths;
}
return null;
}
}
public class DatePicker_DayButton_Pool_List
{
//private DatePickerDayButtonType type;
private DatePicker_DayButton template;
private RectTransform poolRect;
private List<DatePicker_DayButton_Pool_List_Item> pool = new List<DatePicker_DayButton_Pool_List_Item>();
public DatePicker_DayButton_Pool_List(DatePickerDayButtonType type, RectTransform poolRect)
{
//this.type = type;
this.poolRect = poolRect;
}
public void SetTemplate(DatePicker_DayButton template)
{
this.template = template;
}
public void AddExistingButtonToPool(DatePicker_DayButton button)
{
if (pool.Any(p => p.button == button)) return;
var buttonItem = new DatePicker_DayButton_Pool_List_Item() { button = button };
pool.Add(buttonItem);
}
public DatePicker_DayButton GetButton()
{
var buttonItem = pool.FirstOrDefault(i => !i.inUse && i.button != null);
if (buttonItem == null)
{
buttonItem = new DatePicker_DayButton_Pool_List_Item(template);
pool.Add(buttonItem);
}
buttonItem.inUse = true;
return buttonItem.button;
}
public void FreeAll()
{
if (pool.Count == 0) return;
pool.ForEach(p =>
{
if (p == null) return;
p.inUse = false;
p.button.transform.SetParent(poolRect);
});
}
public void Invalidate()
{
var items = pool.Select(p => p.button).ToList();
foreach (var i in items)
{
if (i == null) continue;
if (Application.isPlaying) GameObject.Destroy(i.gameObject);
else GameObject.DestroyImmediate(i.gameObject);
}
// if, for example, our template has changed, all of our pool items are invalid, so we should remove them
pool.Clear();
}
}
class DatePicker_DayButton_Pool_List_Item
{
public bool inUse = false;
public DatePicker_DayButton button = null;
public DatePicker_DayButton_Pool_List_Item()
{
}
public DatePicker_DayButton_Pool_List_Item(DatePicker_DayButton template)
{
button = GameObject.Instantiate(template);
button.IsTemplate = false;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ac0061fa239b2684bae435fb5f8418ff
timeCreated: 1487598754
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,48 @@
using System;
using System.Collections;
using System.Globalization;
using UnityEngine;
using UnityEngine.UI;
using UI.Tables;
using UnityEngine.Serialization;
using TMPro;
namespace UI.Dates
{
public class DatePicker_DayHeader : MonoBehaviour
{
#pragma warning disable
[SerializeField, FormerlySerializedAs("HeaderText"), HideInInspector]
private Text oldHeaderText;
#pragma warning restore
[SerializeField]
private TextMeshProUGUI m_HeaderText;
public TextMeshProUGUI HeaderText
{
get
{
if (m_HeaderText == null)
{
if (oldHeaderText == null)
{
Debug.LogError("[DatePicker] An error ocurred while upgrading to TextMesh Pro - unable to locate original text element for a day header.");
return null;
}
m_HeaderText = DatePicker_TextMeshProUtilities.ReplaceTextElementWithTextMeshPro(oldHeaderText);
m_HeaderText.enableAutoSizing = true;
m_HeaderText.fontSizeMin = 2;
m_HeaderText.fontSizeMax = 16;
}
return m_HeaderText;
}
}
public TableCell Cell;
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 18a923d3d6950f942b48f9378fd1df80
timeCreated: 1467802994
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,61 @@
using System;
using System.Collections;
using System.Globalization;
using UnityEngine;
using UnityEngine.UI;
using UI.Tables;
namespace UI.Dates
{
public enum Animation
{
None,
Slide,
Fade
}
public enum DatePickerPosition
{
Below,
Above
}
public enum AnimationType
{
Show,
Hide
}
public enum Alignment
{
Left,
Center,
Right
}
public enum VisibleDateDefaultBehaviour
{
UseStoredValue,
UseTodaysDate
}
public enum DateSelectionMode
{
SingleDate,
MultipleDates
}
public enum WeekNumberMode
{
WeekOfMonth,
WeekOfYear
}
public enum DatePickerDayButtonType
{
Today,
SelectedDay,
CurrentMonth,
OtherMonths
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 84b11e32f7d528d4786576c3f0d1048d
timeCreated: 1469020948
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,49 @@
using System;
using System.Collections;
using System.Globalization;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UI;
using UI.Tables;
using TMPro;
namespace UI.Dates
{
public class DatePicker_Header : MonoBehaviour
{
#pragma warning disable
[SerializeField, FormerlySerializedAs("HeaderText")]
private Text oldHeaderText;
#pragma warning restore
[SerializeField]
private TextMeshProUGUI m_HeaderText;
public TextMeshProUGUI HeaderText
{
get
{
if (m_HeaderText == null)
{
if (oldHeaderText == null)
{
Debug.LogError("[DatePicker] An error ocurred while upgrading to TextMesh Pro - unable to locate original header text element.");
return null;
}
m_HeaderText = DatePicker_TextMeshProUtilities.ReplaceTextElementWithTextMeshPro(oldHeaderText);
}
return m_HeaderText;
}
}
public DatePicker_Button PreviousMonthButton;
public DatePicker_Button NextMonthButton;
public DatePicker_Button PreviousYearButton;
public DatePicker_Button NextYearButton;
public Image Background;
public TableRow Row;
public TableLayout TableLayout;
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 59f0e0eff86cd8d4da0e663da0496ba0
timeCreated: 1467815188
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,94 @@
using System;
using System.Collections;
using System.Globalization;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UI.Tables;
namespace UI.Dates
{
/// <summary>
/// A special button which responds when held down
/// Note: These are intended to supplement the existing Next/Previous buttons,
/// and as such, they require that the existing buttons already have an event handler defined
/// (which this component will then extract and replace at runtime)
/// </summary>
public class DatePicker_HoldButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
public Button Button;
public float Delay = 0.5f;
private bool pointerDown = false;
private Action action;
private float lastInvokeTime = 0;
private int executionCount = 0;
void Start()
{
Button = this.GetComponent<Button>();
// The default buttons have click event handlers
int eventCount = Button.onClick.GetPersistentEventCount();
MonoBehaviour[] target = new MonoBehaviour[eventCount];
string[] method = new string[eventCount];
for (int i = 0; i < eventCount; ++i)
{
target[i] = (MonoBehaviour)Button.onClick.GetPersistentTarget(i);
method[i] = Button.onClick.GetPersistentMethodName(i);
}
action = () =>
{
for (int i = 0; i < eventCount; ++i)
{
target[i].Invoke(method[i], 0);
}
};
/*
// The default buttons have click event handlers
var target = Button.onClick.GetPersistentTarget(0);
var method = Button.onClick.GetPersistentMethodName(0);
action = () => { ((MonoBehaviour)target).Invoke(method, 0); };*/
// This appears to be the only way to remove persistent listeners in code (at runtime)
Button.onClick = new Button.ButtonClickedEvent();
}
public void OnPointerDown(PointerEventData eventData)
{
pointerDown = true;
Execute();
}
public void OnPointerUp(PointerEventData eventData)
{
pointerDown = false;
executionCount = 0;
}
void Update()
{
if (!Button.interactable) return;
var _delay = Delay / executionCount;
if (pointerDown && lastInvokeTime < Time.realtimeSinceStartup - _delay)
{
Execute();
}
}
void Execute()
{
if (!Button.interactable) return;
lastInvokeTime = Time.realtimeSinceStartup;
executionCount++;
action.Invoke();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 988ffe1fd29e7994b8411bb07695a415
timeCreated: 1518610168
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,214 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
using UI.Tables;
namespace UI.Dates
{
[ExecuteInEditMode]
public class DatePicker_InputField : MonoBehaviour
{
[SerializeField]
private DateSelectionMode m_DateSelectionMode = DateSelectionMode.SingleDate;
public DateSelectionMode DateSelectionMode
{
get { return m_DateSelectionMode; }
set
{
SetProperty(ref m_DateSelectionMode, value);
}
}
[SerializeField]
private SerializableDate m_SelectedDate;
public SerializableDate SelectedDate
{
get { return m_SelectedDate; }
set
{
SetProperty(ref m_SelectedDate, value);
if (Ref_InputField != null)
{
Ref_InputField.text = (SelectedDate.HasValue) ? SelectedDate.Date.ToString(Ref_SharedDatePicker.Config.Format.DateFormat) : "";
}
if (Ref_SharedDatePicker.Config.Misc.CloseWhenDateSelected) HideCalendar();
}
}
[SerializeField]
private List<SerializableDate> m_SelectedDates = new List<SerializableDate>();
public List<SerializableDate> SelectedDates
{
get { return m_SelectedDates; }
set
{
SetProperty(ref m_SelectedDates, value);
}
}
public DatePickerInputFieldConfig InputFieldConfig;
public DatePickerEventConfig EventConfig;
[Header("References")]
public DatePicker Ref_SharedDatePicker;
#pragma warning disable
[SerializeField, UnityEngine.Serialization.FormerlySerializedAs("Ref_InputField"), HideInInspector]
private InputField Ref_OldInputField;
#pragma warning restore
[SerializeField]
private TMPro.TMP_InputField m_Ref_InputField;
public TMPro.TMP_InputField Ref_InputField
{
get
{
if (m_Ref_InputField == null && Ref_OldInputField != null)
{
m_Ref_InputField = DatePicker_TextMeshProUtilities.ReplaceInputFieldWithTextMeshPro(Ref_OldInputField);
}
return m_Ref_InputField;
}
}
public TableLayout Ref_InputFieldContainer;
public TableCell Ref_InputFieldToggleButtonCell;
public void UpdateDisplay()
{
if (Ref_InputField != null && Ref_InputFieldContainer != null && Ref_InputFieldToggleButtonCell != null)
{
UpdateInputFieldText();
var valueBefore = Ref_InputFieldContainer.ColumnWidths.ToList();
if (InputFieldConfig.ShowToggleButton)
{
Ref_InputFieldContainer.ColumnWidths = new List<float> { 0, InputFieldConfig.ToggleButtonWidth };
Ref_InputFieldToggleButtonCell.gameObject.SetActive(true);
}
else
{
Ref_InputFieldContainer.ColumnWidths = new List<float> { 0 };
Ref_InputFieldToggleButtonCell.gameObject.SetActive(false);
}
if (!valueBefore.SequenceEqual(Ref_InputFieldContainer.ColumnWidths)) Ref_InputFieldContainer.UpdateLayout();
}
}
public void InputFieldClicked()
{
if (InputFieldConfig.ToggleDisplayWhenInputFieldClicked) ToggleDisplay();
}
public void ToggleDisplay()
{
if (Ref_SharedDatePicker == null)
{
Debug.LogError("[DatePicker_InputField] This Input Field needs 'Ref_SharedDatePicker' populated in order to function correctly. You can create a shared DatePicker using the 'DatePicker - Shared Calendar' menu item.");
return;
}
if (Ref_SharedDatePicker.gameObject.activeInHierarchy)
{
HideCalendar();
}
else
{
ShowCalendar();
}
}
void ShowCalendar()
{
Ref_SharedDatePicker.Ref_InputFieldContainer = Ref_InputFieldContainer;
Ref_SharedDatePicker.Ref_InputField = Ref_InputField;
Ref_SharedDatePicker.Ref_InputFieldToggleButtonCell = Ref_InputFieldToggleButtonCell;
Ref_SharedDatePicker.Config.InputField = InputFieldConfig;
Ref_SharedDatePicker.Config.Events.OnDaySelected.RemoveAllListeners();
Ref_SharedDatePicker.Config.Events.OnDaySelected.AddListener(OnDaySelected);
Ref_SharedDatePicker.Config.Events.OnDayMouseOver.RemoveAllListeners();
Ref_SharedDatePicker.Config.Events.OnDayMouseOver.AddListener(OnDayMouseOver);
Ref_SharedDatePicker.DateSelectionMode = DateSelectionMode;
Ref_SharedDatePicker.SelectedDate = SelectedDate;
Ref_SharedDatePicker.SelectedDates = SelectedDates;
Ref_SharedDatePicker.IsSharedCalendar = true;
Ref_SharedDatePicker.Show();
DatePickerTimer.AtEndOfFrame(() =>
{
Ref_SharedDatePicker.UpdateDisplay();
}, this, true);
}
void HideCalendar()
{
Ref_SharedDatePicker.Hide();
}
protected void SetProperty<T>(ref T currentValue, T newValue)
{
if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue)))
return;
currentValue = newValue;
UpdateDisplay();
}
private void OnDaySelected(DateTime date)
{
if (DateSelectionMode == Dates.DateSelectionMode.SingleDate)
{
SelectedDate = date;
}
else
{
// let the DatePicker handle it
SelectedDates = Ref_SharedDatePicker.SelectedDates;
}
if (EventConfig.OnDaySelected != null) EventConfig.OnDaySelected.Invoke(date);
}
private void OnDayMouseOver(DateTime date)
{
if (EventConfig.OnDayMouseOver != null) EventConfig.OnDayMouseOver.Invoke(date);
}
public void UpdateInputFieldText()
{
if (Ref_InputField != null)
{
switch (DateSelectionMode)
{
case Dates.DateSelectionMode.SingleDate:
Ref_InputField.text = (SelectedDate.HasValue) ? SelectedDate.Date.ToString(Ref_SharedDatePicker.Config.Format.DateFormat) : "";
break;
case Dates.DateSelectionMode.MultipleDates:
var valueCount = SelectedDates.Count(s => s.HasValue);
Ref_InputField.text = ((valueCount == 1) ? SelectedDates.First(s => s.HasValue).Date.ToString(Ref_SharedDatePicker.Config.Format.DateFormat)
: (valueCount > 1 ? "Multiple Dates" : ""));
break;
}
}
}
private void Start()
{
UpdateDisplay();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1d6642118b5725140b828a40ee3e6969
timeCreated: 1481978679
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,167 @@
using UnityEngine;
using System;
using System.Collections;
using System.Globalization;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace UI.Dates
{
public static class DatePicker_Instantiation
{
private static Dictionary<string, UnityEngine.Object> m_CachedResources = new Dictionary<string, UnityEngine.Object>(StringComparer.OrdinalIgnoreCase);
public static void FixInstanceTransform(RectTransform baseTransform, RectTransform instanceTransform)
{
//instanceTransform.localScale = baseTransform.localScale;
instanceTransform.localScale = Vector3.one;
instanceTransform.anchoredPosition = baseTransform.anchoredPosition;
instanceTransform.sizeDelta = baseTransform.sizeDelta;
instanceTransform.anchoredPosition3D = new Vector3(baseTransform.anchoredPosition3D.x, baseTransform.anchoredPosition3D.y, 0);
instanceTransform.localPosition = Vector3.zero;
instanceTransform.localRotation = new Quaternion();
}
public static GameObject InstantiatePrefab(string name, bool playMode = false, bool generateUndo = true, Transform parent = null)
{
var prefab = DatePicker_Instantiation.LoadResource<GameObject>("Prefabs/" + name);
if (prefab == null)
{
throw new UnityException(String.Format("Could not find prefab '{0}'!", name));
}
#if UNITY_EDITOR
if(!playMode) parent = UnityEditor.Selection.activeTransform;
#endif
var gameObject = GameObject.Instantiate(prefab) as GameObject;
gameObject.name = name;
if (parent == null || !(parent is RectTransform))
{
parent = GetCanvasTransform();
}
gameObject.transform.SetParent(parent);
var transform = (RectTransform)gameObject.transform;
var prefabTransform = (RectTransform)prefab.transform;
FixInstanceTransform(prefabTransform, transform);
// Override the prefab's visible date with today's date
var datePicker = gameObject.GetComponent<DatePicker>();
if(datePicker != null) datePicker.VisibleDate = DateTime.Today;
#if UNITY_EDITOR
if (generateUndo)
{
UnityEditor.Undo.RegisterCreatedObjectUndo(gameObject, "Created " + name);
}
#endif
return gameObject;
}
public static Transform GetCanvasTransform()
{
Canvas canvas = null;
#if UNITY_EDITOR
// Attempt to locate a canvas object parented to the currently selected object
if (!Application.isPlaying && UnityEditor.Selection.activeGameObject != null)
{
canvas = FindParentOfType<Canvas>(UnityEditor.Selection.activeGameObject);
//canvas = UnityEditor.Selection.activeTransform.GetComponentInParent<Canvas>();
}
#endif
if (canvas == null)
{
// Attempt to find a canvas anywhere
canvas = UnityEngine.Object.FindObjectOfType<Canvas>();
if (canvas != null) return canvas.transform;
}
// if we reach this point, we haven't been able to locate a canvas
// ...So I guess we'd better create one
GameObject canvasGameObject = new GameObject("Canvas");
canvasGameObject.layer = LayerMask.NameToLayer("UI");
canvas = canvasGameObject.AddComponent<Canvas>();
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
canvasGameObject.AddComponent<CanvasScaler>();
canvasGameObject.AddComponent<GraphicRaycaster>();
#if UNITY_EDITOR
UnityEditor.Undo.RegisterCreatedObjectUndo(canvasGameObject, "Create Canvas");
#endif
var eventSystem = UnityEngine.Object.FindObjectOfType<EventSystem>();
if (eventSystem == null)
{
GameObject eventSystemGameObject = new GameObject("EventSystem");
eventSystem = eventSystemGameObject.AddComponent<EventSystem>();
eventSystemGameObject.AddComponent<StandaloneInputModule>();
#if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
eventSystemGameObject.AddComponent<TouchInputModule>();
#endif
#if UNITY_EDITOR
UnityEditor.Undo.RegisterCreatedObjectUndo(eventSystemGameObject, "Create EventSystem");
#endif
}
return canvas.transform;
}
public static T FindParentOfType<T>(GameObject childObject)
where T : UnityEngine.Object
{
Transform t = childObject.transform;
while (t.parent != null)
{
var component = t.parent.GetComponent<T>();
if (component != null) return component;
t = t.parent.transform;
}
// We didn't find anything
return null;
}
public static T LoadResource<T>(string path, bool ignoreCache = false)
where T : UnityEngine.Object
{
UnityEngine.Object resource = null;
if (!ignoreCache)
{
// include the type name in the cache path, so that if we try to cache two different objects that share the same path, we can still access them both
var cachePath = String.Format("{0}|{1}", typeof(T).Name, path);
if (!m_CachedResources.TryGetValue(cachePath, out resource))
{
resource = Resources.Load<T>(path);
if (resource != null)
{
m_CachedResources.Add(cachePath, resource);
}
}
}
else
{
resource = Resources.Load<T>(path);
}
return resource as T;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8bbd531db3b732746a86ee296c74f7fb
timeCreated: 1469626481
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3eda37ef069e0034fae0d9869a8d1ac9
folderAsset: yes
timeCreated: 1467636730
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,239 @@
v1.26
------------------------------------------------------------------------------
- Added the option to set the width and padding of the Previous/Next Year/Month
button cells
(Config -> Header -> Buttons -> Month Button Cell Width)
(Config -> Header -> Buttons -> Year Button Cell Width)
- Added the option to toggle the 'Preserve Aspect' property for the
Previous/Next Year/Month buttons
- Fixed a bug where non-interactable buttons (next/previous) could still be
used
- Fixed a bug where it was possible for the next/previous year buttons
could select a month outside of the Date Range limit
------------------------------------------------------------------------------
v1.25
------------------------------------------------------------------------------
- Added the option to prohibit specific dates from selection
(Config -> Date Range -> Prohibited Dates)
- Added the option to prohibit specific days from selection
(Config -> Date Range -> Permitted Week Days)
------------------------------------------------------------------------------
v1.24
------------------------------------------------------------------------------
- Added more options for font size customization (min, max, auto sizing)
- Fixed a bug where adjusting the header height wouldn't immediately update
in Unity 2019.2
------------------------------------------------------------------------------
v1.23
------------------------------------------------------------------------------
- Added the GetDayButtons() method which allows you to retrrieve references
to the day buttons in the DatePicker, optionally filtering by a specific
type (e.g. SelectedDay/CurrentMonth/OtherMonth)
- Added the GetDayButton(DateTime date) which allows you to retrieve a reference
to a specific day button
- Added the GetSerializedConfiguration() method which returns a string
representing the configuration of the DatePicker which you can then save
- Added the SetConfigFromJsonString() which allows you to set the configuration
of the DatePicker based on a serialized string
- DatePicker will now re-use the existing TableLayout structure where possible
when updating its layout rather than recreating rows and cells
- Note: Button templates are no longer guaranteed to be invalidated when
DatePicker is first initialized in Play mode - if you make changes to the
templates, be sure to click the Invalidate Button Templates button.
- Fixed an issue where sometimes, for some reason, .NET's DateTimeFormatInfo
had a blank entry in AbbreviatedDayNames on Android (by stripping out
the blank entry before using the day names collection)
------------------------------------------------------------------------------
v1.22
------------------------------------------------------------------------------
- DatePicker Prefabs now have TextMesh Pro instead of 'Text' components,
as such the in-place upgrade process will no longer execute on new
DatePicker instances created from the prefabs.
- Suppressed some compiler warning messages about old fields not being populated
------------------------------------------------------------------------------
v1.21
------------------------------------------------------------------------------
- Fixed an issue where day button colors were not being applied in more
recent versions of Unity
------------------------------------------------------------------------------
v1.20
------------------------------------------------------------------------------
- All Text fields will now be automatically replaced with TextMesh Pro fields
This process will attempt to preserve whatever styles you may have been using;
but may not be perfect. Some small adjustments may be required.
- Dropped support for versions of Unity older than 2018.2
- Fixed some issues with Shared Calendars for multiple Input Fields
------------------------------------------------------------------------------
v1.19
------------------------------------------------------------------------------
- Added the Enable()/Disable() methods to DatePicker. Disable() will disable
(but not hide) the DatePicker by preventing it from responding to pointer
events. Enable() will cause it to resume responding to such events.
------------------------------------------------------------------------------
v1.18
------------------------------------------------------------------------------
- The Next/Previous Year/Month buttons now work when holding them down,
rather than just when they are pushed. The longer you hold them down for,
the faster DatePicker will move forward/backward through the months/years
- Fixed the DatePicker_DateRange Prefab such that the Next/Previous Year
buttons now correctly switch years rather than months
------------------------------------------------------------------------------
v1.17
------------------------------------------------------------------------------
- Updated to TableLayout v1.12
------------------------------------------------------------------------------
V1.16
------------------------------------------------------------------------------
- Made an adjustment to DatePicker's initial setup so that it will always
execute at least once, even if the DatePicker is deactivated before the end
of its first active frame.
------------------------------------------------------------------------------
V1.15
------------------------------------------------------------------------------
- Updated TableLayout to v1.11 (fixing a positioning issue in 2017.3)
------------------------------------------------------------------------------
V1.14
------------------------------------------------------------------------------
- Updated TableLayout to v1.09
------------------------------------------------------------------------------
V1.13
------------------------------------------------------------------------------
- Updated TableLayout to v1.08
- Added a workaround to an exception on iOS when applying configuration
values
------------------------------------------------------------------------------
V1.12
------------------------------------------------------------------------------
- Introduced object pooling for day buttons, markedly improving performance.
If you make any changes to button templates, you should either click the
'Invalidate Button Templates' button, or call
datePicker.InvalidateDayButtonTemplate(type)
or datePicker.InvalidateAllDayButtonTemplates() at runtime, this will reset
the pool so that new buttons can be made using the updated template(s).
------------------------------------------------------------------------------
V1.11
------------------------------------------------------------------------------
- Added the SerializeableDate.ToDateString() extension method to the UI.Dates
namespace - you can use this instead of SerializeableDate.date.ToDateString()
- Added a new optional Week Numbers column, to activate this, use the
Config -> Week Days -> Show Week Numbers property.
- Added 'Next Year' and 'Previous Year' buttons to the in-editor Calendar
------------------------------------------------------------------------------
V1.10
------------------------------------------------------------------------------
- Fixed a bug in the 'DatePicker - Date Range' prefab which caused the
DatePickers to open individually when the input fields were clicked instead
of both opening together.
- Added the ability to select multiple dates at once (can be used with all
normal DatePickers as well as a Shared DatePicker instance, although it
is not compatible with Date Range selection)
------------------------------------------------------------------------------
V1.09
------------------------------------------------------------------------------
- You can now control the font size of week day headers and day buttons
through the use of the new 'Week Days -> Text -> Font Size' and
'Days -> Font Size' properties.
- Fixed a positioning issue in 'Screen Space - Overlay' mode.
------------------------------------------------------------------------------
V1.08
------------------------------------------------------------------------------
- The next/previous year buttons will now be disabled if they would lead
to a date which exceeds the available date range (as per the next/previous
month buttons).
- Fixed some display issues in World Space mode.
- Updated TableLayout to V1.07
------------------------------------------------------------------------------
V1.07
------------------------------------------------------------------------------
- New 'Shared Calendar' menu items added. You can now create multiple
popup DatePickers that share a single DatePicker calendar instance.
This may improve performance in applications which use a lot of DatePicker fields
simultaneously.
To use this:
1. Use the 'UI/DatePicker/Shared Calendar/Shared Calendar' menu item
to create the calendar object that will be used by all of your DatePicker
popups. You can customise this as you wish. NOTE: It will be disabled by
by default, you will need to enable it to view the changes you make in the
editor. You should then disable it again before entering play mode.
2. Use the 'UI/DatePicker/Shared Calendar/DatePicker - Popup (Shared Calendar)'
menu item to create as many input fields as you wish.
3. On each input field, set the 'Ref_SharedDatePicker' property to the
calendar created in step (1). The input fields support multi-object editing,
so you can do this in bulk. You can also do this in code, provided that the
property is populated before the user can click on the DatePicker to select
a date.
- Updated TableLayout to v1.06
------------------------------------------------------------------------------
V1.06
------------------------------------------------------------------------------
- Popup DatePickers should now work better in Screen Space - Camera canvas
render mode
- Fixed a bug where the Toggle Button width would not always automatically update
when the width value was changed
------------------------------------------------------------------------------
V1.05
------------------------------------------------------------------------------
- Fixed an exception which was sometimes occurring in the inspector
- Added a new property which controls how the Visible Date is determined
during initialization.
- The Inline DatePicker prefab no longer has a date selected by default
------------------------------------------------------------------------------
V1.04
------------------------------------------------------------------------------
- Updated TableLayout to V1.03
------------------------------------------------------------------------------
V1.03
------------------------------------------------------------------------------
- Added new options to Config -> Sizing which allow you to control the width
of the DatePicker itself independently of the input field in Popup DatePickers
- Added a new option to Config -> Input Field which allows you to control
the positioning of the DatePicker relative to the Input Field container
(Specifically, Left-aligned, Center-aligned, and Right-aligned). This will only
have a visible effect if the DatePicker's width has been set (as above).
------------------------------------------------------------------------------
V1.02
------------------------------------------------------------------------------
- Fixed a bug when using very high (or very low) resolutions which prevented
DatePicker popups from appearing in the correct location relative to their
InputField
------------------------------------------------------------------------------
V1.01
------------------------------------------------------------------------------
- Added the ToDate and FromDate properties to DatePicker_DateRange to make it
easier to configure
- Made a few minor adjustments to improve optional integration with XmlLayout.
------------------------------------------------------------------------------
V1.00
------------------------------------------------------------------------------
- Initial Release
------------------------------------------------------------------------------

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6cfe6a240c975c946865f4c96650669a
timeCreated: 1470062641
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d846c11f4a903fc45b8ff5b779815440
timeCreated: 1470062556
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 4087ec0dbb84f7a4dbbd3dfa424ecf82
folderAsset: yes
timeCreated: 1467640078
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,336 @@
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Globalization;
using System.Linq;
namespace UI.Dates
{
[CustomPropertyDrawer(typeof(SerializableDate))]
public class DatePickerDateDrawer : PropertyDrawer
{
private GUIContent buttonImage = null;
private GUIStyle textStyle = null;
//private bool showDatePicker = false;
private GUIContent m_leftArrowImage;
private GUIContent leftArrowImage
{
get
{
if (m_leftArrowImage == null) m_leftArrowImage = new GUIContent(Resources.Load("Sprites/Editor/Editor_Arrow_Left") as Texture2D);
return m_leftArrowImage;
}
}
private GUIContent m_doubleLeftArrowImage;
private GUIContent doubleLeftArrowImage
{
get
{
if (m_doubleLeftArrowImage == null) m_doubleLeftArrowImage = new GUIContent(Resources.Load("Sprites/Editor/Editor_Arrow_Double_Left") as Texture2D);
return m_doubleLeftArrowImage;
}
}
private GUIContent m_rightArrowImage;
private GUIContent rightArrowImage
{
get
{
if (m_rightArrowImage == null) m_rightArrowImage = new GUIContent(Resources.Load("Sprites/Editor/Editor_Arrow_Right") as Texture2D);
return m_rightArrowImage;
}
}
private GUIContent m_doubleRightArrowImage;
private GUIContent doubleRightArrowImage
{
get
{
if (m_doubleRightArrowImage == null) m_doubleRightArrowImage = new GUIContent(Resources.Load("Sprites/Editor/Editor_Arrow_Double_Right") as Texture2D);
return m_doubleRightArrowImage;
}
}
private GUIStyle m_monthNameStyle;
private GUIStyle monthNameStyle
{
get
{
if (m_monthNameStyle == null)
{
m_monthNameStyle = new GUIStyle(EditorStyles.label);
m_monthNameStyle.fontStyle = FontStyle.Bold;
m_monthNameStyle.fontSize = 14;
m_monthNameStyle.alignment = TextAnchor.MiddleCenter;
}
return m_monthNameStyle;
}
}
private GUIStyle m_dayNameStyle;
private GUIStyle dayNameStyle
{
get
{
if (m_dayNameStyle == null)
{
m_dayNameStyle = new GUIStyle(EditorStyles.label);
m_dayNameStyle.alignment = TextAnchor.MiddleCenter;
m_dayNameStyle.fontStyle = FontStyle.Bold;
}
return m_dayNameStyle;
}
}
private GUIStyle m_dayButtonStyle;
private GUIStyle dayButtonStyle
{
get
{
if (m_dayButtonStyle == null)
{
m_dayButtonStyle = new GUIStyle(EditorStyles.miniButton);
m_dayButtonStyle.fontSize = 12;
m_dayButtonStyle.richText = true;
m_dayButtonStyle.alignment = TextAnchor.MiddleCenter;
m_dayButtonStyle.normal.textColor = Color.black;
}
return m_dayButtonStyle;
}
}
private GUIStyle m_dayButtonStyle_OtherMonth;
private GUIStyle dayButtonStyle_OtherMonth
{
get
{
if (m_dayButtonStyle_OtherMonth == null)
{
m_dayButtonStyle_OtherMonth = new GUIStyle(dayButtonStyle);
m_dayButtonStyle_OtherMonth.normal.textColor = new Color(0, 0, 0, 0.5f);
}
return m_dayButtonStyle_OtherMonth;
}
}
private GUIStyle m_dayButtonStyle_CurrentDay;
private GUIStyle dayButtonStyle_CurrentDay
{
get
{
if(m_dayButtonStyle_CurrentDay == null)
{
m_dayButtonStyle_CurrentDay = new GUIStyle(dayButtonStyle);
m_dayButtonStyle_CurrentDay.fontStyle = FontStyle.Bold;
}
return m_dayButtonStyle_CurrentDay;
}
}
private DateTime SelectedDate;
private DateTime? VisibleDate;
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
if (!property.FindPropertyRelative("m_showEditorCalendar").boolValue)
return 24f;
else
return 292f;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var showDatePickerProperty = property.FindPropertyRelative("m_showEditorCalendar");
var showDatePicker = showDatePickerProperty.boolValue;
var serializedProperty = property.FindPropertyRelative("m_SerializedDate");
SelectedDate = !String.IsNullOrEmpty(serializedProperty.stringValue) ? DateTime.Parse(serializedProperty.stringValue) : DateTime.Today;
if (!String.IsNullOrEmpty(serializedProperty.stringValue))
{
if (!DateTime.TryParse(serializedProperty.stringValue, out SelectedDate))
{
SelectedDate = DateTime.Today;
}
}
else
{
SelectedDate = DateTime.Today;
}
if (buttonImage == null)
{
buttonImage = new GUIContent(Resources.Load("Sprites/Editor/Calendar_Editor") as Texture2D);
}
if (textStyle == null)
{
textStyle = new GUIStyle(EditorStyles.textField);
textStyle.fontSize = 18;
textStyle.alignment = TextAnchor.MiddleCenter;
}
EditorGUI.BeginProperty(position, label, property);
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
var indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
var textFieldPosition = new Rect(position.x, position.y, 224, 24);
var buttonPosition = new Rect(position.x + 224, position.y, 40, 24);
EditorGUI.BeginDisabledGroup(true);
serializedProperty.stringValue = EditorGUI.TextField(textFieldPosition, serializedProperty.stringValue, textStyle);
EditorGUI.EndDisabledGroup();
if (GUI.Button(buttonPosition, buttonImage))
{
showDatePicker = !showDatePicker;
}
buttonPosition.x += 48;
buttonPosition.width = 24;
if (GUI.Button(buttonPosition, "X"))
{
serializedProperty.stringValue = null;
showDatePicker = false;
}
position.y += 24;
if (showDatePicker)
{
showDatePicker = DrawDatePicker(position, serializedProperty, showDatePickerProperty);
}
EditorGUI.indentLevel = indent;
showDatePickerProperty.boolValue = showDatePicker;
EditorGUI.EndProperty();
}
bool DrawDatePicker(Rect position, SerializedProperty property, SerializedProperty showDatePickerProperty)
{
if (!VisibleDate.HasValue) VisibleDate = SelectedDate;
float startX = position.x;
var calendarPosition = new Rect(position.x, position.y, 224, 256);
EditorGUI.DrawRect(calendarPosition, new Color(0, 0, 0, 0.1f));
var rowSize = 224f / 7f;
var columnSize = rowSize;
// previous year button
if(GUI.Button(new Rect(position.x, position.y, rowSize, columnSize), doubleLeftArrowImage))
{
VisibleDate = VisibleDate.Value.AddYears(-1);
}
position.x += columnSize;
// previous month button
if (GUI.Button(new Rect(position.x, position.y, rowSize, columnSize), leftArrowImage))
{
VisibleDate = VisibleDate.Value.AddMonths(-1);
}
position.x += columnSize;
// month name
GUI.Label(new Rect(position.x, position.y, columnSize * 3, rowSize), VisibleDate.Value.ToString("MMM yyyy"), monthNameStyle);
position.x += columnSize * 3;
// next month button
if(GUI.Button(new Rect(position.x, position.y, columnSize, rowSize), rightArrowImage))
{
VisibleDate = VisibleDate.Value.AddMonths(+1);
}
position.x += columnSize;
// next year button
if (GUI.Button(new Rect(position.x, position.y, columnSize, rowSize), doubleRightArrowImage))
{
VisibleDate = VisibleDate.Value.AddYears(+1);
}
// next row
position.x = startX;
position.y += rowSize;
// Day of week headers
var dayNames = DatePickerUtilities.GetAbbreviatedDayNames().Select(d => d.Substring(0,1)).ToArray();
foreach (var dayName in dayNames)
{
GUI.Label(new Rect(position.x, position.y, columnSize, rowSize), dayName, dayNameStyle);
position.x += columnSize;
}
// Start outputing day buttons
var days = DatePickerUtilities.GetDateRangeForDisplay(VisibleDate.Value);
var selectedDateString = SelectedDate.ToDateString();
var returnValue = true;
foreach (var day in days)
{
if (day.DayOfWeek == DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek)
{
// Next row
position.x = startX;
position.y += rowSize;
}
var style = dayButtonStyle;
if (day.Month == VisibleDate.Value.Month)
{
var backColor = new Color(0, 0, 0, 0.5f);
if (day.ToDateString() == selectedDateString)
{
style = dayButtonStyle_CurrentDay;
backColor = Color.green;
}
EditorGUI.DrawRect(new Rect(position.x, position.y, rowSize, columnSize), backColor);
}
else
{
style = dayButtonStyle_OtherMonth;
}
if (GUI.Button(new Rect(position.x + 1, position.y + 1, columnSize - 2, rowSize - 2), day.Day.ToString(), style))
{
property.stringValue = day.ToDateString();
VisibleDate = day;
returnValue = false; // hide the datepicker
}
position.x += columnSize;
}
return returnValue;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f45010f93df526a4396c70b5f333fff4
timeCreated: 1467641153
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,57 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
namespace UI.Dates
{
[CustomEditor(typeof(DatePicker)), CanEditMultipleObjects]
public class DatePickerEditor : Editor
{
public void OnEnable()
{
}
public override void OnInspectorGUI()
{
var datePicker = ((DatePicker)target);
if (GUILayout.Button("Force Update"))
{
datePicker.InvalidateAllDayButtonTemplates();
var rows = datePicker.Ref_DayTable.Rows;
foreach (var row in rows)
{
DestroyImmediate(row.gameObject);
}
datePicker.UpdateDisplay();
}
if (GUILayout.Button("Invalidate Button Templates"))
{
datePicker.InvalidateAllDayButtonTemplates();
}
// create a copy of the configuration object
DatePickerConfig configBefore = JsonUtility.FromJson<DatePickerConfig>(datePicker.GetSerializedConfiguration());
if (DrawDefaultInspector())
{
var weekDayConfigChanged = (JsonUtility.ToJson(configBefore.WeekDays) != JsonUtility.ToJson(datePicker.Config.WeekDays));
if (weekDayConfigChanged) datePicker.ClearWeekDayHeaders();
var buttonConfigChanged = (JsonUtility.ToJson(configBefore.Days) != JsonUtility.ToJson(datePicker.Config.Days));
if (buttonConfigChanged)
{
datePicker.InvalidateAllDayButtonTemplates();
}
else
{
datePicker.UpdateDisplay();
}
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b9bd871c003086b4983a97c5708a6236
timeCreated: 1467640088
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,29 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
namespace UI.Dates
{
[CustomEditor(typeof(DatePicker_DateRange)), CanEditMultipleObjects]
public class DatePicker_DateRangeEditor : Editor
{
public void OnEnable()
{
}
public override void OnInspectorGUI()
{
var datePicker = ((DatePicker_DateRange)target);
if (GUILayout.Button("Force Update"))
{
datePicker.UpdateDisplay();
}
if (DrawDefaultInspector())
{
datePicker.UpdateDisplay();
DatePickerTimer.DelayedCall(0.005f, datePicker.UpdateDisplay, datePicker);
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a0b43a8b7088d0b40b0b4cb636e497c4
timeCreated: 1469621713
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,29 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
namespace UI.Dates
{
[CustomEditor(typeof(DatePicker_InputField)), CanEditMultipleObjects]
public class DatePicker_InputFieldEditor : Editor
{
public void OnEnable()
{
}
public override void OnInspectorGUI()
{
var datePickerInputField = ((DatePicker_InputField)target);
if (GUILayout.Button("Force Update"))
{
datePickerInputField.UpdateDisplay();
}
if (DrawDefaultInspector())
{
datePickerInputField.UpdateDisplay();
DatePickerTimer.DelayedCall(0.005f, datePickerInputField.UpdateDisplay, datePickerInputField);
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 27c939b3301ab1045aba8f2f5d983248
timeCreated: 1481978823
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,52 @@
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Globalization;
using System.Linq;
namespace UI.Dates
{
public class DatePickerMenuItems
{
[UnityEditor.MenuItem("GameObject/UI/DatePicker/DatePicker - Inline")]
public static void MenuItem_NewDatePickerInline()
{
var datePicker = DatePicker_Instantiation.InstantiatePrefab("DatePicker - Inline").GetComponent<DatePicker>();
DatePickerTimer.DelayedCall(0.1f, datePicker.UpdateDisplay, datePicker);
}
[UnityEditor.MenuItem("GameObject/UI/DatePicker/DatePicker - Popup")]
public static void MenuItem_NewDatePickerPopup()
{
var datePicker = DatePicker_Instantiation.InstantiatePrefab("DatePicker - Popup").GetComponent<DatePicker>();
DatePickerTimer.DelayedCall(0.1f, datePicker.UpdateDisplay, datePicker);
}
[UnityEditor.MenuItem("GameObject/UI/DatePicker/DatePicker - Date Range")]
public static void MenuItem_NewDatePickerDateRange()
{
var datePicker = DatePicker_Instantiation.InstantiatePrefab("DatePicker - Date Range").GetComponent<DatePicker_DateRange>();
DatePickerTimer.DelayedCall(0.1f, datePicker.UpdateDisplay, datePicker);
}
[UnityEditor.MenuItem("GameObject/UI/DatePicker/Shared Calendar/DatePicker - Popup (Shared Calendar)")]
public static void MenuItem_NewDatePickerPopupSharedCalendar()
{
var datePicker = DatePicker_Instantiation.InstantiatePrefab("DatePicker - Popup (Shared Calendar)").GetComponent<DatePicker_InputField>();
DatePickerTimer.DelayedCall(0.1f, datePicker.UpdateDisplay, datePicker);
}
[UnityEditor.MenuItem("GameObject/UI/DatePicker/Shared Calendar/Shared Calendar")]
public static void MenuItem_NewDatePickerSharedCalendar()
{
var datePicker = DatePicker_Instantiation.InstantiatePrefab("DatePicker - Shared Calendar").GetComponent<DatePicker>();
DatePickerTimer.DelayedCall(0.1f, datePicker.UpdateDisplay, datePicker);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: dc7224ca8954a534f94a201c196a7904
timeCreated: 1469626481
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7d35530f9e1be69428c2655585e3a499
folderAsset: yes
timeCreated: 1467636610
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 83cc9704932363f4fbad128377f479f5
timeCreated: 1468501028
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,66 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!850595691 &4890085278179872738
LightingSettings:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Example SceneSettings
serializedVersion: 6
m_GIWorkflowMode: 1
m_EnableBakedLightmaps: 0
m_EnableRealtimeLightmaps: 0
m_RealtimeEnvironmentLighting: 1
m_BounceScale: 1
m_AlbedoBoost: 1
m_IndirectOutputScale: 1
m_UsingShadowmask: 0
m_BakeBackend: 0
m_LightmapMaxSize: 1024
m_BakeResolution: 40
m_Padding: 2
m_LightmapCompression: 3
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 0
m_CompAOExponentDirect: 0
m_ExtractAO: 0
m_MixedBakeMode: 1
m_LightmapsBakeMode: 1
m_FilterMode: 1
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_RealtimeResolution: 2
m_ForceWhiteAlbedo: 0
m_ForceUpdates: 0
m_FinalGather: 0
m_FinalGatherRayCount: 1024
m_FinalGatherFiltering: 1
m_PVRCulling: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVREnvironmentSampleCount: 512
m_PVREnvironmentReferencePointCount: 2048
m_LightProbeSampleCountMultiplier: 4
m_PVRBounces: 2
m_PVRMinBounces: 2
m_PVREnvironmentImportanceSampling: 0
m_PVRFilteringMode: 0
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_PVRTiledBaking: 0
m_NumRaysToShootPerTexel: -1
m_RespectSceneVisibilityWhenBakingGI: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 96d74d4b823c48c4ca98fd6559402915
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 4890085278179872738
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,44 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace UI.Dates
{
[ExecuteInEditMode]
public class ExampleController : MonoBehaviour
{
public DatePicker InlineDatePicker;
public void ToggleNextPreviousMonthButtons(bool on)
{
InlineDatePicker.Config.Header.ShowNextAndPreviousMonthButtons = on;
InlineDatePicker.UpdateDisplay();
}
public void ToggleNextPreviousYearButtons(bool on)
{
InlineDatePicker.Config.Header.ShowNextAndPreviousYearButtons = on;
InlineDatePicker.UpdateDisplay();
}
public void ToggleWeekNumberDisplay(bool on)
{
InlineDatePicker.Config.WeekDays.ShowWeekNumbers = on;
InlineDatePicker.UpdateDisplay();
}
public void ToggleShowDatesInOtherMonths(bool on)
{
InlineDatePicker.Config.Misc.ShowDatesInOtherMonths = on;
InlineDatePicker.UpdateDisplay();
}
public void ToggleAllowMultipleDateSelection(bool on)
{
InlineDatePicker.DateSelectionMode = on ? DateSelectionMode.MultipleDates : DateSelectionMode.SingleDate;
InlineDatePicker.UpdateDisplay();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3f7d4df20dce726449a1fc0ad61ad760
timeCreated: 1487327309
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b3109c11f0d833e45911e5c790493d3d
timeCreated: 1481877028
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3d914505884c9d8449c709174771bbf3
folderAsset: yes
timeCreated: 1469713476
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: a3239e8fbc3a63046a151bd386173baf
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7992ff2513c6ddb488b663fd0bdadb7a
folderAsset: yes
timeCreated: 1487329961
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 62429c5426a10784d9272e2b60660e57
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: 9eec131dc638a154c9adc8db429f0ba7
timeCreated: 1487329983
licenseType: Store
TrueTypeFontImporter:
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Arial
fallbackFontReferences:
- {fileID: 12800000, guid: 2989c42092e4afc4580482e7f1265b72, type: 3}
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 239eaf08dcf333e49851e01446b32483
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 2989c42092e4afc4580482e7f1265b72
timeCreated: 1487329982
licenseType: Store
TrueTypeFontImporter:
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Arial
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b2730e4869054fe4fbfc81c74dee4032
folderAsset: yes
timeCreated: 1467636618
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e162c3b6a76b39b48b6c1398ac8b4638
folderAsset: yes
timeCreated: 1467636604
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 901680f7e0ec34947af2b72e976cc800
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4ae4fe27ab2bcad46bd1e3cd9df0a8e4
timeCreated: 1469623929
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 313699e4dcf0bc3419c37d93c4ddea1d
timeCreated: 1468494747
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 32bbf938bbac09749822216c1e4209d0
timeCreated: 1481985837
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 44b0dac864ce65b468c76ef4bac98d08
timeCreated: 1468503930
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a3568642f57c4a14b95169d0bdbe37ec
timeCreated: 1481985810
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 772e4998e52a3df4eb2ce9232d25165c
folderAsset: yes
timeCreated: 1467643064
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Some files were not shown because too many files have changed in this diff Show More