Skip to content
StaleButton

UI / StaleButton

StaleButton Class

Text button

Usage example: create a script named "NewScript", place it in the object sub level of the object manager, open the script, enter the following code to save it, run the game, and a button will be displayed on the screen.

ts
@Component
export default class NewScript extends Script {

    protected onStart(): void {
        if(SystemUtil.isClient()){
            if(SystemUtil.isClient()){
                let mainui = UIService.create(UI_Main);
                UIService.showUI(mainui);
                UIService.canvas.addChild(mainui.button);
            }
        }
    }
}
class UI_Main extends UIScript {

    button: StaleButton = undefined;

    public onAwake() {
        let size = WindowUtil.getViewportSize();

        this.button = StaleButton.newObject();
        this.button.transform = new UITransform(size.x/2,size.y/2,size.x / 14, size.y / 20);

        this.button.size = new Vector2(size.x / 14, size.y / 20);
        this.button.text = "StaleButton";
        this.button.fontSize = 18;
        this.button.transitionEnable = true;
        InputUtil.bindButton(Keys.X, this.button);
        this.button.setPressedImageColorDecimal(200, 200, 200, 255);
        this.button.onClicked.add(() => {
            // When the button is pressed, execute the following logic
            console.log("The \"StaleButton\" button was pressed ~");
        });
    }
}
@Component
export default class NewScript extends Script {

    protected onStart(): void {
        if(SystemUtil.isClient()){
            if(SystemUtil.isClient()){
                let mainui = UIService.create(UI_Main);
                UIService.showUI(mainui);
                UIService.canvas.addChild(mainui.button);
            }
        }
    }
}
class UI_Main extends UIScript {

    button: StaleButton = undefined;

    public onAwake() {
        let size = WindowUtil.getViewportSize();

        this.button = StaleButton.newObject();
        this.button.transform = new UITransform(size.x/2,size.y/2,size.x / 14, size.y / 20);

        this.button.size = new Vector2(size.x / 14, size.y / 20);
        this.button.text = "StaleButton";
        this.button.fontSize = 18;
        this.button.transitionEnable = true;
        InputUtil.bindButton(Keys.X, this.button);
        this.button.setPressedImageColorDecimal(200, 200, 200, 255);
        this.button.onClicked.add(() => {
            // When the button is pressed, execute the following logic
            console.log("The \"StaleButton\" button was pressed ~");
        });
    }
}

Hierarchy

Table of contents

Properties

click

Properties

onCustomPropertyChange: Readonly<MulticastDelegate<(path: string, value: unknown, oldValue: unknown) => void>> other
Monitor custom attribute synchronization events

Accessors

clickMethod(inClickMethod: ButtonClickMethod): void other
Set click mode
contentColor(): LinearColor other
Set font content color
disableImageColor(): Readonly<LinearColor> other
Get disable image Color
disableImageDrawType(): Readonly<SlateBrushDrawType> other
Get disable image Drawing Type
disableImageGuid(): string other
Get disabled image ID
disableImageInfo(): ImageInfo other
Get ImageInfo of button Disable image
disableImageMargin(): Readonly<Margin> other
Get disable image Margins
disableImageSize(): Readonly<Vector2> other
Get disable image Size
focusable(): boolean other
Get whether to obtain input focus
fontColor(): LinearColor other
Get font color
fontLetterSpace(): number other
Get font spacing
fontSize(): number other
Get font size
glyph(): UIFontGlyph other
Get font and glyph shapes
normalImageColor(): Readonly<LinearColor> other
Get normal image colors
normalImageDrawType(): Readonly<SlateBrushDrawType> other
Obtain ordinary image drawing types
normalImageGuid(): string other
Obtain a regular image ID
normalImageInfo(): ImageInfo other
Retrieve the ImageInfo of the button's normal image
normalImageMargin(): Readonly<Margin> other
Get normal image margins
normalImageSize(): Readonly<Vector2> other
Get image size
onClicked(): MulticastDelegate<() => void> other
Click Event
onHovered(): MulticastDelegate<() => void> other
Suspension event
onPressed(): MulticastDelegate<() => void> other
Press Event
onReleased(): MulticastDelegate<() => void> other
Release event
onUnhovered(): MulticastDelegate<() => void> other
Unsettled event
outlineColor(): LinearColor other
Get font outline color
outlineSize(): number other
Get font outline width
pressMethod(inPressMethod: ButtonPressMethod): void other
Set press mode
pressedImagColor(): Readonly<LinearColor> other
Get the color of pressed image
pressedImageDrawType(): Readonly<SlateBrushDrawType> other
Obtain the type of pressed image drawing
pressedImageGuid(): string other
Get press image ID
pressedImageInfo(): ImageInfo other
Get the ImageInfo of the button Pressed image
pressedImageMargin(): Readonly<Margin> other
Get press image margins
pressedImageSize(): Readonly<Vector2> other
Get the size of pressing image
shadowColor(): LinearColor other
Get font shadow color
shadowOffset(): Vector2 other
Get font shadow offset
strikethroughEnable(): boolean other
Get whether to enable font strikethrough
text(): string <Badge type="tip" text="other" />
Get button text
textAlign(): TextJustify other
Get font align
textVerticalAlign(): TextVerticalJustify other
Get the vertical alignment of the font
touchMethod(inTouchMethod: ButtonTouchMethod): void other
Set Touch mode
transitionEnable(): boolean other
Get whether the button enable the excessive mode, and whether press has effect
underlineEnable(): boolean other
Return whether to enable font underline
click

