Welcome,
Guest
. Please
login
or
register
.
April 28, 2026, 12:43:41 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Dynamically changing sliced sprite
« previous
next »
Print
Pages: [
1
]
Author
Topic: Dynamically changing sliced sprite (Read 2861 times)
jrhee
Newbie
Thank You
-Given: 0
-Receive: 2
Posts: 13
Dynamically changing sliced sprite
«
on:
September 04, 2014, 05:24:55 AM »
Hi,
What is the correct way to change the sliced sprite for a button in code while retaining its original dimensions? I tried something like below which seems to work at first, but when I hover out of the sprite and back into it, the size resets.
void
PushIn
(
UIButton button
)
{
UIWidget widget
=
button
.
GetComponent
<
UIWidget
>
(
)
;
int
width
=
widget
.
width
;
int
height
=
widget
.
height
;
button
.
normalSprite
=
"UI.glass.card.pressed"
;
widget
.
width
=
width
;
widget
.
height
=
height
;
// widget.MarkAsChanged();
// widget.SetDirty();
}
Thanks-
Logged
jrhee
Newbie
Thank You
-Given: 0
-Receive: 2
Posts: 13
Re: Dynamically changing sliced sprite
«
Reply #1 on:
September 04, 2014, 05:35:49 AM »
Disregard, disabling pixel snap on the button did the trick.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Dynamically changing sliced sprite