- Home /
Android version not working as intended
Hello!
See, I have a few problems I'm trying to figure out. I'm completely new to android development through unity, but I'm hoping I can get some answers here.
I'm getting a lot of nullreferenceexceptions on my android build that don't occur in unity editor, nor in normal windows build. (I fixed one of the problems by assigning a variable through the inspector instead of doing GameObject.FindGameObjectWithTag().)
for example I'm doing a transform.getchild() that doesn't work on the android build that works perfectly in the editor.
I'm really confused, I've been programming just like I would for a normal windows build and when I tried it out on android so many things are not working at all. Should I be programming differently for android (not including optimization, input and other stuff that is generally different for other platforms)? I'm more talking about what I can do and what I can't do code-wise.
Sorry for the novel, I'd be super thankful for any advice! :)
Are you using the most recent Unity version? I think this can be, sometimes, bugs from your currently installed Unity version.
Answer by Raimi · Jun 12, 2017 at 11:18 PM
void Update()
{
transform.Getchild(0).transform.position += transform.Getchild(1).transform.positon;
}
if you use Unity's built in functions rather than C# native functions you should be fine. Main issue is probs iPhone
Give some code examples and we can see if we can help you out
plant = transform.GetChild(1);
this is what makes a nullreferenceexception, even tho I can see the plant is spawned and everything works in the editor.
What Type is plant? GameObject, transform, vector2?
Gameobject plant = transform.GetChild(1).gameobject;
Transform plant = transform.Getchild(1).transform;
Transform.
plant.localScale = Vector3.Lerp(InitialScale, FinalScale, percent);
This is the line of code that actually givesme the error. I'm assu$$anonymous$$g the nullreferenceexception is referring to the plant.
EDIT: Oh, I thought GetChild(0) returned the same as GetChild(0).transform in this case.
Have you actually assigned something to plant? like in inspector, or GameObject.Find()?
Answer by Pedro_Brito · Jun 12, 2017 at 11:42 PM
Are you sure you've wet up everything correctly and you've updated Unity to the most recent version?
I've already experienced some issues while building for Android, quick were fixed by updating Unity.
Yes, I actually reinstalled whole unity yesterday, so it should be up to date. I'm currently on 5.6.1f1.