Accessors

alignPosition(): Readonly<Vector2> other
Get the align position of the widget. When the align method is right align, bottom align, and center align, the value of alignPosition is different from that of position;
autoSizeHorizontalEnable(): boolean other
Get whether to automatically set the size horizontally
autoSizeVerticalEnable(): boolean other
Get whether to set the size automatically vertical
cachedGeometry(): Geometry other
Get the previous Get TickSpaceGeometry
constraints(): Readonly<UIConstraintAnchors> other
Get the layout of the control
desiredSize(): Vector2 other
Obtain expected size
enable(): boolean other
Is it available
guid(): string other
Get the widget GUID
isHovered(): boolean other
Is it hovered
mouseCursor(): MouseCursor other
Get the cursor type on the widget
name(): string other
Get Name
paintSpaceGeometry(): Geometry other
Get the last geometric information used to render the Widget
parent(): Widget other
Get parent node
pivot(): Vector2 other
Get the position of the widget anchor. This property determine the relative position of the widget graph and the anchor; At (0,0), the anchor point is located in the upper left corner of the control; (0.5,0.5), the anchor is at the center of the widget
position(): Readonly<Vector2> other
Get the position of the control
renderOpacity(): number other
Obtain rendering transparency
renderScale(): Vector2 other
Get rendering scaling
renderShear(): Vector2 other
Obtain rendering misalignment deformation
renderTransformAngle(): number other
Obtain the rendering angle
renderTransformPivot(): Vector2 other
Get Render anchor
size(): Vector2 other
Get size
tickSpaceGeometry(): Geometry other
Retrieve the last geometric information used to drive Widget Tick
transform(): Readonly<UITransform> other
Obtain the size and position of the control
visibility(): SlateVisibility other
Get visibility
visible(): boolean other
Is it visible
zOrder(): number other
Get Zorder

Methods

addKey(key: Keys): void other
The same button can only control one UI control at a time, and the latest bound UI control will overwrite the previous binding; The binding added in the script cannot override the UI controls bound to the same key in the editor's key binding menu. However, when two UI controls are bound to the same key separately through code and menu, the priority of using code binding is higher
getKeys(): Keys[] other
Get all the keyboard keys bound to the current UI widget, including the editor key binding menu and the code bound keys
isPressed(): boolean other
Whether press
removeKey(key: Keys): void other
This operation only unbinds dynamically bound keys and cannot unbind keys bound in the editor's key binding menu
setButtonDisableByFile(absPath: string, bRefreshCache?: boolean): void other
Set unavailable image
setButtonNormalByFile(absPath: string, bRefreshCache?: boolean): void other
Set normal image
setButtonPressedByFile(absPath: string, bRefreshCache?: boolean): void other
Set press image
setDisableImageColorByHex(inHexString: string): void other
Set unavailable color to specify Hex's color text, set color # 05050505
setDisableImageColorDecimal(R: number, G: number, B: number, A: number): void other
Set unavailable colors
setFontColorByHex(inHexString: string): void other
Set font color, specify the color of Hex text Set Color # 05050505
setFontColorDecimal(R: number, G: number, B: number, A: number): void other
Set font color
setNormalImageColorByHex(inHexString: string): void other
Set normal color, specify Hex's color text, set color # 05050505
setNormalImageColorDecimal(R: number, G: number, B: number, A: number): void other
Set normal color
setPressedImageColorByHex(inHexString: string): void other
Set press Color to specify the color of Hex text Set Color # 05050505
setPressedImageColorDecimal(R: number, G: number, B: number, A: number): void other
Set press color
newObject(parent?: Canvas, inName?: string): StaleButton other
Create StaleButton control
click

