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
1
Question by braisque · Apr 16, 2018 at 10:29 AM · scalespritessizequad

How to resize a quad to fit the dimensions of a sprite/.png ?

I'm building a 3D fps game, basically like the first doom. The thing is I want my "sprites" to cast shadow. So I have to put them in quads (I believe there's no other way to have the sprites cast shadows).

My first question is: Is it optimized to glue two quad together to have my sprites visible on each face ?

My second question is: If I put a .png in the game's assets, and I set the texture type to "Sprite (2D and UI), I can put this sprite in the game and the x and y sizes from the original .png are kept identical in the game. But I have to put the .pngs in quads and transform these .pngs to materials: But then I can't get the size and scale to be exactly the same as in the .png. Is there a non-manual way to set the size and scale of the quad to be the same as the original .png ?

Thank you for reading

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by selewi · Apr 16, 2018 at 11:11 AM

First of all, I think that if you want to use a quad with a sprite, you need to know about the billboarding technique, which makes a 2D sprite rotate towards the camera position, so you cannot see the "dark side of the sprite" huh :P.


You can set the scale and the size of a sprite by scripting using the quad bounds or the sprite bounds deppending on what you want to resize. Sorry I cannot help you with code right now, if you still need help with that I'll try to cover the code for you later, but I hope this is enough help. Cheers!

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 braisque · Apr 17, 2018 at 03:46 PM 0
Share

That is true. I indeed figured that I need to "billboard" some sprites and I figured how to do it.

I get your idea: If I'm correct, I shall, in a script, get the size of a sprite bound to a specific quad (in which I put the script) so it transforms that quad according to the sprite's size? Unfortunately, I can't figure out how to code that. I'm still not good enough to write that in C# ><. Could you help me ? Thank you anyway for the time you spent answering.

avatar image
0

Answer by BCook99 · Nov 23, 2020 at 08:30 PM

I recently ran into the same issue. In my project I imported the sprites png files as texture type Sprite 2D and set the pixel ratio to 1:1.

I then created a material using the sprite for the albedo and put it on a quad using a sprite shader. By setting the quad scale equal to the dimensions of the PNG file, it matched a 2D sprite display size perfectly.

In my example, the PNG file was 600x600 pixels and the quad scale was 600,600,1

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

82 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 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 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 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

Scale Particle Billboards On Specific Axis 0 Answers

Permanent space between objects 2 Answers

Resizing only one side of GameObject with mouse drag 0 Answers

Prefabs with sprites, make them all same size 0 Answers

Sprite size and resolution,Sprite Size and Resolution 0 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