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
0
Question by ducthangdang1502 · Jan 04, 2021 at 10:19 PM · canvasoverlayscreenspace

My canvas keep being off center and I have trouble instantiating objects at (0,0,0)

Hello. I am learning to instantiate an object, and I tried making a "Card" in the center of the screen, or (0,0,0). But when I play, the object is instantiated at the bottom left of the screen. I opened the editor to find out that the canvas was positioned automatically like this: alt text

The Main camera was positioned at 0, which is the bottom left corner of the Canvas.

alt text

I looked around on the internet and learned that I should keep the canvas render mode to Screen Space - Overlay. But this way I can't instantiate my object. Does it have something to do with my screen or editor layout? Can anybody please help me?

unity1.png (13.5 kB)
unity2.png (5.4 kB)
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
Best Answer

Answer by ducthangdang1502 · Jan 06, 2021 at 11:10 AM

Hello again,

After some further studies, I found the answer to my problem here and I want to add to @sacredgeometry 's one.

Great explanation can be found here https://www.youtube.com/watch?v=at6gUB_-HII.

The Screen space - overlay Canvas and the view of the camera are two separate things. In the overlay canvas, the objects are mapped to the screen by pixel like stickers to a glass window. The Canvas in this case corresponds to the screen ratios, leading to weird x,y ratios if you set Free Aspect on the game panel.

On the other hand, the camera is rendering 3D objects in the actual world space. Objects here are not sticked to the screen but move freely in 3D space. You can modify their Z axis and see how they change, unlike the overlay mode.

The game will render both views on the same screen, though, leading to a little confusion at first. Think of looking through a glass window where you can see both the stickers on it (overlay), and the objects outside the window (gameObjects).

In this case I chose to display my card in the overlay layer. I will create the card and then position them afterwards. My approach was to create some GameObject at the place I want my cards to be, and call them positions.

First, I Instantiate my cards without the position parameter. Then, I will snap the cards to the premade positions by setting the the cards position to the premade positions.

Here is the code that will snap the cards to position after Instantiating them:

void SnapCardInPlace() { cardClone.transform.position = cardPosition.transform.position; }

I hope this help other people new to the concept. Cheers

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 sacredgeometry · Jan 06, 2021 at 08:03 AM

0,0 in screen space is different to 0,0 in unitys local or world coordinate space. World space origin is in the centre of the the coordinate space, and screen space origin is (depending on the library) one of the corners.

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

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

How to display the gameobjects of a worldspace canvas in front of gameobjects of screen space overlay canvas? 1 Answer

Missing Camera for Canvas (Screen Space - Overlay)? 0 Answers

Particle System not showing over "Screen Space - Overlay" UI Canvas 0 Answers

Canvas screenpspace overlay for a particular camera 0 Answers

Screen Space - Camera to Screen Space - Overlay switch issue 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