- Home /
how to convert a object to boolean
It sais everytime in the console:''Cannot convert 'boolean' to 'Unity.Monoscript' '' Does someone have a solution?
Code:
var OptionsLevel : String; var GraphcicsScript : Monoscript = false;
function OnMouseEnter (){ renderer.material.color = Color.black; }
function OnMouseExit (){ renderer.material.color = Color.white; }
function OnMouseDown (){ if(GraphcicsScript){ GraphcicsScript = true; } else { Application.LoadLevel(OptionsLevel)} }
Answer by BerggreenDK · Dec 21, 2011 at 06:55 PM
Not sure I understand the question. Here is your code with my comments:
var OptionsLevel : String;
var GraphcicsScript : Monoscript = false; // MonoScript??? if you need to load a script into this variable, dont set it to false, set it to null.
function OnMouseEnter ()
{
renderer.material.color = Color.black;
}
function OnMouseExit ()
{
renderer.material.color = Color.white;
}
function OnMouseDown ()
{
if(GraphcicsScript) // this is only true if the variable is a boolean and the value is true
{
GraphcicsScript = true; // so why set it to true again?
} else
{
Application.LoadLevel(OptionsLevel)
}
}
My guess is that you are trying to check if a certain script is loaded or not?
I think you might want to check this link first:
http://unity3d.com/support/documentation/ScriptReference/ScriptableObject.html
so this was the answer you needed? if it is, please mark it as the correct answer so the thread / question is closed and others knows which answer let you to the solution. thanks in advance.
Your answer
