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 /
  • Help Room /
avatar image
0
Question by Xarbrough · Jun 07, 2016 at 09:15 PM · c#naming

What do you call a map coordinate or 2D array index pair?

I'm looking for a better name than the lengthy "coordinate" to use when dealing with 2D arrays and the composite of the indices like so:

 public class Map
 {
     public int x; // x coordinate
     public int y; // y coordinate
 
     byte[,] data;
 
     public static Vector2 CoordinateToWorldPosition(IntVector2 mapCoordinate)
     {
         return Vector3.zero;
     }
 
     public static IntVector2 WorldPositionToCoordinate(Vector2 worldPosition)
     {
         return new IntVector2();
     }
 }

I basically only need this when returning both indices from a function at once, but that made me think that my naming is not yet perfect.

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

Answer by Jeshira · Jan 25, 2018 at 09:47 PM

C# naming convention advice against using abbreviation unless widely accepted, but a common accepted abbreviation used for coordinate is coord. There isn't any word it can be confused for.

 public  static Vector2 CoordToWorldPosition(Vector2Int _coord) {}
 public static Vector2Int WorldPositionToCoord(Vector2 _position) {}

N.B. Vector2Int is an int-based Vector2 that is now part of Unity.

.NET General Naming Conventions

Comment
Add comment · Show 3 · 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 StarCmd · Jan 29, 2018 at 01:42 PM 0
Share

How to use [Vector2Int][1] ? Vector2 gridXY = new Vector2(0, 0) : O$$anonymous$$ Vector2Int gridXY = new Vector2Int(0, 0) : Visual Studio does not recognise it and Unity complain "The type or namespace name `Vector2Int' could not be found" Thanks [1]: https://docs.unity3d.com/ScriptReference/Vector2Int.html

avatar image Hellium StarCmd · Jan 29, 2018 at 01:58 PM 0
Share

Which Unity version of Unity do you use? This struct is available since Unity 2017.2 only.

avatar image StarCmd Hellium · Jan 29, 2018 at 02:04 PM 0
Share

Was still with 2017.1.1f1. Thanks.

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

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

[Solved] How to find a variable using the value of another variable? 1 Answer

C# naming related enum, private member and public accessor. 2 Answers

[SOLVED]I'm trying to destroy a button. YOU MAY WANT TO CHECK THIS THREAD IF DESTROY OBJECT IS NOT WORKING FOR NO GOOD REASON. [SOLVED] 0 Answers

Accessing string from other script 1 Answer

Rotate camera on collision of character 1 Answer


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