Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
wyb10a10 committed Aug 2, 2023
1 parent 5ad2f9d commit 1167c8b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions assets/Scene/example_sync_scene.scene
Original file line number Diff line number Diff line change
Expand Up @@ -2847,10 +2847,10 @@
"__id__": 20
},
"createButton": {
"__id__": 83
"__id__": 41
},
"syncButton": {
"__id__": 41
"__id__": 83
},
"_id": "bdqlCMX7lPTpyCohOiL0+0"
},
Expand Down
2 changes: 2 additions & 0 deletions assets/Script/example/sync/SyncUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ export class SyncUI extends Component {
}

private onCreateButtonClick() {
console.log("create button click");
this.serverReplicator?.createRandomPrefab();
}

private async onSyncButtonClick() {
console.log("sync button click");
const syncData = this.serverReplicator?.generateSyncData();
if (syncData) {
await this.clientReplicator?.syncInstances(syncData);
Expand Down
3 changes: 1 addition & 2 deletions assets/Script/sync/ServerReplicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class ServerReplicator extends Component {
const nodeSync = instance.getComponent(NodeSync);
if (nodeSync) {
nodeSync.setInstanceId(this.instanceCounter++);
nodeSync.setPrefabPath(`path/to/prefab/${prefab.name}`);
this.node.addChild(instance);
console.log(`create instance ${nodeSync.instanceId}`);
}
}

Expand All @@ -38,6 +38,5 @@ export class ServerReplicator extends Component {
if (nodeSync.instanceId === -1) {
nodeSync.setInstanceId(this.instanceCounter++);
}
nodeSync.setPrefabPath(`path/to/prefab/${nodeSync.node.name}`);
}
}

0 comments on commit 1167c8b

Please sign in to comment.