mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 10:46:17 +00:00
提交Unity 联机Pro
This commit is contained in:
@@ -0,0 +1,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
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b640e13d843caef4885814c6d13d8e3d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,63 @@
|
||||
using BestHTTP.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace BestHTTP.Examples.Helpers.Components
|
||||
{
|
||||
public class Cookies : 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 !BESTHTTP_DISABLE_COOKIES
|
||||
if (@event.Event == PluginEvents.SaveCookieLibrary)
|
||||
UpdateLabels();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void UpdateLabels()
|
||||
{
|
||||
#if !BESTHTTP_DISABLE_COOKIES
|
||||
var cookies = BestHTTP.Cookies.CookieJar.GetAll();
|
||||
var size = cookies.Sum(c => c.GuessSize());
|
||||
|
||||
this._count.text = cookies.Count.ToString("N0");
|
||||
this._size.text = size.ToString("N0");
|
||||
#else
|
||||
this._count.text = "0";
|
||||
this._size.text = "0";
|
||||
#endif
|
||||
}
|
||||
|
||||
public void OnClearButtonClicked()
|
||||
{
|
||||
#if !BESTHTTP_DISABLE_COOKIES
|
||||
BestHTTP.Cookies.CookieJar.Clear();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b9db2d0fa31b054b835fb38d688f211
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user