Translating gui.matrix to java problem

Hello everyone

I have this script of gui.matrix and it works great but its for c++ and i did my whole project in java and i cant just change it so i ask if someone knows how to translate the script i really tried everything but it just doesnt do anything

Script:

  Matrix4x4 transformation = Matrix4x4.TRS(
        Vector3.zero,
        Quaternion.identity,
        Vector3.one);   
 
    void OnGUI() {
// We need to assign the GUI matrix before GUI controls are shown.
        GUI.matrix = transformation;
 
        if (GUI.Button(new Rect((Screen.width - 250) / 2, (Screen.height - 100) / 2 - 55, 250, 100), "TRANSFORM GUI")) {
            transformation = Matrix4x4.TRS(
                new Vector3(-Screen.width * 0.2f, -Screen.height * 0.7f, 0),    // move the GUI a little to fit the transformed controls in the screen
                Quaternion.Euler(0, 0, 15),    // rotate 15 degrees clockwise around Z, because controls are in XY plane
                new Vector3(2, 2, 1));  // scale GUI x2 times in X and Y
        }
 
        if (GUI.Button(new Rect((Screen.width - 250) / 2, (Screen.height - 100) / 2 + 55, 250, 100), "NORMALIZE GUI")) {
            transformation = Matrix4x4.TRS(
                Vector3.zero,
                Quaternion.identity,
                Vector3.one);
        }
    }

script made by unimechanic

Thanks in advance Skullbeats1

First of all this script is written in C# and not C++ also you are using UnityScript and not Java. The syntax of the relevant parts is exactly the same, you just need to change the declaration of the variable and the method. Also a matrix with no translation, no rotation and a scale of 1.0 is the identity matrix, so you can simply exchange it with the Matrix4x4.identity constant

var transformation = Matrix4x4.identity;
 
function OnGUI() {
    // We need to assign the GUI matrix before GUI controls are shown.
    GUI.matrix = transformation;
    
    if (GUI.Button(Rect((Screen.width - 250) / 2, (Screen.height - 100) / 2 - 55, 250, 100), "TRANSFORM GUI")) {
        transformation = Matrix4x4.TRS(
            Vector3(-Screen.width * 0.2f, -Screen.height * 0.7f, 0), // move the GUI a little to fit the transformed controls in the screen
            Quaternion.Euler(0, 0, 15), // rotate 15 degrees clockwise around Z, because controls are in XY plane
            Vector3(2, 2, 1)); // scale GUI x2 times in X and Y
    }
    
    if (GUI.Button(Rect((Screen.width - 250) / 2, (Screen.height - 100) / 2 + 55, 250, 100), "NORMALIZE GUI")) {
        transformation = Matrix4x4.identity;
    }
}