- Home /
Switch platform broke my scripts!
Help! I was tryng out unity pro and I switched one of my game's platforms to android but when I did my scripts broke and I got errors like
'transform' is not a member of 'Object'
I switched my platform back to normal and my scripts are still broke! My scripts were fine until I switched platform.
Any on ideas on how I could fix this?
Well.. that error you just exampled is quite easy to fix. Just make all of your Object-variables to gameObject-variables
No because that isn't the code, here is the part of the code that has that error: var new_ball = Instantiate(Balls[PlayerPrefs.GetString("ballcolour")], ball_spawn.position, ball_spawn.rotation); new_ball.transform.name = "Ball";
Hmm... Then I dont know. Have you restarted unity? silly question... You could try and reinstall unity?
I have restarted unity, i'll try re-installing it now.
Answer by TheCoolDog · Jan 23, 2013 at 11:47 AM
Fixed!!!
I found out that my platform was then set to Flashplayer :o I switched it back to web player and it works!! Thanks guys for your support. Oh and "as GameObject" did work but I don't need to do that now(and there were other errors).
Answer by golden pouria · Jan 21, 2013 at 08:19 PM
It is difficult to tell the reason of that error message without looking at your code. How did you defined that Game object? It could be because while you switched for the first time, the variable that is related to that Game object got re-defined to the switched platform style, and when you switched back your platform, it didn't re-re-defined those variables. Try to debug the lines of your code that is related to that game object or that specific transform.
Answer by Pix10 · Jan 21, 2013 at 08:19 PM
Instantiate(Balls[PlayerPrefs.GetString("ballcolour")], ball_spawn.position, ball_spawn.rotation); new_ball.transform.name = "Ball";
I take it you've created PlayerPrefs key "ballcolour"?
Answer by Loius · Jan 21, 2013 at 08:53 PM
Clearly, instantiate is returning an object. So cast it to a GameObject.
new_ball = Instantiate(...) as GameObject
Your answer
![](https://koobas.hobune.stream/wayback/20220613091337im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
I Switched platforms and I got this errors 1 Answer
My game does not run when I switch to Android Platform 1 Answer
switch platform error 0 Answers