mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-05-18 12:15:39 +08:00
TimerManager.stop方法添加重置计时状态功能
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Asset, AssetManager, assetManager, Constructor, error, js, Prefab, resources, __private } from "cc";
|
||||
import { Asset, AssetManager, Constructor, Prefab, __private, assetManager, error, js, resources } from "cc";
|
||||
|
||||
type ProgressCallback = __private._cocos_core_asset_manager_shared__ProgressCallback;
|
||||
type CompleteCallback<T = any> = __private._cocos_core_asset_manager_shared__CompleteCallbackWithData;
|
||||
@@ -177,13 +177,31 @@ oops.res.loadDir("game", onProgressCallback, onCompleteCallback);
|
||||
*/
|
||||
releaseDir(path: string, bundleName: string = "resources") {
|
||||
var bundle: AssetManager.Bundle | null = assetManager.getBundle(bundleName);
|
||||
var infos = bundle?.getDirWithPath(path);
|
||||
infos?.map((info) => {
|
||||
this.releasePrefabtDepsRecursively(info.uuid);
|
||||
});
|
||||
if (bundle) {
|
||||
var infos = bundle.getDirWithPath(path);
|
||||
if (infos) {
|
||||
infos.map((info) => {
|
||||
this.releasePrefabtDepsRecursively(info.uuid);
|
||||
});
|
||||
}
|
||||
|
||||
if (path == "" && bundleName != "resources" && bundle) {
|
||||
assetManager.removeBundle(bundle);
|
||||
if (path == "" && bundleName != "resources") {
|
||||
assetManager.removeBundle(bundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 释放预制依赖资源 */
|
||||
private releasePrefabtDepsRecursively(uuid: string) {
|
||||
var asset = assetManager.assets.get(uuid)!;
|
||||
assetManager.releaseAsset(asset);
|
||||
|
||||
if (asset instanceof Prefab) {
|
||||
var uuids: string[] = assetManager.dependUtil.getDepsRecursively(uuid)!;
|
||||
uuids.forEach(uuid => {
|
||||
var asset = assetManager.assets.get(uuid)!;
|
||||
asset.decRef();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,18 +288,4 @@ oops.res.loadDir("game", onProgressCallback, onCompleteCallback);
|
||||
this.loadByBundleAndArgs(resources, args);
|
||||
}
|
||||
}
|
||||
|
||||
/** 释放预制依赖资源 */
|
||||
private releasePrefabtDepsRecursively(uuid: string) {
|
||||
var asset = assetManager.assets.get(uuid)!;
|
||||
assetManager.releaseAsset(asset);
|
||||
|
||||
if (asset instanceof Prefab) {
|
||||
var uuids: string[] = assetManager.dependUtil.getDepsRecursively(uuid)!;
|
||||
uuids.forEach(uuid => {
|
||||
var asset = assetManager.assets.get(uuid)!;
|
||||
asset.decRef();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,6 +307,7 @@ export class Timer {
|
||||
}
|
||||
|
||||
stop() {
|
||||
this._elapsedTime = 0;
|
||||
this.step = -1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user