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 robert 1 · Feb 16, 2011 at 06:33 PM · texturechange

texture change problem

var cubeToggle : boolean = false; var window1 : Rect = Rect (20,20,650,300); var cube3 : Transform; var cube4 : Transform; var texture1 : Texture2D; var texture2 : Texture2D; function OnGUI() { window1 = GUI.Window(0,window1,firstwindow,"LOGIN WINDOW"); if(table9 == true) { cubeToggle = GUI.Toggle(Rect(Screen.width*(4.5/6.55),Screen.height*(4/6.3),Screen.width* (1.7/6.55),Screen.height*(1/6.3)),cubeToggle,"CUBE1"); cubeToggle = !GUI.Toggle(Rect(Screen.width*(4.5/6.55),Screen.height*(4.25/6.3),Screen.width*(1.7/6.55),Screen.height*(1/6.3)),!cubeToggle,"CUBE2"); }

}

function firstwindow(windowID : int) {

  if(table7 == true)
  {
    GUI.Label(Rect(200, 250, 300, 100), "YOU HAVE CLICKED ON:cube1 ");
  }
  if (table8 == true)
  {
    GUI.Label(Rect(200, 250, 300, 100), "YOU HAVE CLICKED ON:cube2 ");
  }
  if (cubeToggle == true)
  {
    table7 = true;
    cube1.renderer.material.mainTexture = texture1;

  }

  if(!cubeToggle == true)
  {
    table8 = true;
    cube2.renderer.material.mainTexture = texture2;
    cubeToggle = false;
  }

}

Here my problem is: I have two cubes (cube3 and cube4) with two toggle buttons (cube 1 and cube2) My need is when I click on cube1, toggle button texture should change to texture1; and when I click on cube2, toggle button texture should change to texture2. When cube1 toggle button is clicked, corresponing label should display "you have clicked on cube 1". When cube2 toggle button is clicked, corresponing label should display "you have clicked on cube 2"

Comment
Add comment · Show 1
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 Kona · Feb 16, 2011 at 07:07 PM 0
Share

I'm not a very experienced programmer and I haven't looked into changing textures etc. but I do know that changing material (which would do pretty much the exactly same thing as long as the materials are identical apart from their name and the texture they're using.) work since I've done it that way myself once. :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DaveA · Feb 16, 2011 at 09:14 PM

Do you need to handle both cubes in the same script? I would have a script that just changes one thing, and put it on both cubes.

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 robert 1 · Feb 16, 2011 at 09:40 PM 0
Share

i want both cube when first toggle button pressed then texture of first cube should change when second toggle is pressed second cube texture should change that is my sample code

avatar image robert 1 · Feb 16, 2011 at 09:41 PM 0
Share

that is not working properly

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

No one has followed this question yet.

Related Questions

How to render part of an object 2 Answers

How can I change an object's texture in-game when the object is unlit? 2 Answers

How to: Create shader and copy texture? 2 Answers

Changing texture for pause button 1 Answer

Changing GameObject texture? 4 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