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 JordanTimeZZZ · May 10, 2014 at 04:23 PM · 2dgrid2dtexture

Grid of gameobjects vs SetPixel

For basic 2D tiled games I've always been setting up a 2D grid of quads or recently with 4.3 sprites. I've never had a problem with this system for small sokoban or puzzle games or just simple roguelikes without any major ai or mechanics. Anyway, I was hoping to move onto my next major project using a 2D grid of 10x10pixel sprites with a fixed resolution of 320x180.

So basically I would have a 32x18 grid gameobjects with a sprite renderer attached. My sprites are simple black and white sprites (old school ascii but with a couple of original's thrown in), I have 2 layers to the grid so in total 1152 gameobjects with sprite renderers in the scene. The background grid basically with 10x10 sprites of solid colour and the foreground grid drawing the ascii sprites. On top of that I will have a couple of actors that will have their own gameobject in the scene, however all gameobjects will be instantiated at load time.

TL;DR, I've been using a layers of sprite gameobjects in a grid to do my 2d games.

I was wondering, as the game gets more complex am I better of using SetPixel for this project where I will only be using Apply once each Update() call?

Also is there a convenient way for me to make the black parts of my sprite one colour and the white parts another?

Sorry if this question isn't very well written, its much past my bed time...

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 tkoknordic · May 11, 2014 at 10:21 AM 0
Share

Also is there a convenient way for me to make the black parts of my sprite one colour and the white parts another?

This is easy task with a simple shader. $$anonymous$$ake shader that takes two colors and black-white image and in render pass put other color onto black and other color onto white pixels.

1 Reply

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

Answer by robertbu · May 10, 2014 at 04:27 PM

SetPixel is likely not the answer.

  • More efficient is to use a texture atlas and change the uv coordinates of your quad. A bit complicated but not hard to hand-code, but third-party UI systems like NGUI and EZGUI will automate this process.

  • Even better is to build many quads out of a single mesh and use uv coordinates to map the quads to textures in a texture atlas.

Search for 'Unity3d Atlas'.

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 JordanTimeZZZ · May 11, 2014 at 05:11 AM 0
Share

@robertbu Wouldn't it be better still to just use Sprite's, using unity's sprite atlasing?

avatar image robertbu · May 11, 2014 at 05:19 AM 0
Share

Unity hides a lot of sprite functionality, so I have no idea what they do under the hood. And I've never run any performance tests on Unity's sprites. $$anonymous$$y guess is that it would be as efficient as the first suggestion but not as efficient as the second suggestion. The second suggestion is technically more difficult to implement, but uses only a single drawcall for up to 16,000 quads.

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

21 People are following this question.

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

Related Questions

Get position from Isometric TileMap 1 Answer

Block puzzle (1010) help 0 Answers

2D Grid Question 0 Answers

How to make 2d distortion? 2 Answers

2D texture loaded from file different from same 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