Welcome,
Guest
. Please
login
or
register
.
May 16, 2026, 04:45:09 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Atlas returning NullReference Exception
« previous
next »
Print
Pages: [
1
]
Author
Topic: Atlas returning NullReference Exception (Read 3963 times)
kwelts
Guest
Atlas returning NullReference Exception
«
on:
July 25, 2012, 01:32:43 PM »
I've made 2 atlases in the same manner and one works perfectly but the other keeps on getting NullReference.
Here's the code:
using
UnityEngine
;
using
System.Collections
;
public
class
UIButtonTexture
:
MonoBehaviour
{
public
UIAtlas ReferenceAtlas
;
public
GameObject ReplacementAtlas
;
public
string
HomePanelTopBG
;
public
string
TopNavBar
;
bool
AtlasSwitch
;
/*public UIButtonTexture(bool AtlasSwitch) {
this.AtlasSwitch = AtlasSwitch;
} */
public
enum
Trigger
{
OnClick,
}
public
Trigger trigger
=
Trigger
.
OnClick
;
void
Start
(
)
{
AtlasSwitch
=
false
;
}
public
void
OnClick
(
)
{
Debug
.
Log
(
"---> Inside OnClick"
)
;
if
(
AtlasSwitch
==
false
)
{
AtlasSwitch
=
true
;
Debug
.
Log
(
"---> AtlasSwitch = "
+
AtlasSwitch
)
;
UpdateAtlas
(
)
;
}
else
{
AtlasSwitch
=
false
;
Debug
.
Log
(
"---> AtlasSwitch = "
+
AtlasSwitch
)
;
UpdateAtlas
(
)
;
}
}
public
void
UpdateAtlas
(
)
{
if
(
AtlasSwitch
==
true
)
{
Debug
.
Log
(
"---> Inside UpdateAtlas [true side]"
)
;
ReplacementAtlas
=
Resources
.
Load
(
"HomePanelTopBG"
)
as
GameObject
;
Debug
.
Log
(
"---> Setting texture GO to 'Clicked'"
)
;
}
else
{
Debug
.
Log
(
"---> Inside UpdateAtlas [false side]"
)
;
ReplacementAtlas
=
Resources
.
Load
(
"TopBlackBar"
)
as
GameObject
;
Debug
.
Log
(
"---> Setting texture GO to 'Default'"
)
;
}
Debug
.
Log
(
"---> Replacing Atlas. ReferenceAtlas = "
+
ReferenceAtlas
+
" ReplacementAtlas = "
+
ReplacementAtlas
)
;
ReferenceAtlas
.
replacement
=
ReplacementAtlas
.
GetComponent
<
UIAtlas
>
(
)
;
Debug
.
Log
(
"Atlas Replaced"
)
;
}
// end UpdateAtlas()
}
Error occurs when it won't actually load the resource "TopBlackBar", and halts at " ReferenceAtlas.replacement = ReplacementAtlas.GetComponent<UIAtlas>();" with the error.
Both atlases are located in the same folder and are named properly. Any idea what is happening that i'm unaware of?
Thanks for your time.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Atlas returning NullReference Exception
«
Reply #1 on:
July 25, 2012, 07:42:15 PM »
All I can suggest is look closely at what's different between them and to make sure you spelled the name correctly.
Logged
kwelts
Guest
Re: Atlas returning NullReference Exception
«
Reply #2 on:
July 25, 2012, 09:41:30 PM »
ok thanks for the response (at least i have something to focus on).
Logged
kwelts
Guest
Re: Atlas returning NullReference Exception
«
Reply #3 on:
July 26, 2012, 10:16:33 AM »
code is the same. it changes once but not back. i've gone through everything i can so im just going to post every little relevant part of my project and you can see if I missed something crucial.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Atlas returning NullReference Exception
«
Reply #4 on:
July 26, 2012, 04:25:33 PM »
I don't see anything wrong.
Logged
kwelts
Guest
Re: Atlas returning NullReference Exception
«
Reply #5 on:
July 26, 2012, 08:41:46 PM »
oh noes!
Logged
Godgib
Guest
Re: Atlas returning NullReference Exception
«
Reply #6 on:
August 09, 2012, 11:42:15 AM »
Ran into this problem yesterday. Try renaming the actual atlas prefab to something that doesn't match the material and texture. By default, NGUI creates all 3 with the same name, but this can confuse the Resource Load.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Atlas returning NullReference Exception