Hello, I’m kind of a noob by using unitron(javascript). I want that the functions OnMouseEnter, OnMouseOver and OnMouseExit, should be inaktivated when the script is disable.
This is how far i’ve got.
function OnEnable() {
Invoke("OnMouseEnter",0);
Invoke("OnMouseOver",0);
Invoke("OnMouseExit",0);
}
function OnDisable (){
Invoke("OnMouseEnter",0);
}
function OnMouseEnter () {
print("enter");
}
function OnMouseOver() {
print("over");
}
function OnMouseExit() {
print("exit");
}
But the thing is that none of the “OnMouse”-functions is inaktivated while the script is OnDisabled.
what do I have to do, to get it to work?
/*instead of having "OnEnable" call "OnMouseEnter, we will simply have both functions invoke omEnter!*/
function OnEnable()
{
Invoke("omEnter",0);
Invoke("omOver",0);
Invoke("omExit",0);
}
function OnDisable ()
{
Invoke("omEnter",0);
}
function OnMouseEnter ()
{
Invoke("omEnter",0);
}
function OnMouseOver()
{
Invoke("omOver",0);
}
function OnMouseExit()
{
Invoke("omExit",0);
}
function omExit ()// Invoked by "OnMouseExit", and "OnEnable"
{
Debug.Log ("Exit");
}
function omOver ()// Invoked by "OnMouseOver", and "OnEnable"
{
Debug.Log ("Over");
}
function omEnter ()// Invoked by "OnMouseEnter", "OnDisable, and "OnEnable"
{
Debug.Log ("Enter");
}
Thank you for your advice. I used though an other soloution:
var On : boolean ;
function OnEnable() {
On = true ;
}
function OnDisable (){
On = false ;
}
function OnMouseEnter(){
print ("enter");
}
function OnMouseOver(){
if (On == true ){
print("Over")
}
//and so on..