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
0
Question by smizelle · Jun 26, 2011 at 04:30 PM · guimaterialanimate

how to add material component to an Animate GUI script

Essentially I'm trying to create a cursor with two textures which it will alternate between using scripting but I can't seem to add a texture component in the Animate GUI script in the inspector window. Any suggestions as to how to accomplish this?

(By the way I'm trying to follow this tutorial: http://www.design3.com/unity/game-builds/knights-3d-game/item/315-chapter-4-custom-cursor-image)

I think this may have to do with the script the tutorial is using that no longer works (specifically the Textured2D)?

(below is my animate GUI script so far)

var textures : Textures2D[];

function Update () { if (Input.GetButton("Fire1") ) { guiTexture.texture = textures[1]; } else { guiTexture.texture = texture [0]; } }

@script RequireComponent(GUITexture)

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 SilverTabby · Jun 26, 2011 at 05:27 PM 0
Share

The only thing I'm seeing wrong with this script is a few misspelled words:

var textures : Texture2D[]; //removed an extra s on the Texture2D

else{ ... = textures[0];//added a missing s to textures

I would assume the compiler would catch those so I don't think this is what you're looking for, though

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Ashkan_gc · Jun 26, 2011 at 05:26 PM

you should write

 var textures : Texture2d;

and not Textures2d. this is the problem. then use textures[n] where n is the index of the texture in the texture array.

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 smizelle · Jun 26, 2011 at 05:49 PM 0
Share

Oh thank you. That did fix my script error.

However I still don't have a material component under my GUIscript that I need...

avatar image Ashkan_gc · Jun 26, 2011 at 06:38 PM 0
Share

you don't need a material component. you now have an array called textures in your inspector. open it and type a number is size filed (2 for example) and then drag two textures in those two appeared texture slots. and use them.

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

Editing buttons created in 'for' loop. 0 Answers

GetComponent Help 2 Answers

GUI in the middle of the screen 1 Answer

GUI draw rectangle script not drawing rectangle! 1 Answer

Any/best way to add a texture in Editor? 2 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