最近、UnityでARKitを使ってゲーム制作をしていますTOSHです。
久しぶりにUnityを使っているのですがエディターをもともとMonoDeveloperを使用してたものの、バージョンの更新に伴いVisual Studioに変更しましたが、やっぱり軽いほうがいいということでVSCodeに変更しました。
しかし
完璧に思えたVSCodeには絶対に見過ごせない欠点がありました...
それは、コードを整形した時、下のようになるのです。
void Update ()
{
if (Input.GetMouseButtonDown (0)) {
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
//we'll try to hit one of the plane collider gameobjects that were generated by the plugin
//effectively similar to calling HitTest with ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent
if (Physics.Raycast (ray, out hit, maxRayDistance, collisionLayer)) {
//we're going to get the position from the contact point
m_HitTransform.position = hit.point;
Debug.Log (string.Format ("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z));
//and the rotation from the transform of the plane collider
m_HitTransform.rotation = hit.transform.rotation;
}
}
}
いやいやなんで { 改行されるん!!!
いや必要ないやん!ってかこれが気になって気になって仕方がなかったのです。
しかし、どのサイトを調べ得ても、方法が見つからなかったので、仕方なく英語で検索しました。
いやいや、整形って英語でなんていうん???
そもそもここがわからず、だいぶ苦戦しましたが、どうやらformat
というようです。
それがわかり、GoogleでVSCode change format
と検索すると、
とある拡張機能が出てきました。
それがこれです。
C# Fix Format
説明文を読んで見るとそれっぽいので早速、installしてみることに!
installをし、VSCodeを再起動、
そして、option+shift+fで整形をすると、なんと
void Update () {
if (Input.GetMouseButtonDown (0)) {
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
//we'll try to hit one of the plane collider gameobjects that were generated by the plugin
//effectively similar to calling HitTest with ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent
if (Physics.Raycast (ray, out hit, maxRayDistance, collisionLayer)) {
//we're going to get the position from the contact point
m_HitTransform.position = hit.point;
Debug.Log (string.Format ("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z));
//and the rotation from the transform of the plane collider
m_HitTransform.rotation = hit.transform.rotation;
}
}
}
おお!変わった!感動!
これで気持ち悪い違和感はなくなりました。めでたし、めでたしと。