A simple Space Bar Press Interaction to make the calculation run, and I made the floats public for easy testing.
‘’ public class PowerCalculation : MonoBehaviour
{
public float numberToCalculate, powerToRaise;
// Start is called before the first frame update
void Start()
{
}
private void Calculate()
{
if(Input.GetKeyDown(KeyCode.Space))
{
Debug.Log( numberToCalculate + " raised to the " + powerToRaise + "th power, equals " + Mathf.Pow(numberToCalculate, powerToRaise));
}
}
// Update is called once per frame
void Update()
{
Calculate();
}
}’’