Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Rad-Coders · May 29, 2016 at 11:40 AM · guierrorguitextureongui error

Sudden GUI.DrawTexture errors

Hi, this morning I suddenly got errors when trying to compile scripts. Everything was working the previous day.

I'm using Unity 5.2.4. So when I try to compile for instance something like this I get "Best overload method match for 'UnityEngine.GUI.DrawTexture(UnityEnginge.Rect, UnityEngine.Texture) ' has some invalid arguments" and "Argument 2 cannot convert 'Texture' expression to type 'UnityEngine.Texture'". These errors appear at places like line10.

 using UnityEngine;
 using UnityEngine.Collections;
 
 public class MainUI : MonoBehaviour
 {
     public Texture sampleTex;
 
 void OnGUI ()
 {
    GUI.DrawTexture(new Rect(0, 0, 100, 100), sampleTex);
 }
 }

This happened to all of my scripts and got 344 of these errors in total. But why all of the sudden when it work yesterday. Any help will be greatly appreciated.

Thanks --Andre

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
1
Best Answer

Answer by Bunny83 · May 29, 2016 at 01:37 PM

You have created or imported a custom class which is called "Texture" into the global namespace. That's why your script is using the wrong "Texture" type.

You have basically two options:

  • Rename your custom "Texture" class or at least put it in a seperate namespace.

  • If you don't want or if you aren't able to do the first option you can also explicitly add the correct namespace to your Texture variable (and everywhere else where you use Unity's Texture type)

So option 1 would be like this:

 namespace MyCustomClasses
 {
     // This is your custom Texture class
     public class Texture
     {
     }
 
 }

Option 2 would be like this:

 public class MainUI : MonoBehaviour
 {
     public UnityEngine.Texture sampleTex;

If you are not sure where that custom Texture class is located, just right click on the "Texture" string in your MainUI class and select "go To declaration". That menu point might be called different depending on which IDE you use. If you don't use any IDE that supports this, try a search in all your project files for the string "class Texture".

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 Bunny83 · May 29, 2016 at 01:45 PM 0
Share

ps: If you still can't find that class, it might be a UnityScript class. So just watch out for files that are named "Texture.js"

pps: If the custom Texture class is supposed to be a $$anonymous$$onoBehaviour, your best option is to rename it as a custom namespace won't work in that case. It's generaly advised to avoid names of any built-in classes / types.

avatar image Rad-Coders · May 29, 2016 at 03:36 PM 0
Share

Thanks man, it's these stupid mistakes that slips past you sometimes. Alternatively you can also just use Texture2D, but that's much more work replacing than just rena$$anonymous$$g a class.

Thanks again.

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

77 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 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer

GUI 2D Bounding Box 1 Answer

Erroe when resizing GUITextures in C# file 1 Answer

GUI Transparency Changing automatically 2 Answers

Doubt with GUILayout 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