Welcome,
Guest
. Please
login
or
register
.
December 12, 2024, 06:23:27 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UITexture.mainTexture causes problem on Android
« previous
next »
Print
Pages: [
1
]
Author
Topic: UITexture.mainTexture causes problem on Android (Read 2918 times)
Oinobareion
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 14
UITexture.mainTexture causes problem on Android
«
on:
August 08, 2013, 09:27:17 AM »
Hi,
I am dynamically creating a GameObject and add a UITexture component to it. Like this:
GameObject go
=
new
GameObject
(
"picture"
+
index
)
;
go
.
AddComponent
(
"UITexture"
)
;
Now I want to assign a texture to it like this:
go
.
GetComponent
<
UITexture
>
(
)
.
mainTexture
=
tex
;
where tex is some Texture2D. This works fine in the editor but as soon as I test it on an Android device, it gets stuck at this point. Any ideas why?
Thanks for any help!
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UITexture.mainTexture causes problem on Android
«
Reply #1 on:
August 08, 2013, 09:29:56 AM »
"gets stuck at some point" is not very descriptive. Investigate. Where is the texture coming from? Are you downloading it? Setting the mainTexture merely sets a reference, so it won't cause it to get stuck.
Logged
Oinobareion
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 14
Re: UITexture.mainTexture causes problem on Android
«
Reply #2 on:
August 08, 2013, 09:34:52 AM »
I load the texture from my Ressources folder:
Object
[
]
photoTextures
=
Resources
.
LoadAll
(
"Photos"
,
typeof
(
Texture2D
)
)
;
and get the textures like this:
foreach
(
Texture2D tex
in
photoTextures
)
{
GameObject go
=
new
GameObject
(
"picture"
+
someIndex
)
;
go
.
AddComponent
(
"UITexture"
)
;
// this is where i try to assign the texture from the Resources folder. Everything after this line does not get executed.
go
.
GetComponent
<
UITexture
>
(
)
.
mainTexture
=
tex
;
...
}
«
Last Edit: August 08, 2013, 10:04:59 AM by Oinobareion
»
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UITexture.mainTexture causes problem on Android
«
Reply #3 on:
August 08, 2013, 10:09:27 AM »
You have the source code for it. Open up UITexture, line 145 is the UITexture.mainTexture property. Line 151 is the setter. You have the power to put Debug.Logs in there to figure out what the issue is.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UITexture.mainTexture causes problem on Android