Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 MrSplosion · Sep 06, 2011 at 12:26 AM · guitexturetexture2dtileoffset

Tile and offset a Texture2D?

I have a sprite sheet with a bunch of different items I want to use similar to minecraft's. I need to tile and offset my sprite sheet so I can get each one of these items in the texture. The problem is that I need to do this for a Texture2D but I don't think that's possible because you can't tile or offset a texture represented as a Texture2D. So my question is how do I get around this problem, how do I tile and offset a texture that can be applied to a GUI for a HUD?

Thanks.

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 MrSplosion · Sep 07, 2011 at 02:25 AM 0
Share

Anyone? Surly there is another way around this.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Ipsquiggle · Sep 07, 2011 at 02:31 AM

It is not possible to do either tiling or subtexturing (picking a region out of a larger texture) using UnityGUI. If you really need this, consider using a 3rd party GUI system, or make your own using textured quads aligned to a camera. Then you will be able to access either the material (as suggested in IllogicalIronical's answer) or the UVs of the quad in order to do subtexturing.

Comment
Add comment · 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
0

Answer by Illogical-Ironic · Sep 06, 2011 at 03:02 AM

I know how. I have this code that might come in handy:

 var texture : Texture2D;
 var scaleX : float = 1.0;
 var scaleY : float = 1.0;
 var offsetX : float = 0;
 var offsetY : float = 0;
 
 function Start() {
     // Create a new texture and assign it to the renderer's material
     renderer.material.mainTexture = texture;
 
     //Set the texture to the indicated offset
         renderer.material.mainTextureOffset = Vector2 (offsetX, offsetY);
 
     //Change the scale of the texture
     renderer.material.mainTextureScale = Vector2 (scaleX,scaleY);
 }

I hope it helps you as well as it helped me out :D

Comment
Add comment · Show 1 · 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 MrSplosion · Sep 06, 2011 at 11:48 PM 0
Share

No that's not what I'm looking for I need to tile a texture2D, not a material.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Offset detail texture in c# 1 Answer

more guitexture in void ongui 1 Answer

Assiging an Image to a Button 1 Answer

Best way to show an image 2 Answers

GUI texture to change texture when hovered over or clicked? 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