話不多說直接上例子
:
Transform center = target;
Matrix4x4 oldMat = Handles.matrix;
//獲取目標旋轉矩陣
Matrix4x4 rotationMat = center.localToWorldMatrix;
//設置當前爲旋轉矩陣
Handles.matrix = rotationMat;
{
//這裏的center是相對目標中心而言,因爲旋轉cube與目標位置相同所以是zero
Handles.DrawWireCube(center: Vector3.zero, size: center.scale);
}
//重置當前矩陣
Handles.matrix = oldMat;