This commit is contained in:
JoneLau
2019-04-25 10:11:28 +08:00
committed by jerrywwl
parent 2f7f6eb143
commit d500061856
2 changed files with 7 additions and 12 deletions
+5 -10
View File
@@ -28,11 +28,11 @@ import { CameraComponent } from '../../../3d/framework/camera-component';
import { Component } from '../../../components/component';
import { ccclass, executeInEditMode, executionOrder, menu, property, requireComponent } from '../../../core/data/class-decorator';
import { Size, Vec3 } from '../../../core/value-types';
import { vec3 } from '../../../core/vmath';
import { GFXClearFlag } from '../../../gfx/define';
import { Camera } from '../../../renderer/scene/camera';
import { UITransformComponent } from './ui-transfrom-component';
const _tempPos = new Vec3();
const _worldPos = new Vec3();
/**
@@ -223,10 +223,7 @@ export class CanvasComponent extends Component {
if (CC_EDITOR) {
// nodeSize = designSize = cc.engine.getDesignResolutionSize();
nodeSize = designSize = this._designResolution;
_tempPos.x = designSize.width * 0.5;
_tempPos.y = designSize.height * 0.5;
_tempPos.z = 0;
vec3.set(_worldPos, designSize.width * 0.5, designSize.height * 0.5, 1);
}
else {
const canvasSize = cc.visibleRect;
@@ -241,13 +238,11 @@ export class CanvasComponent extends Component {
offsetY = (designSize.height - canvasSize.height) * 0.5;
}
_tempPos.x = canvasSize.width * 0.5 + offsetX;
_tempPos.y = canvasSize.height * 0.5 + offsetY;
_tempPos.z = 0;
vec3.set(_worldPos, canvasSize.width * 0.5 + offsetX, canvasSize.height * 0.5 + offsetY, 1);
}
if (this._pos.equals(_tempPos)) {
this.node.setPosition(_tempPos);
if (!this._pos.equals(_worldPos)){
this.node.setPosition(_worldPos);
}
if (this.node.width !== nodeSize.width) {
+2 -2
View File
@@ -558,7 +558,7 @@ export const widgetManager = cc._widgetManager = {
l += zero.x;
l *= one.x;
temp = pos.x - myAP.x * widgetNode.width! * widgetNodeScale.x - l;
if (widget.isAbsoluteLeft) {
if (!widget.isAbsoluteLeft) {
temp /= matchSize.width;
}
@@ -570,7 +570,7 @@ export const widgetManager = cc._widgetManager = {
let r = (1 - parentAP.x) * matchSize.width;
r += zero.x;
temp = (r *= one.x) - (pos.x + (1 - myAP.x) * widgetNode.width! * widgetNodeScale.x);
if (widget.isAbsoluteRight) {
if (!widget.isAbsoluteRight) {
temp /= matchSize.width;
}