- Home /
Webplayer: Why can't we call private member function from a constructor?
I have
class Command {
private var name : String;
function Command(input : String) {
Validate(input);
}
private function Validate(input : String) {
if(input.Contains(" ")) {
var trimmed : String = Regex.Relpace("\\s+", " ");
} else {
this.name = input;
}
}
}
It runs well in Unity Editor but complains in the WebBuilds when I attach the debugger. If I don't attach debugger, it crashes. Does anyone know why we can execute private
member in Editor but not in WebPlayer? Or, does it specifically crashes in my machine?
What does "crashes" mean specifically? Is it perhaps a null reference on line 10 since the private variable "name" is not initialized?
I fixed the code. It was a typo. Without debugger, my webplayer crashes. With debugger, and development mode, it says cannot access private method.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Is WWW class usable in Android platform? 1 Answer
Can you make a variable modifiable ONLY by the Inspector? 2 Answers
Best practice for copying Components from one GameObject to another? 3 Answers
UnityEditor callback OnRefresh()? 1 Answer