Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ErAs · Dec 21, 2011 at 06:43 PM · booleanconverting

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)} }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ErAs · Dec 22, 2011 at 05:43 PM 0
Share

oh, ok now i understand. thx!

avatar image BerggreenDK · Dec 24, 2011 at 12:22 PM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Can I open unity pro projects with unity free? 1 Answer

NAudio WMA to WAV Conversion Error 0 Answers

FindWithTag or how to find if there any instances left 1 Answer

How to fix unstable boolean values? [possible bug] 1 Answer

issue with yield.WaitForSeconds(); 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges