Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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
1
Question by ShichiNoBushi · Mar 09, 2015 at 07:34 AM · 2dtexturespriterenderrepeat

2D - How to make sprites repeat tiles?

I recently started using Unity in an attempt to make a game prototype. I initially made a version of the game I'm making in Game Maker, but I expected I could make a better version in Unity. As I've been trying to migrate things over, I ran into probably the stupidest problem. I'm trying to apply sprites to objects, and to limit the number of objects (a few large ones rather than a whole bunch arranged in a grid), I'm trying to use box colliders as well as any others I find necessary. But what I'm having trouble with is getting the graphic to look like a repeating texture rather one that scales with the size of the object. The only component I've found to display 2D sprites is the Sprite Renderer. I tried changing the Sprite into a texture, but that's apparently incompatible with Sprite Renderers. I also tried adding a bit of code to change the sprite to "repeatable", but that doesn't seem to do anything.

void Update () { renderer.material.mainTexture.wrapMode = TextureWrapMode.Repeat; }

If there are any other tools that can solve this issue, I would appreciate any suggestions including any code to use preferably in C# or how to execute the code.

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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by zvasconcelos · Dec 30, 2018 at 01:11 PM

I know this is an old question, but in case someone still in doubt about this topic, you can set you sprite's "Wrap mode" to "repeat". This will do the trick.

alt text


unityhelp.png (69.3 kB)
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 sp-LeventeLajtai · Feb 13, 2020 at 10:18 AM 0
Share

This should be the accepted answer, it works perfectly.

avatar image
0

Answer by ShichiNoBushi · Mar 09, 2015 at 11:42 AM

edit: previous answer apparently removed

I'm sorry, but your answer doesn't help much because it seems to be about animation. What I need to happen is to have a texture create repeating tiles on the environment. I already imported the sprites as images into Unity, and they automatically became Sprite 2Ds. My problem is that as I adjust the size of the objects they're applied to, they scale with the size rather than staying the same and crating copies.

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 dval · Jan 08, 2016 at 02:01 AM

You could sort of cheat by having a parent gameobject with a RectTransform and a UI.GridLayoutGroup component attached. Then, your sprite would need a UI.LayoutElement attached to it. Then just fill the layout with sprite instances.

It would be a pain to manage without a script in the large scale. But for small groups that change size, it works nice. Doesn't add a lot of overhead either. Unity seems to be ok with the re-use.

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 ly202009 · May 26 at 04:09 PM

@ShichiNoBushi This is a really old post but I had some trouble around this so just leaving some stuff. Set the sprite settings to something like this:

https://answers.unity.com/storage/temp/196801-screenshot-2022-05-26-094951.png

Then create a gameobject with a sprite renderer that shows this sprite, and put a collider on it, in my case, my sprite is a metal box. Make sure to crop out any blank space on your sprite in the sprite editor. Set the scale of the gameobject to whatever you want the repeating sprite to be the size of. In the collider, turn on Auto Tiling. Set the Draw Mode of the Sprite Renderer to Tiled. Now your gameobject settings should look something like this:

https://answers.unity.com/storage/temp/196802-screenshot-2022-05-26-095422.png

To change the size, DON'T ALTER THE SCALE, alter the width and the height in the sprite renderer and it'll repeat the sprite. Hope this helps!


screenshot-2022-05-26-094951.png (55.8 kB)
screenshot-2022-05-26-095422.png (72.1 kB)
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

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Sprite rendering texture as one solid color 1 Answer

Tilemap: Resizing Tiles? 1 Answer

loading sprite from atlas in script 4 Answers

Unity Adds Antialiasing to Texture 2 Answers

Black boarder on transparent sprites 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