forked from Benedicht/BestHTTP_Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCache.cs
More file actions
57 lines (49 loc) · 1.35 KB
/
Copy pathCache.cs
File metadata and controls
57 lines (49 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using BestHTTP.Core;
using UnityEngine;
using UnityEngine.UI;
namespace BestHTTP.Examples.Helpers.Components
{
public class Cache : MonoBehaviour
{
#pragma warning disable 0649, 0169
[SerializeField]
private Text _count;
[SerializeField]
private Text _size;
[SerializeField]
private Button _clear;
#pragma warning restore
private void Start()
{
PluginEventHelper.OnEvent += OnPluginEvent;
UpdateLabels();
}
private void OnDestroy()
{
PluginEventHelper.OnEvent -= OnPluginEvent;
}
private void OnPluginEvent(PluginEventInfo @event)
{
if (@event.Event == PluginEvents.SaveCacheLibrary)
UpdateLabels();
}
private void UpdateLabels()
{
#if !BESTHTTP_DISABLE_CACHING
this._count.text = BestHTTP.Caching.HTTPCacheService.GetCacheEntityCount().ToString("N0");
this._size.text = BestHTTP.Caching.HTTPCacheService.GetCacheSize().ToString("N0");
#else
this._count.text = "0";
this._size.text = "0";
#endif
}
public void OnClearButtonClicked()
{
#if !BESTHTTP_DISABLE_CACHING
BestHTTP.Caching.HTTPCacheService.BeginClear();
#endif
}
}
}