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 uanmanarmy · May 17, 2015 at 08:45 PM · positioncanvasimagebuttonspanel

[Solved]Why my Unity Button's Positions are different.

Ok. So I want to make some kind of animation, so when I press on the main button others buttons it will be displayed in an circular mode around that main button. But the problem is that their positions are not where it should be. This is how I want it to be.

alt text

And this is how its position after I place them. alt text

This is the code

 using UnityEngine;
 using System.Collections;
 
 public class PieMenu : MonoBehaviour {
 
     public int numPoints = 20;                       
     public Vector3 centerPos = new Vector3(0,0,32);   
     public GameObject[] pieObj;
     public float radiusX,radiusY;                 
     
     public bool isCircular = false;                 
     public bool vertical = true;                  
     
     Vector3 pointPos;                        
 
 
      void Start()
     {
         for(int i = 0; i<numPoints;i++){
             //multiply 'i' by '1.0f' to ensure the result is a fraction
             float pointNum = (i*1.0f)/numPoints;
             
             //angle along the unit circle for placing points
             float angle = pointNum*Mathf.PI*2;
             
             float x = Mathf.Sin (angle)*radiusX;
             float y = Mathf.Cos (angle)*radiusY;
             
             //position for the point prefab
             if(vertical)
                 pointPos = new Vector3(x, y)+centerPos;
             else if (!vertical){
                 pointPos = new Vector3(x, 0, y)+centerPos;
             }
             Debug.Log(pointPos);
             Debug.Log(i);
 
             //place the prefab at given position
             pieObj[i].transform.position = pointPos;
 
         }
         
         //keeps radius on both axes the same if circular
         if(isCircular){
             radiusY = radiusX;
         }
     }
 
 
 }
 

Thats because of the canvas because if I'm testing with simple sprites everything works.

screenshot-12.png (14.5 kB)
screenshot-11.png (18.6 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Gaming-Dudester · May 17, 2015 at 09:44 PM

Have you tried putting all the anchors to the top left corner of the screen?

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 uanmanarmy · May 17, 2015 at 10:31 PM 0
Share

Yes I did, I tried every anchor but the position is almost the same as in the picture above.

avatar image uanmanarmy · May 22, 2015 at 10:19 PM 0
Share

I had to access the localPosition :D

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

20 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

Related Questions

How do I create an Image of certain size in the middle of the screen with stretching border images 0 Answers

Tutorials for 2D game GUI 2 Answers

I'm trying to make a UI object move from one position to another over time 0 Answers

Image ui point at mousse position 0 Answers

How to get accurate x/y for Rectangle Transform of Panel under canvas? 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