From b07d91cf98e2c9eb913b9701de5c1854967974eb Mon Sep 17 00:00:00 2001 From: ChiaNing Date: Fri, 21 Feb 2020 10:22:12 +0800 Subject: [PATCH] widget alignMode add (#6187) --- cocos/ui/components/widget-component.ts | 12 ++++++------ cocos/ui/components/widget-manager.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos/ui/components/widget-component.ts b/cocos/ui/components/widget-component.ts index 51f17aef51..ce3ed57e0a 100644 --- a/cocos/ui/components/widget-component.ts +++ b/cocos/ui/components/widget-component.ts @@ -111,16 +111,16 @@ export enum AlignMode { * 开启后会在 onEnable 时所在的那一帧结束前对齐一次,然后立刻禁用该 Widget。 */ ONCE = 0, - // /** - // * @zh - // * 一开始会像 ONCE 一样对齐一次,之后每当窗口大小改变时还会重新对齐。 - // */ - // ON_WINDOW_RESIZE = 1, /** * @zh * 始终保持对齐。 */ ALWAYS = 1, + /** + * @zh + * 一开始会像 ONCE 一样对齐一次,之后每当窗口大小改变时还会重新对齐。 + */ + ON_WINDOW_RESIZE = 2, } ccenum(AlignMode); @@ -670,7 +670,7 @@ export class WidgetComponent extends Component { @property private _originalHeight = 0; @property - private _alignMode = AlignMode.ALWAYS; + private _alignMode = AlignMode.ON_WINDOW_RESIZE; /** * @zh diff --git a/cocos/ui/components/widget-manager.ts b/cocos/ui/components/widget-manager.ts index 4435284b40..2b7de0bf79 100644 --- a/cocos/ui/components/widget-manager.ts +++ b/cocos/ui/components/widget-manager.ts @@ -387,8 +387,8 @@ export const widgetManager = cc._widgetManager = { refreshWidgetOnResized (node: Node) { if (Node.isNode(node)){ const widget = node.getComponent(WidgetComponent); - if (widget && widget.alignFlags === AlignMode.ALWAYS) { - return; + if (widget && widget.alignMode === AlignMode.ON_WINDOW_RESIZE) { + widget.enabled = true; } }