2024-12-14 18:27:59 +08:00

80 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/****************************************************************************
* Copyright (c) 2016 - 2023 liangxiegame UNDER MIT License
*
* https://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
using System;
using System.Collections;
using UnityEngine;
namespace QFramework
{
#if UNITY_EDITOR
[ClassAPI("07.ResKit", "ResKit", 0, "ResKit")]
[APIDescriptionCN("资源管理方案")]
[APIDescriptionEN("Resource Managements Solution")]
#endif
public class ResKit
{
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod]
public static void CheckAutoInit()
{
if (PlatformCheck.IsEditor && AssetBundlePathHelper.SimulationMode)
{
Init();
}
}
#endif
#if UNITY_EDITOR
[MethodAPI]
[APIDescriptionCN("初始化 ResKit")]
[APIDescriptionEN("initialise ResKit")]
[APIExampleCode(@"
ResKit.Init();
")]
#endif
public static void Init()
{
ResMgr.Init();
}
#if UNITY_EDITOR
[MethodAPI]
[APIDescriptionCN("异步初始化 ResKit如果是 WebGL 平台,只支持异步初始化")]
[APIDescriptionEN("initialise ResKit async")]
[APIExampleCode(@"
IEnumerator Start()
{
yield return ResKit.InitAsync();
}
// Or With ActionKit
ResKit.InitAsync().ToAction().Start(this,()=>
{
});
")]
#endif
public static IEnumerator InitAsync()
{
yield return ResMgr.InitAsync();
}
private static readonly Lazy<ResKit> mInstance = new Lazy<ResKit>(() => new ResKit().InternalInit());
internal static ResKit Get => mInstance.Value;
internal IOCContainer Container = new IOCContainer();
ResKit InternalInit()
{
Container.Register<IZipFileHelper>(new ZipFileHelper());
Container.Register<IBinarySerializer>(new BinarySerializer());
return this;
}
}
}