- Home /
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);
     }
 
 }
Answer by RLin · Aug 09, 2015 at 08:37 PM
 someTexture2D.enabled = true;
someTexture2D.enabled = true;
It does not refer to either of these.
public Texture2D cursoropen; public Texture2D CursorClose;
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.
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?) 
What are you trying to? You can't activate texture2D's; they don't inherit from monobehaviour and are not components.
I have two sprites. open hand and closed hand. I'm using the mouse cursor with these two hands.


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.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                