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 TheKnight · Jul 29, 2011 at 09:50 PM · javascriptguitexturematerialbumpmap

Menu material error

Hi,

I have a cube with the button script which I am trying to modify. To show a button and a picture of the texture that I want to be applied.

 var btnTexture : Texture;
 var bumpMap : Texture;
 function OnGUI() {
     if (!btnTexture) {
         Debug.LogError("Please assign a texture on the inspector");
         return;
     }
     if (GUI.Button(Rect(10,10,50,50),btnTexture))
         Debug.Log("Clicked the button with an image");
     if (GUI.Button(Rect(10,70,50,30),"Click")){
         Debug.Log("Clicked the button with text");
         renderer.material.SetTexture("_BumpMap", bumpMap);
     }
 }

So, when I run it it says that material doesn't have a texture property _BumpMap. Why is that? Do I need to apply something else to the material?

P.S. - post the answers as comments to this post or I will answer them as comments in this post.

Thank you all. Cheers.

Comment
Add comment · Show 5
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 Kith · Jul 29, 2011 at 10:45 PM 0
Share

Why would someone post the answer as a comment as opposed to, say..an answer?

avatar image TheKnight · Jul 29, 2011 at 10:49 PM 0
Share

I can't comment on other people's replies so I'll have to make a new reply or post comments on this post. If I post as a reply I'll get downvoted just like a got the last time.

avatar image Kith · Jul 29, 2011 at 10:54 PM 0
Share

You can comment on other people's replies, and that's actually the way you should do it. The wrong way to do it is to post an answer as a reply. Look at this answer and notice that the answers have their own replies (http://answers.unity3d.com/questions/13784/players-projectile-communicating-with-enemy.html) You get down voted when you post a new answer for every comment you have.

avatar image Waz · Jul 29, 2011 at 10:59 PM 1
Share

Try commenting now. The permissions were changed quite recently because of that problem.

avatar image TheKnight · Jul 29, 2011 at 11:03 PM 0
Share

Actually now I can. Great :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Waz · Jul 29, 2011 at 10:54 PM

Ensure the Material on the Renderer is a Bumped one.

Comment
Add comment · Show 4 · 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 TheKnight · Jul 29, 2011 at 11:05 PM 0
Share

It's set as a default diffuse, so what I want to do is when I click the button a texture is applied to the cube.

avatar image Waz · Jul 29, 2011 at 11:11 PM 0
Share

The you also need to set the shader:

 renderer.material.shader = Shader.Find("Bumped Diffuse");
avatar image Waz · Jul 29, 2011 at 11:15 PM 0
Share

(note that it is better to use a variable for that Shader as you have for the other attributes, since it performs better and ensures correct dependencies, I just used the simplest to write and understand)

avatar image TheKnight · Jul 29, 2011 at 11:17 PM 0
Share

Put it into the script still not working.

Here is how it's set up : Cube's mesh renderer is - Default Diffuse. I've made a material that I've named _Bump$$anonymous$$ap which is bumped specular but don't use it. I have a texture that I also named _Bump$$anonymous$$ap which I attached to the script. And that's it. Error : material doesn't have a texture property _Bump$$anonymous$$ap.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Modifying scroll texture 1 Answer

Repositioning remote GUI Texture 1 Answer

GUI Info button not displaying 1 Answer

How can i show the texture in the array? 2 Answers

DrawTexture GUI iPhone 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