修复oops.gui.toast组个不使用多语言配置时,不显示自定义文本问题

This commit is contained in:
dgflash
2023-08-03 21:03:36 +08:00
parent 33294dddf7
commit 0047c5433e
2 changed files with 10 additions and 10 deletions

View File

@@ -1,8 +1,8 @@
import { Asset, AssetManager, Constructor, __private, assetManager, error, js, resources } from "cc";
type ProgressCallback = __private._cocos_asset_asset_manager_shared__ProgressCallback;
type CompleteCallback<T = any> = __private._cocos_asset_asset_manager_shared__CompleteCallbackWithData;
type IRemoteOptions = __private._cocos_asset_asset_manager_shared__IRemoteOptions;
type ProgressCallback = __private._cocos_asset_asset_manager_deprecated__LoadProgressCallback;
type CompleteCallback<T = any> = any; // (error: Error | null, asset: T) => void; (error: Error | null, asset: T[], urls: string[]) => void;
type IRemoteOptions = { [k: string]: any; ext?: string; } | null;
type AssetType<T = Asset> = Constructor<T>;
interface ILoadResArgs<T extends Asset> {
@@ -249,7 +249,7 @@ oops.res.loadDir("game", onProgressCallback, onCompleteCallback);
* @param type 资源类型
* @param bundleName 远程资源包名
*/
get<T extends Asset>(path: string, type?: __private._cocos_asset_asset_manager_shared__AssetType<T> | null, bundleName?: string): T | null {
get<T extends Asset>(path: string, type?: __private._types_globals__Constructor<T> | null, bundleName?: string): T | null {
if (bundleName == null) bundleName = this.defaultBundleName;
var bundle: AssetManager.Bundle = assetManager.getBundle(bundleName)!;

View File

@@ -13,10 +13,10 @@ const { ccclass, property } = _decorator;
@ccclass('Notify')
export class Notify extends Component {
@property(Label)
private lab_content: Label | null = null;
private lab_content: Label = null!;
@property(Animation)
private animation: Animation | null = null;
private animation: Animation = null!;
onLoad() {
if (this.animation)
@@ -33,14 +33,14 @@ export class Notify extends Component {
* @param useI18n 设置为 true 时,使用多语言功能 msg 参数为多语言 key
*/
toast(msg: string, useI18n: boolean) {
let label = this.lab_content?.getComponent(LanguageLabel)!;
let label = this.lab_content.getComponent(LanguageLabel)!;
if (useI18n) {
label.enabled = true;
label.dataID = msg;
}
else {
if (label)
label.dataID = "";
this.lab_content!.string = msg;
label.enabled = false;
this.lab_content.string = msg;
}
}
}