Methods

addChild(child: Widget): void other
Add child nodes
clone(position: Vector2, Parent?: any): Widget other
Clone the UI widget and its child nodes to the specified parent widget position (default to its parent node)
destroyObject(): void other
Remove and destroy immediately. Cannot be used again
equal(that: Widget): boolean other
Determine if it is the same object
findChildByPath(inPath: string): Widget other
Find nodes by relative path
getChildAt(index: number): Widget other
What is the position node to obtain
getChildByName<T: extends Widget<T>>(name: string): T: extends Widget<T> other
Search for nodes by name
getChildrenCount(): number other
Obtain the number of child nodes
getCustomProperties(): string[] other
Get all customize property
getCustomProperty<T: extends CustomPropertyType>(propertyName: string): T: extends CustomPropertyType other
Get customize property
getCustomPropertyChangeDelegate(property): Readonly<MulticastDelegate<(path: string, value: unknown, oldValue: unknown) => void>> other
Event proxy triggered when a given object property is modified
invalidateLayoutAndVolatility(): void other
Immediately trigger re rendering and layout calculation
removeAllChildren(): void other
Clearing all child nodes will destroy the UI and render it unusable
removeChild(child: Widget): void other
Removing a node will destroy the UI and make it unusable
removeChildAt(index: number): void other
Removing the third node will destroy the UI and render it unusable
removeObject(): void other
Immediately remove and add to the root node for reuse
serialize(): string other
Serialize UI widget
setCustomProperty(propertyName: string, value: undefined CustomPropertyType): void other
Set custom attributes
deserialize(Data: string, Parent?: Widget): Widget other
Deserialize UI

Properties

Accessors


clickMethod

set clickMethod(inClickMethod): void other

Set click mode

Parameters

inClickMethod ButtonClickMethodUsage: click mode

Click on mode selection


contentColor

get contentColor(): LinearColor other

set contentColor(inContentColor): void other

Set font content color

Returns

LinearColorFont content color, TypeLinearColor type, data range 0~1

Set font content color

Parameters

inContentColor LinearColorUsage: Color, TypeLinearColor type, data range 0~1

disableImageColor

get disableImageColor(): Readonly<LinearColor> other

set disableImageColor(inColor): void other

Get disable image Color

Returns

Readonly<LinearColor>Disable image color, Type.LinearColor type, data range 0~1

Set disable image Color

Parameters

inColor LinearColorUsage: Color, TypeLinearColor type, data range 0~1

disableImageDrawType

get disableImageDrawType(): Readonly<SlateBrushDrawType> other

set disableImageDrawType(inDrawTYpe): void other

Get disable image Drawing Type

Returns

Readonly<SlateBrushDrawType>Disable image Draw Type

Set to disable image drawing types

Parameters

inDrawTYpe SlateBrushDrawTypeUsage: Type

disableImageGuid

get disableImageGuid(): string other

set disableImageGuid(inGUID): void other

Get disabled image ID

Returns

stringDisable Image ID

Set unavailable image ID

Parameters

inGUID stringUsage: image id

disableImageInfo

get disableImageInfo(): ImageInfo other

Get ImageInfo of button Disable image

Returns

ImageInfoReturn ImageInfo object

disableImageMargin

get disableImageMargin(): Readonly<Margin> other

set disableImageMargin(inMargin): void other

Get disable image Margins

Returns

Readonly<Margin>Disable image Margins

Set disable image Margins

Parameters

inMargin MarginUsage: disable image margins

disableImageSize

get disableImageSize(): Readonly<Vector2> other

set disableImageSize(inSize): void other

Get disable image Size

Returns

Readonly<Vector2>Disable image size

Set disable image size

Parameters

inSize Vector2Usage: Size

