Skip to content

Instantly share code, notes, and snippets.

@GOROman
Created May 9, 2019 06:53
Show Gist options
  • Save GOROman/b12ddb6d4674c61eb826cf3edfc62e54 to your computer and use it in GitHub Desktop.
Save GOROman/b12ddb6d4674c61eb826cf3edfc62e54 to your computer and use it in GitHub Desktop.
UnityのSceneView上に行列を表示する
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MatrixViewer : MonoBehaviour
{
void Update()
{
}
void OnDrawGizmos()
{
#if UNITY_EDITOR
Matrix4x4 m = transform.localToWorldMatrix;
string text = "";
text += string.Format("{0:N2} {1:N2} {2:N2} {3:N2}\n", m[0, 0], m[0, 1], m[0, 2], m[0, 3]);
text += string.Format("{0:N2} {1:N2} {2:N2} {3:N2}\n", m[1, 0], m[1, 1], m[1, 2], m[1, 3]);
text += string.Format("{0:N2} {1:N2} {2:N2} {3:N2}\n", m[2, 0], m[2, 1], m[2, 2], m[2, 3]);
text += string.Format("{0:N2} {1:N2} {2:N2} {3:N2}\n", m[3, 0], m[3, 1], m[3, 2], m[3, 3]);
UnityEditor.Handles.Label(transform.position, text);
#endif
}
}
@GOROman
Copy link
Author

GOROman commented May 9, 2019

Matrix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment