Welcome,
Guest
. Please
login
or
register
.
June 11, 2026, 04:46:04 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Sprite Alpha
« previous
next »
Print
Pages: [
1
]
Author
Topic: Sprite Alpha (Read 13799 times)
Noi14
Jr. Member
Thank You
-Given: 10
-Receive: 0
Posts: 57
Sprite Alpha
«
on:
March 04, 2014, 11:52:08 AM »
Hi,
I can't change alpha of a sprite when I instanziate a object.
GameObject user
=
NGUITools
.
AddChild
(
list, user_selection
)
;
GameObject removeUser
=
user
.
transform
.
Find
(
"RemoveUser"
)
.
gameObject
;
if
(
TNManager
.
isHosting
)
{
Debug
.
Log
(
"Is host"
)
;
removeUser
.
GetComponent
<
BoxCollider
>
(
)
.
enabled
=
true
;
// Work
removeUser
.
GetComponent
<
UISprite
>
(
)
.
alpha
=
1
;
// Doesn't work
}
Collider is correctly activated but alpha of sprite doesn't have variations. Why?
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Sprite Alpha
«
Reply #1 on:
March 05, 2014, 08:10:24 AM »
"doesn't have variations"?
If you have a button script on that "removeUser" object, then it will likely overwrite your sprite color when it starts up. Also, why set alpha to 1? Shouldn't it already be 1?
Logged
r.pedra
Full Member
Thank You
-Given: 7
-Receive: 20
Posts: 131
Re: Sprite Alpha
«
Reply #2 on:
March 05, 2014, 08:26:33 AM »
I think his button is disable by default and he is "activating" it when the user is the host. So I think the button have an alpha of 0 at the start.
Logged
Noi14
Jr. Member
Thank You
-Given: 10
-Receive: 0
Posts: 57
Re: Sprite Alpha
«
Reply #3 on:
March 05, 2014, 08:43:27 AM »
I've setted prefab with alpha at 0, after I have used tned and if client is Host, alpha will set 1 and will be activated collider
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Sprite Alpha
«
Reply #4 on:
March 05, 2014, 09:04:33 AM »
Make sure you have the latest NGUI, there was an issue with going form alpha of 0 in some cases in the past.
I'd also advise leaving the prefab in "enabled" state by default, and disabling the collider / hiding the sprite on instantiation instead.
Logged
Noi14
Jr. Member
Thank You
-Given: 10
-Receive: 0
Posts: 57
Re: Sprite Alpha
«
Reply #5 on:
March 05, 2014, 09:36:10 AM »
I'm using the latest version, but if I enter the code in the update at "press a button" instead of "creation" It works:
void
Update
(
)
{
if
(
Input
.
GetKeyDown
(
KeyCode
.
L
)
)
{
...
code
...
removeUser
.
GetComponent
<
BoxCollider
>
(
)
.
enabled
=
false
;
removeUser
.
GetComponent
<
UISprite
>
(
)
.
alpha
=
0
;
}
}
I also try to reverse the functioning, that is disable the buttons putting it enabled by default, but have the same problem
Logged
Nicki
Global Moderator
Hero Member
Thank You
-Given: 33
-Receive: 141
Posts: 1,768
Re: Sprite Alpha
«
Reply #6 on:
March 05, 2014, 01:57:18 PM »
instead of setting alpha to 0,1 it's easier to just disable the UISprite component.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Sprite Alpha