focusable

get focusable(): boolean other

set focusable(inFocus): void other

Get whether to obtain input focus

Returns

booleanWhether to obtain input focus

Set whether to obtain input focus

Parameters

inFocus booleanUsage: Get input focus or not

fontColor

get fontColor(): LinearColor other

set fontColor(inColor): void other

Get font color

Returns

LinearColorFont color, TypeLinearColor type, data range 0~1

Set font color

Parameters

inColor LinearColorUsage: Font color, TypeLinearColor type, data range 0~1

fontLetterSpace

get fontLetterSpace(): number other

set fontLetterSpace(fontLetterSpace): void other

Get font spacing

Returns

numberFont spacing

Set font spacing

Parameters

fontLetterSpace numberUsage: spacing

fontSize

get fontSize(): number other

set fontSize(FontSize): void other

Get font size

Returns

numberfont size

Set font size

Parameters

FontSize numberUsage: Size

glyph

get glyph(): UIFontGlyph other

set glyph(inGlyph): void other

Get font and glyph shapes

Returns

UIFontGlyphFont Shape

Set font and glyph shape

Parameters

inGlyph UIFontGlyphUsage: Type of font and glyph

normalImageColor

get normalImageColor(): Readonly<LinearColor> other

set normalImageColor(inNormalColor): void other

Get normal image colors

Returns

Readonly<LinearColor>Normal image color, Type.LinearColor type, data range 0~1

Set regular image colors

Parameters

inNormalColor LinearColorUsage: Color, TypeLinearColor type, data range 0~1

normalImageDrawType

get normalImageDrawType(): Readonly<SlateBrushDrawType> other

set normalImageDrawType(inDrawType): void other

Obtain ordinary image drawing types

Returns

Readonly<SlateBrushDrawType>Ordinary image drawing type

Set normal image drawing type

Parameters

inDrawType SlateBrushDrawTypeUsage: Type

normalImageGuid

get normalImageGuid(): string other

set normalImageGuid(inGUID): void other

Obtain a regular image ID

Returns

stringNormal image ID

Set normal image ID

Parameters

inGUID stringUsage: image id

normalImageInfo

get normalImageInfo(): ImageInfo other

Retrieve the ImageInfo of the button's normal image

Returns

ImageInfoReturn ImageInfo object

normalImageMargin

get normalImageMargin(): Readonly<Margin> other

set normalImageMargin(inMargin): void other

Get normal image margins

Returns

Readonly<Margin>Normal image margin

Set normal image margins

Parameters

inMargin MarginUsage: Normal image margins

normalImageSize

get normalImageSize(): Readonly<Vector2> other

set normalImageSize(inSize): void other

Get image size

Returns

Readonly<Vector2>Normal image size

Set image size

Parameters

inSize Vector2Usage: Size

onClicked

get onClicked(): MulticastDelegate<() => void> other

Click Event

Returns

MulticastDelegate<() => void>Return the proxy of the event

onHovered

get onHovered(): MulticastDelegate<() => void> other

Suspension event

Returns

MulticastDelegate<() => void>Return the proxy of the event

onPressed

get onPressed(): MulticastDelegate<() => void> other

Press Event

Returns

MulticastDelegate<() => void>Return the proxy of the event

onReleased

get onReleased(): MulticastDelegate<() => void> other

Release event

Returns

MulticastDelegate<() => void>Return the proxy of the event

onUnhovered

get onUnhovered(): MulticastDelegate<() => void> other

Unsettled event

Returns

MulticastDelegate<() => void>Return the proxy of the event

outlineColor

get outlineColor(): LinearColor other

set outlineColor(inOutlineColor): void other

Get font outline color

Returns

LinearColorFont stroke color, TypeLinearColor type, data range 0~1

Set font outline color

Parameters

inOutlineColor LinearColorUsage: Stroke color, TypeLinearColor type, data range 0~1

outlineSize

get outlineSize(): number other

set outlineSize(inOutlineSize): void other

Get font outline width

Returns

numberFont stroke width

Set font outline width

Parameters

inOutlineSize numberUsage: Set size

pressMethod

set pressMethod(inPressMethod): void other

Set press mode

Parameters

inPressMethod ButtonPressMethodUsage: press mode

pressedImagColor

get pressedImagColor(): Readonly<LinearColor> other

