@galacean/engine-ui 2.0.0-alpha.14 → 2.0.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -1220,10 +1220,7 @@
1220
1220
  dstTransition.disabled = srcTransition.disabled;
1221
1221
  var transitionTarget = srcTransition.target;
1222
1222
  if (transitionTarget) {
1223
- var paths = UIInteractive._targetTempPath;
1224
- // @ts-ignore
1225
- var success = engine.Entity._getEntityHierarchyPath(srcRoot, transitionTarget.entity, paths);
1226
- dstTransition.target = success ? engine.Entity._getEntityByHierarchyPath(targetRoot, paths).getComponent(transitionTarget.constructor) : transitionTarget;
1223
+ dstTransition.target = engine.CloneUtils.remapComponent(srcRoot, targetRoot, transitionTarget);
1227
1224
  }
1228
1225
  target.addTransition(dstTransition);
1229
1226
  }
@@ -1338,7 +1335,6 @@
1338
1335
  ]);
1339
1336
  return UIInteractive;
1340
1337
  }(engine.Script);
1341
- UIInteractive._targetTempPath = new Array();
1342
1338
  __decorate([
1343
1339
  engine.ignoreClone
1344
1340
  ], UIInteractive.prototype, "_rootCanvas", void 0);
@@ -1558,11 +1554,7 @@
1558
1554
  target.renderMode = this._renderMode;
1559
1555
  var camera = this._camera;
1560
1556
  if (camera) {
1561
- var paths = UICanvas._targetTempPath;
1562
- // @ts-ignore
1563
- var success = engine.Entity._getEntityHierarchyPath(srcRoot, camera.entity, paths);
1564
- // @ts-ignore
1565
- target.camera = success ? engine.Entity._getEntityByHierarchyPath(targetRoot, paths).getComponent(engine.Camera) : camera;
1557
+ target.camera = engine.CloneUtils.remapComponent(srcRoot, targetRoot, camera);
1566
1558
  }
1567
1559
  };
1568
1560
  _proto._getRenderers = function _getRenderers() {
@@ -1960,7 +1952,6 @@
1960
1952
  return UICanvas;
1961
1953
  }(engine.Component);
1962
1954
  /** @internal */ exports.UICanvas._hierarchyCounter = 1;
1963
- exports.UICanvas._targetTempPath = [];
1964
1955
  exports.UICanvas._tempGroupAbleList = [];
1965
1956
  exports.UICanvas._tempVec3 = new engine.Vector3();
1966
1957
  exports.UICanvas._tempMat = new engine.Matrix();
@@ -2066,45 +2057,41 @@
2066
2057
  _inherits(Button, UIInteractive);
2067
2058
  function Button() {
2068
2059
  var _this;
2069
- _this = UIInteractive.apply(this, arguments) || this, _this._listeners = new engine.SafeLoopArray();
2060
+ _this = UIInteractive.apply(this, arguments) || this, /** Signal emitted when the button is clicked. */ _this.onClick = new engine.Signal();
2070
2061
  return _this;
2071
2062
  }
2072
2063
  var _proto = Button.prototype;
2064
+ _proto.onPointerClick = function onPointerClick(event) {
2065
+ if (!this._getGlobalInteractive()) return;
2066
+ this.onClick.invoke(event);
2067
+ };
2068
+ _proto.onDestroy = function onDestroy() {
2069
+ UIInteractive.prototype.onDestroy.call(this);
2070
+ this.onClick.removeAll();
2071
+ };
2072
+ // @ts-ignore
2073
+ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
2074
+ UIInteractive.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
2075
+ // @ts-ignore
2076
+ this.onClick._cloneTo(target.onClick, srcRoot, targetRoot);
2077
+ };
2073
2078
  /**
2074
2079
  * Add a listening function for click.
2075
- * @param listener - The listening function
2080
+ * @deprecated Use `onClick.on(listener, context)` instead.
2076
2081
  */ _proto.addClicked = function addClicked(listener) {
2077
- this._listeners.push({
2078
- fn: listener
2079
- });
2082
+ this.onClick.on(listener);
2080
2083
  };
2081
2084
  /**
2082
2085
  * Remove a listening function of click.
2083
- * @param listener - The listening function
2086
+ * @deprecated Use `onClick.off(listener, context)` instead.
2084
2087
  */ _proto.removeClicked = function removeClicked(listener) {
2085
- this._listeners.findAndRemove(function(value) {
2086
- return value.fn === listener ? value.destroyed = true : false;
2087
- });
2088
- };
2089
- _proto.onPointerClick = function onPointerClick(event) {
2090
- if (!this._getGlobalInteractive()) return;
2091
- var listeners = this._listeners.getLoopArray();
2092
- for(var i = 0, n = listeners.length; i < n; i++){
2093
- var listener = listeners[i];
2094
- !listener.destroyed && listener.fn(event);
2095
- }
2096
- };
2097
- _proto.onDestroy = function onDestroy() {
2098
- UIInteractive.prototype.onDestroy.call(this);
2099
- this._listeners.findAndRemove(function(value) {
2100
- return value.destroyed = true;
2101
- });
2088
+ this.onClick.off(listener);
2102
2089
  };
2103
2090
  return Button;
2104
2091
  }(UIInteractive);
2105
2092
  __decorate([
2106
2093
  engine.ignoreClone
2107
- ], Button.prototype, "_listeners", void 0);
2094
+ ], Button.prototype, "onClick", void 0);
2108
2095
 
2109
2096
  /**
2110
2097
  * UI element that renders an image.