Jelajahi Sumber

修改UI场景加载方式

mojunshou 8 bulan lalu
induk
melakukan
ad5c7ef3f2

+ 30 - 0
assets/resources/config.json

@@ -17,6 +17,36 @@
         "gameVersion": "1.0.5",
         "gameCompanyName": "广州市游戏科技有限公司"
     },
+    "gui": [
+        {
+            "name": "LayerGame",
+            "type": "Node"
+        },
+        {
+            "name": "LayerUI",
+            "type": "UI"
+        },
+        {
+            "name": "LayerPopUp",
+            "type": "PopUp"
+        },
+        {
+            "name": "LayerDialog",
+            "type": "Dialog"
+        },
+        {
+            "name": "LayerSystem",
+            "type": "Dialog"
+        },
+        {
+            "name": "LayerNotify",
+            "type": "Notify"
+        },
+        {
+            "name": "LayerGuide",
+            "type": "Node"
+        }
+    ],
     "language": {
         "default": "zh",
         "type": [

+ 25 - 1
assets/script/game/common/setting/SettingViewComp.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-20 15:40:20
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-03-25 15:18:55
+ * @LastEditTime: 2025-03-31 16:44:21
  * @Description:设置界面 
  */
 import { _decorator } from "cc";
@@ -12,6 +12,9 @@ import { CCComp } from "db://oops-framework/module/common/CCComp";
 import { UIID } from "../config/GameUIConfig";
 import { CCVMParentComp } from "db://oops-framework/module/common/CCVMParentComp";
 import { Toggle } from "cc";
+import { Account } from "../../account/Account";
+import { ImageAsset, Texture2D, SpriteFrame, Sprite } from "cc";
+import { IRemoteOptions, resLoader } from "db://oops-framework/core/common/loader/ResLoader";
 
 const { ccclass, property } = _decorator;
 
@@ -29,6 +32,7 @@ export class SettingViewComp extends CCVMParentComp {
     start() {
         // const entity = this.ent as ecs.Entity;         // ecs.Entity 可转为当前模块的具体实体对象
         this.setButton();
+        this.updateHead();
     }
 
     /** 视图对象通过 ecs.Entity.remove(SettingViewComp) 删除组件是触发组件处理自定义释放逻辑 */
@@ -89,6 +93,26 @@ export class SettingViewComp extends CCVMParentComp {
         oops.audio.switchEffect = this.data.effect_state;
     }
 
+    //更新头像
+    private updateHead() {
+        let account = ecs.getEntity<Account>(Account);
+        let sprite = this.node.getChildByPath("Bg/btn_head/sp_head")!.uiSprite;
+        // let url = account.AccountModel.head;
+        let url = "http://www.kuaipng.com/Uploads/pic/w/2020/07-16/89010/water_89010_698_698_.png"
+        this.data.nickName = account.AccountModel.AccountName;
+        this.data.uid = account.AccountModel.uid;
+        var opt: IRemoteOptions = { ext: ".png" };
+        var onComplete = (err: Error | null, data: ImageAsset) => {
+            const texture = new Texture2D();
+            texture.image = data;
+
+            const spriteFrame = new SpriteFrame();
+            spriteFrame.texture = texture;
+            sprite.spriteFrame = spriteFrame;
+        }
+        resLoader.loadRemote<ImageAsset>(url, opt, onComplete);
+    }
+