set pressedImagColor(inColor): void other

Get the color of pressed image

Returns

Readonly<LinearColor>Press image color, Type.LinearColor type, data range 0~1

Set the color of the pressed image

Parameters

inColor LinearColorUsage: Color, TypeLinearColor type, data range 0~1

pressedImageDrawType

get pressedImageDrawType(): Readonly<SlateBrushDrawType> other

set pressedImageDrawType(inDrawType): void other

Obtain the type of pressed image drawing

Returns

Readonly<SlateBrushDrawType>Press image drawing type

Set press image drawing type

Parameters

inDrawType SlateBrushDrawTypeUsage: Type

pressedImageGuid

get pressedImageGuid(): string other

set pressedImageGuid(inGUID): void other

Get press image ID

Returns

stringPress image ID

Set press image ID

Parameters

inGUID stringUsage: image id

pressedImageInfo

get pressedImageInfo(): ImageInfo other

Get the ImageInfo of the button Pressed image

Returns

ImageInfoReturn ImageInfo object

pressedImageMargin

get pressedImageMargin(): Readonly<Margin> other

set pressedImageMargin(inMargin): void other

Get press image margins

Returns

Readonly<Margin>Press the image margin

Set press image margin

Parameters

inMargin MarginUsage: press the image margin

pressedImageSize

get pressedImageSize(): Readonly<Vector2> other

set pressedImageSize(inSize): void other

Get the size of pressing image

Returns

Readonly<Vector2>Press image size

Set the size of pressing image

Parameters

inSize Vector2Usage: Size

shadowColor

get shadowColor(): LinearColor other

set shadowColor(inShadowColor): void other

Get font shadow color

Returns

LinearColorFont shadow color, TypeLinearColor type, data range 0~1

Set font shadow color

Parameters

inShadowColor LinearColorUsage: Input color, TypeLinearColor type, data range 0~1

shadowOffset

get shadowOffset(): Vector2 other

set shadowOffset(inOffset): void other

Get font shadow offset

Returns

Vector2Font Shadow offset

Set font shadow offset

Parameters

inOffset Vector2Usage: shadow offset

strikethroughEnable

get strikethroughEnable(): boolean other

set strikethroughEnable(inEnableStrikethrough): void other

Get whether to enable font strikethrough

Returns

booleanDo you want to enable font strikethrough

Set whether to enable font strikethrough

Parameters

inEnableStrikethrough booleanUsage: Is it enabled

text

get text(): string other

set text(InString): void other

Get button text

Returns

stringReturn Text

Set button text

Parameters

InString stringUsage: Text

new text


textAlign

get textAlign(): TextJustify other

set textAlign(InTextJustify): void other

Get font align

Returns

TextJustifyFont align

Set font align

Parameters

InTextJustify TextJustifyUsage: enumeration of align

textVerticalAlign

get textVerticalAlign(): TextVerticalJustify other

set textVerticalAlign(inTextVerticalJustify): void other

Get the vertical alignment of the font

Returns

TextVerticalJustifyFont vertical align

Set font vertical alignment method

Parameters

inTextVerticalJustify TextVerticalJustifyUsage: Alignment method

touchMethod

set touchMethod(inTouchMethod): void other

Set Touch mode

Parameters

inTouchMethod ButtonTouchMethodUsage: Touch mode selection

transitionEnable

get transitionEnable(): boolean other

set transitionEnable(inBoolean): void other

Get whether the button enable the excessive mode, and whether press has effect

Returns

booleanWhether the button enable the transition mode

Should different pressing schemes be applied

Parameters

inBoolean booleanUsage: Whether to apply a different press scheme

underlineEnable

get underlineEnable(): boolean other

set underlineEnable(inEnableUnderline): void other

Return whether to enable font underline

Returns

booleanGet whether to enable font underline

Set whether to enable font underline

Parameters

inEnableUnderline booleanUsage: Set whether to enable underline

Methods


addKey

addKey(key): void other

The same button can only control one UI control at a time, and the latest bound UI control will overwrite the previous binding; The binding added in the script cannot override the UI controls bound to the same key in the editor's key binding menu. However, when two UI controls are bound to the same key separately through code and menu, the priority of using code binding is higher

Parameters

key KeysUsage: button

getKeys

getKeys(): Keys[] other

