Welcome,
Guest
. Please
login
or
register
.
December 03, 2024, 09:56:18 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Change UILabel Material in Real-time
« previous
next »
Print
Pages: [
1
]
Author
Topic: Change UILabel Material in Real-time (Read 4302 times)
sandolkakos
Newbie
Thank You
-Given: 16
-Receive: 1
Posts: 17
Change UILabel Material in Real-time
«
on:
September 06, 2014, 12:22:22 AM »
Hello ArenMook,
I'm trying to change the Material of my UILabel in real-time. The Material is changed but the effect does not happen.
The effect happens when I set the Material Manually via Inspector, so I can't understand my mistake
I'm setting it like this:
this
.
GetComponent
<
UILabel
>
(
)
.
material
=
newMaterial
;
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Change UILabel Material in Real-time
«
Reply #1 on:
September 06, 2014, 02:07:58 AM »
Is it a dynamic font label? Bitmap fonts always use the material of their atlas.
Logged
sandolkakos
Newbie
Thank You
-Given: 16
-Receive: 1
Posts: 17
Re: Change UILabel Material in Real-time
«
Reply #2 on:
September 06, 2014, 09:28:37 PM »
yes, I'm using dynamic font in the UILabel.
In the Attachment Files I've uploaded a file with the video showing the error.
Thank you for the attention, ArenMook.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Change UILabel Material in Real-time
«
Reply #3 on:
September 07, 2014, 08:45:26 AM »
I am not able to view that video. May I suggest uploading to youtube instead?
Logged
sandolkakos
Newbie
Thank You
-Given: 16
-Receive: 1
Posts: 17
Re: Change UILabel Material in Real-time
«
Reply #4 on:
September 07, 2014, 06:49:00 PM »
Here you are
http://youtu.be/2CHTupWka8E
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Change UILabel Material in Real-time
«
Reply #5 on:
September 08, 2014, 08:43:27 PM »
I don't recommend using OnGUI with NGUI.
Regardless, this seems to be a bug. You can fix it by changing UILabel's material property to this:
public
override
Material material
{
get
{
if
(
mMaterial
!=
null
)
return
mMaterial
;
if
(
mFont
!=
null
)
return
mFont
.
material
;
if
(
mTrueTypeFont
!=
null
)
return
mTrueTypeFont
.
material
;
return
null
;
}
set
{
if
(
mMaterial
!=
value
)
{
RemoveFromPanel
(
)
;
mMaterial
=
value
;
MarkAsChanged
(
)
;
}
}
}
Logged
sandolkakos
Newbie
Thank You
-Given: 16
-Receive: 1
Posts: 17
Re: Change UILabel Material in Real-time
«
Reply #6 on:
September 09, 2014, 01:39:32 PM »
Thank you, ArenMook. It is now fixed.
About the OnGUI, I just used it to show you how the problem was happening
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Change UILabel Material in Real-time