public void MatrixTest1(){

///Matrix4x4 是列矩阵,就是一个vector4表示一列,所以在c#中矩阵和Vector4只能矩阵右乘坐标。但是在shader中是矩阵左乘坐标,所以在shader中是行矩阵

Matrix4x4 moveMatrix1 = new Matrix4x4(new Vector4(1,0,0,0),new Vector4(0,1,0,0),new Vector4(0,0,1,0),new Vector4(1,1,1,1));//列矩阵,xyz 各位移一个单位

Matrix4x4 matrix4X4 = new Matrix4x4(new Vector4(1,0,0,1),new Vector4(0,1,0,1),new Vector4(0,0,1,1),new Vector4(0,0,0,1));//如果是行矩阵(这里只是演示),xyz各位移一个单位

Matrix4x4 moveMatrix2 = new Matrix4x4(new Vector4(1,0,0,0),new Vector4(0,1,0,0),new Vector4(0,0,1,0),new Vector4(2,2,2,1));

// Matrix4x4 resultMatrix = moveMatrix1 * moveMatrix2;

var posMatrix = new Vector4(transform.localPosition.x,transform.localPosition.y,transform.localPosition.z,1);

Vector3 pos1 = moveMatrix1 * posMatrix ;

Vector3 pos2 = moveMatrix1 *( moveMatrix2 * posMatrix);

Debug.Log($”pos1 is {pos1} pos2 is {pos2}”);

}

以上只是做个记录,怕忘记了,如果错,后面再来改