Get all the keyboard keys bound to the current UI widget, including the editor key binding menu and the code bound keys

Returns

Keys[]Returns the key bound to the current widget, which may be empty

isPressed

isPressed(): boolean other

Whether press

Returns

booleanIs the return button pressed

removeKey

removeKey(key): void other

This operation only unbinds dynamically bound keys and cannot unbind keys bound in the editor's key binding menu

Parameters

key KeysUsage: button

setButtonDisableByFile

setButtonDisableByFile(absPath, bRefreshCache?): void other

Set unavailable image

Parameters

absPath stringUsage: Image file path
range: Path length
bRefreshCache? booleanUsage: If set to true, the cache will be recreated and refreshed. If set to false, the cache will be used.
default: true

Precautions

It is recommended to set bRefreshCache=false to improve performance


setButtonNormalByFile

setButtonNormalByFile(absPath, bRefreshCache?): void other

Set normal image

Parameters

absPath stringImage file path range: path length
bRefreshCache? booleanUsage: If it is true, the cache will be re created and refreshed; if it is false, the cache will be used< br> default: true

Precautions

It is recommended to set bRefreshCache=false to improve performance


setButtonPressedByFile

setButtonPressedByFile(absPath, bRefreshCache?): void other

Set press image

Parameters

absPath stringUsage: image file path range: path length
bRefreshCache? booleanUsage: If set to true, the cache will be recreated and refreshed. If set to false, the cache will be used.
default: true

Precautions

It is recommended to set bRefreshCache=false to improve performance


setDisableImageColorByHex

setDisableImageColorByHex(inHexString): void other

Set unavailable color to specify Hex's color text, set color # 05050505

Parameters

inHexString stringUsage: Color string range: A string type that conforms to the characteristics of Hex

setDisableImageColorDecimal

setDisableImageColorDecimal(R, G, B, A): void other

Set unavailable colors

Parameters

R numberUsage: Color R value< Range: [0, 255] type: integer
G numberUsage: Color G value< Range: [0, 255] type: integer
B numberUsage: Color B value< Range: [0, 255] type: integer
A numberUsage: Color transparency< Range: [0, 255] type: integer

setFontColorByHex

setFontColorByHex(inHexString): void other

Set font color, specify the color of Hex text Set Color # 05050505

Parameters

inHexString stringUsage: Hex color string range: string type conforming to Hex characteristics

setFontColorDecimal

setFontColorDecimal(R, G, B, A): void other

Set font color

Parameters

R numberUsage: Font R value< Range: [0, 255] type: integer
G numberUsage: Font G value< Range: [0, 255] type: integer
B numberUsage: Font B value< Range: [0, 255] type: integer
A numberUsage: Font transparency< Range: [0, 255] type: integer

setNormalImageColorByHex

setNormalImageColorByHex(inHexString): void other

Set normal color, specify Hex's color text, set color # 05050505

Parameters

inHexString stringUsage: Color string range: A string type that conforms to the characteristics of Hex

setNormalImageColorDecimal

setNormalImageColorDecimal(R, G, B, A): void other

Set normal color

Parameters

R numberUsage: Color R value< Range: [0, 255] type: integer
G numberUsage: Color G value< Range: [0, 255] type: integer
B numberUsage: Color B value< Range: [0, 255] type: integer
A numberUsage: Color transparency< Range: [0, 255] type: integer

setPressedImageColorByHex

setPressedImageColorByHex(inHexString): void other

Set press Color to specify the color of Hex text Set Color # 05050505

Parameters

inHexString stringUsage: Color string range: A string type that conforms to the characteristics of Hex

setPressedImageColorDecimal

setPressedImageColorDecimal(R, G, B, A): void other

Set press color

Parameters

R numberUsage: Color R value< Range: [0, 255] type: integer
G numberUsage: Color G value< Range: [0, 255] type: integer
B numberUsage: Color B value< Range: [0, 255] type: integer
A numberUsage: Color transparency< Range: [0, 255] type: integer

newObject

Static newObject(parent?, inName?): StaleButton other

Create StaleButton control

Parameters

parent? CanvasUsage: create the parent Canvas object of the widget default: null
inName? stringUsage: name of the create widget default: null range: set a reasonable name

Returns

StaleButtonReturn the created object

When the parent and inName are the same as an existing object, the old object will be destroyed