Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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 shyreckdc · Sep 06, 2016 at 03:27 PM · coordinate-system

Display coordinate system

In the scene view, when an object is selected, the coordinate system is shown. I want the coordinate system can also be shown in the game view. I would appreciate it if you could help me.

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
1
Best Answer

Answer by iagoccampos · Sep 06, 2016 at 03:56 PM

Well, you will need a script to do it. Check OnDrawGizmosSelected, the Gizmos class, the DrawLine function and the Color variable.

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 shyreckdc · Sep 07, 2016 at 01:43 AM 0
Share

It really works! Thank you very much!

avatar image
0

Answer by LeEHil · Feb 11 at 12:24 PM

I was facing a similar problem and on this post I found the solution. But to clarify the whole "How To" a little better, I want to contribute my solution here:

 public void OnDrawGizmosSelected()
 {
     // draw y axis with arrow
     Gizmos.color = Color.green;
     Gizmos.DrawLine(transform.position, (transform.position + (2 * transform.up)));
     Cone.DrawCone(transform.position + (2 * transform.up), transform.up, 0.1f);
 
     // draw x axis with arrow
     Gizmos.color = Color.red;
     Gizmos.DrawLine(transform.position, (transform.position + (2 * transform.right)));
     Cone.DrawCone(transform.position + (2 * transform.right), transform.right, 0.1f);
 
     // draw z axis with arrow
     Gizmos.color = Color.blue;
     Gizmos.DrawLine(transform.position, (transform.position + (2 * transform.forward)));
     Cone.DrawCone(transform.position + (2 * transform.forward), transform.forward, 0.1f);
 }
 
 
 private static class Cone
 {
     private static Vector3[] newVertices = new Vector3[]
 {
             new Vector3(-0.0f, 1.0f, 0.0f),
             new Vector3(0.2f, 0.0f, 0.4f),
             new Vector3(0.5f, 0.0f, 0.0f),
             new Vector3(0.0f, 0.0f, 0.0f),
             new Vector3(-0.3f, 0.0f, 0.4f),
             new Vector3(-0.5f, 0.0f, 0.0f),
             new Vector3(-0.2f, 0.0f, -0.4f),
             new Vector3(0.2f, 0.0f, -0.4f),
 };
     private static Vector3[] newNormals = new Vector3[]
     {
             new Vector3(0,1,0),
             new Vector3(1,0,1),
             new Vector3(1,0,0),
             new Vector3(0,-1,0),
             new Vector3(-1,0,1),
             new Vector3(-1,0,0),
             new Vector3(-1,0,-1),
             new Vector3(1,0,-1),
     };
     private static int[] newTriangles = new int[]
     {
             0, 1, 2, 2, 1, 3, 0, 4, 1, 1, 4, 3, 0, 5, 4, 4, 5, 3, 0, 6, 5, 5, 6, 3, 0, 7, 6, 6, 7, 3, 0, 2, 7, 7, 2, 3
     };
 
     private static Mesh mesh;
 
     static Cone()
     {
         mesh = new Mesh();
         mesh.vertices = newVertices;
         mesh.triangles = newTriangles;
         mesh.normals = newNormals;
     }
 
     public static void DrawCone(Vector3 position, Vector3 rotation, float scale)
     {
         Gizmos.DrawMesh(mesh, position, Quaternion.FromToRotation(Vector3.up, rotation), new Vector3(scale, 2 * scale, scale));
     }
 }

Witch this code block you can easily draw a coordinate system. Just attach this to a GameObject and you will have a coordinate system drawn to it's origin using gizmos. To make this coordinate system visible in the game view you will need to enable gizmos there.

alt text


2022-02-11-08-22-00-edag-automationstudio-op4300-t.png (12.7 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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem with rotation order of euler angles when importing MoCap data 1 Answer

GameObject position and orientation in the 3D environment. 1 Answer

maya to unity: converting rotation matrix coordinate system 0 Answers

Is there any way to set a Gameobject's transform matrix to be the World Space? 0 Answers

Need to convert to/from right-handed coordinates 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