/**
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
using Live2D.Cubism.Framework.Tasking;
using UnityEngine;
namespace Live2D.Cubism.Samples.AsyncBenchmark
{
///
/// Shows how to enable the from script.
///
public sealed class AsyncToggler : MonoBehaviour
{
///
/// Controls async task handling.
///
public bool EnableAsync = true;
///
/// Last state.
///
private bool LastEnableSync { get; set; }
#region Unity Event Handling
///
/// Called by Unity. Enables/Disables async task handler.
///
private void Update()
{
if (EnableAsync == LastEnableSync)
{
return;
}
if (EnableAsync)
{
CubismBuiltinAsyncTaskHandler.Activate();
}
else
{
CubismBuiltinAsyncTaskHandler.Deactivate();
}
LastEnableSync = EnableAsync;
}
///
/// Called by Unity. Disables async task handler.
///
private void OnDestroy()
{
EnableAsync = false;
Update();
}
#endregion
}
}