-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
import { Component, _decorator } from "cc"; | ||
import { replicated } from "../../sync/SyncUtil"; | ||
import { CCString } from "cc"; | ||
|
||
const { ccclass, property } = _decorator; | ||
|
||
@ccclass | ||
export default class SyncCube extends Component { | ||
// 定义一个字符串类型的同步属性 | ||
@replicated() | ||
@property({type : CCString}) | ||
public cubeName: string = "cube"; | ||
|
||
onLoad() { | ||
// 随机生成一个cubeName,后面接的随机数为0-1000的整数 | ||
this.cubeName = "cube" + Math.floor(Math.random() * 1000); | ||
console.log("cubeName: " + this.cubeName); | ||
} | ||
// update (dt) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters