• 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
Question by rOBY GAMES · Aug 09, 2015 at 08:28 PM · mousecursoractivefalsetrue

CursorAnim.cs (28,17): error CS0029: Can not implicitly convert type 'bool' to `UnityEngine.Texture2D '

I get this error. I want to turn it off 2 Texture2D different.

When I press the left mouse button to activate the mouse cursor component (Texture2D) and when the release button to trigger another (textured2d).

how to fix the error CS0029: Can not implicitly convert type 'bool' to `UnityEngine.Texture2D '

script reference:

 using UnityEngine;
 using System.Collections;
 
 public class CursorAnim : MonoBehaviour {
 
     public Texture2D cursoropen;
     public Texture2D cursorclose;
     public Vector2 mouse;
     public int w = 32;
     public int h = 32;
 
 
     void Start()
     {
         Screen.showCursor = false;
         }
 
 
     void Update()
     {
         if (Input.GetMouseButtonDown (0))
         
 
         cursorclose = true;
         cursoropen = false;
         
         if (Input.GetMouseButtonUp (0))
         
         {
         cursoropen = true;
         cursorclose = false;
         }
 
         mouse = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
     
     }
     
     void OnGUI()
     {
         GUI.DrawTexture(new Rect(mouse.x - (w / 2), mouse.y - (h / 2), w, h), cursoropen = cursorclose);
     }
 
 }
Comment

People who like this

0 Show 0
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

Answer by RLin · Aug 09, 2015 at 08:37 PM

 someTexture2D.enabled = true;
Comment

People who like this

0 Show 8 · 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 rOBY GAMES · Aug 09, 2015 at 08:41 PM 0
Share

someTexture2D.enabled = true;

It does not refer to either of these.

public Texture2D cursoropen; public Texture2D CursorClose;

avatar image RLin · Aug 09, 2015 at 08:44 PM 0
Share

Do I really have to be so specific? Just put the name of your texture2D in the place of someTexture2D and set the bool to true or false.

avatar image rOBY GAMES · Aug 09, 2015 at 08:54 PM 0
Share

I'm sorry. :-)

But now I get this error.

cursoropen.enabled = true;

24,36): error CS1061: Type UnityEngine.Texture2D 'does not contain a definition for enabled' and no extension method enabled 'of type UnityEngine.Texture2D' could be found (are you missing a using directive or an assembly reference?)

avatar image RLin · Aug 09, 2015 at 09:03 PM 0
Share

What are you trying to? You can't activate texture2D's; they don't inherit from monobehaviour and are not components.

avatar image rOBY GAMES · Aug 09, 2015 at 09:15 PM 0
Share

I have two sprites. open hand and closed hand. I'm using the mouse cursor with these two hands.

alt text

alt text

these two sprites are in Texture2D. I wish that when I press the left mouse button active sprite closed hand, and when you release the button, turn off the closed hand is on his open hand.

4-mano-pugno-chiuso.png (113.8 kB)
1-mano-aperta.png (153.5 kB)
Show more comments

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Disabling Mouse Look with Escape wont work? 1 Answer

iOS deactivating a script deactivates the gameobject 1 Answer

radio off and on 1 Answer

Cursor Locks/Hides but Will Not Reappear? 1 Answer

guiTexture button hit area 0 Answers


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