- Home /
build for iphone - "function is not a member of object"
Hi - I have an application which works properly when built in the unity player, but when I do a development build for iphone, I get a number of errors, all stemming from a reference I am making to a script which is attached to another game object. The error, specifically, says:
'turnOnLighter' is not a member of 'Object'.
This is my code:
in the LighterControl script:
var flameObjRef : GameObject; (tied to a game object called Candle, which contains the flame script)
var flameScriptRef = flameObjRef.GetComponent("FlameControl"); //references the FlameControl script
flameScriptRef.turnOnLighter();
in the FlameControl script:
function turnOnLighter(){
//Do stuff
}
Any idea what's going on?
Answer by Wolfram · Jun 13, 2012 at 04:04 PM
Replace the second line with:
var flameScriptRef : FlameControl = flameObjRef.GetComponent("FlameControl"); //references the FlameControl script
UnityScript does not know about the particular return type of GetComponent(). Not sure why it works in the Editor, though.
Hm, we would need to see more of your script - in the code excerpt you posted there is no uppercase "FlameScriptRef".
Concerning your second comment: that's okay, Unity automatically "creates" classes for your scripts, which are named the same way as the script is. I think. Not really working with UnityScript...
Your answer
Follow this Question
Related Questions
iTween - calling functions on oncomplete doesn't work if the function is declared as a variable 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
the most RESOURCE EFFICIENT way of referencing 1 Answer
Static and Coroutines help 2 Answers
What is the expected behaviour of Dynamic Batching? 2 Answers