import { _decorator } from "cc"; const {ccclass, property} = _decorator; @ccclass export default class GBaseData { //加载保存的数据 loadfromSave(saveobj: any) { for (let key in this) { //这里注意saveobj[key]==0的问题,不使用if(saveobj[key]) if (saveobj[key]!=null) { let obj = this[key]; if (obj instanceof GBaseData) { obj.loadfromSave(saveobj[key]) } else{ this[key] = saveobj[key]; } } } } }