Calculator with GUI resources

Hello, I need help (My english is bad) :stuck_out_tongue:

My problem is: I need an Example (complete code in C#) how to make a mini-calculator using gui buttons

where the user can type a number X, and Y number, imagine this to be done in a text field (on screen), then you do the sum of these two numbers if the user presses the button (“Result”) .

Please help meee, I understand that the integer values ​​must be converted to string, but I do not know how to do that

I need a funcionally short script in C# please

This is my idea:

I hope it’ll help you :wink:

using UnityEngine;

public class Calculator : MonoBehaviour 
{  
    string x = "0";
    string y = "0";
    string result = "0";

    void OnGUI()
    {
        x = GUI.TextField(new Rect(10, 10, 100, 30), x);
        y = GUI.TextField(new Rect(120, 10, 100, 30), y);

        if (GUI.Button(new Rect(200, 10, 100, 30), "Resul"))
        {
            int integer_x = 0;
            int integer_y = 0;

            System.Int32.TryParse(x, out integer_x);
            System.Int32.TryParse(x, out integer_y);

            result = (integer_x * integer_y).ToString();
        }

        GUI.Label(new Rect(220, 10, 100, 30), result);
    }
}

im late as fuck, but for other people reading, inthink a float value or double would do better than an integer

I’m even later but if you ever do a project similar to this then use a GUI Designer. VisualTK is good but https://labdeck.com/python/ is better. Also, they have a scientific calculator GUI as well ()
Trent240