Skip to content

Commit

Permalink
修复:切换场景重复加载bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightre committed Feb 13, 2024
1 parent 5a04e88 commit 6fdb204
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sparkle-engine",
"private": false,
"version": "0.0.10",
"version": "0.1.11",
"type": "module",
"files": [
"dist/*",
Expand Down
8 changes: 6 additions & 2 deletions src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class SparkleEngine {
maxFPS: number
/**@ignore */
toDestory: Container[] = []
private loadedSences: Set<new () => Sence> = new Set()
constructor(options: ISparkleEngineOption) {


Expand Down Expand Up @@ -173,10 +174,13 @@ class SparkleEngine {
*/
instantiateSence<T extends Sence>(Sence: new () => T) {
return new Promise<Container>((resolve) => {

this.resource.startRegion()
const sence = new Sence()
sence.preload()

if (!this.loadedSences.has(Sence)) {
sence.preload()
this.loadedSences.add(Sence)
}
this.resource.endRegion(() => {
resolve(sence.create(this))
})
Expand Down

0 comments on commit 6fdb204

Please sign in to comment.