From cdf6b51a63e857389ecfeac36b3f5efda3fbc2e4 Mon Sep 17 00:00:00 2001 From: dgflash Date: Sun, 21 Aug 2022 10:20:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=89=B9=E6=95=88=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=A8=A1=E5=9D=97=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../libs/animator-effect/EffectSingleCase.ts | 9 +++--- assets/libs/model-view/VMBase.ts | 14 +++++----- assets/libs/model-view/VMLabel.ts | 28 +++++++++---------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/assets/libs/animator-effect/EffectSingleCase.ts b/assets/libs/animator-effect/EffectSingleCase.ts index 81f3680..97c73fa 100644 --- a/assets/libs/animator-effect/EffectSingleCase.ts +++ b/assets/libs/animator-effect/EffectSingleCase.ts @@ -2,7 +2,7 @@ * @Author: dgflash * @Date: 2021-10-12 14:00:43 * @LastEditors: dgflash - * @LastEditTime: 2022-08-19 17:51:37 + * @LastEditTime: 2022-08-20 14:57:42 */ import { Component, Node, NodePool, Prefab, Vec3 } from 'cc'; @@ -36,7 +36,7 @@ export class EffectSingleCase { private effects: Map = new Map(); /** 加载资源并现实特效 */ - loadAndShow(name: string, parent: Node, params?: IEffectParams): Promise { + loadAndShow(name: string, parent?: Node, params?: IEffectParams): Promise { return new Promise((resolve, reject) => { var np = this.effects.get(name); if (np == undefined) { @@ -63,7 +63,7 @@ export class EffectSingleCase { * @param parent 父节点 * @param pos 位置 */ - show(name: string, parent: Node, params?: IEffectParams): Node { + show(name: string, parent?: Node, params?: IEffectParams): Node { var np = this.effects.get(name); if (np == null) { np = new NodePool(); @@ -81,10 +81,11 @@ export class EffectSingleCase { else { node = np.get()!; } - node.parent = parent; if (params && params.pos) node.position = params.pos; + if (parent) node.parent = parent; + return node; } diff --git a/assets/libs/model-view/VMBase.ts b/assets/libs/model-view/VMBase.ts index 8a4cd68..2b1f7a3 100644 --- a/assets/libs/model-view/VMBase.ts +++ b/assets/libs/model-view/VMBase.ts @@ -16,21 +16,21 @@ const { ccclass, property } = _decorator; */ @ccclass export default class VMBase extends Component { + /**VM管理 */ + VM = VM; + /** watch 单路径 */ - public watchPath: string = ''; + watchPath: string = ''; + + /** 是否启用模板多路径模式 */ + templateMode: boolean = false; /** watch 多路径 */ protected watchPathArr: string[] = []; - /** 是否启用模板多路径模式 */ - public templateMode: boolean = false; - /** 储存模板多路径的值 */ protected templateValueArr: any[] = []; - /**VM管理 */ - public VM = VM; - /** * 如果需要重写onLoad 方法,请根据顺序调用 super.onLoad(),执行默认方法 */ diff --git a/assets/libs/model-view/VMLabel.ts b/assets/libs/model-view/VMLabel.ts index 353ce0a..fe43b58 100644 --- a/assets/libs/model-view/VMLabel.ts +++ b/assets/libs/model-view/VMLabel.ts @@ -25,38 +25,36 @@ export default class VMLabel extends VMBase { @property({ tooltip: '是否启用模板代码,只能在运行时之前设置,\n将会动态解析模板语法 {{0}},并且自动设置监听的路径' }) - public templateMode: boolean = false; + templateMode: boolean = false; + + @property({ + visible() { + return this.templateMode === false; + } + }) + watchPath: string = ''; @property({ readonly: true }) private labelType: string = LABEL_TYPE.CC_LABEL; - @property({ - visible: function () { - // @ts-ignore - return this.templateMode === false; - } - }) - watchPath: string = ""; - - // 按照匹配参数顺序保存的 path 数组 (固定) @property({ type: [CCString], - visible: function () { - // @ts-ignore + visible() { return this.templateMode === true; } }) + /** 按照匹配参数顺序保存的 path 数组 (固定) */ protected watchPathArr: string[] = []; - // 按照路径参数顺序保存的 值的数组(固定) + /** 按照路径参数顺序保存的 值的数组(固定)*/ protected templateValueArr: any[] = []; - // 保存着字符模板格式的数组 (只会影响显示参数) + /** 保存着字符模板格式的数组 (只会影响显示参数) */ private templateFormatArr: string[] = []; - // 源字符串 + /** 源字符串 */ private originText: string | null = null; onRestore() {