Dice roll in canvas.

Hey! I want the random number to get into the canvas that I want to create but I don’t know how to do it…

Can someone help me with how to get the random number; steps = Random.Range(1, 7); into the canvas.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class StoneCode : MonoBehaviour
{

    public Route currentRoute;

    int routePosition;

    public int steps;

    bool isMoving;

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space) && !isMoving)
        {
            steps = Random.Range(1, 7);
            Debug.Log("Dice Rolled " + steps);

            StartCoroutine(Move());

            //if (routePosition + steps < currentRoute.childNodeList.Count)
            //{
            //    StartCoroutine(Move());
            //}
            //else
            //{
            //    Debug.Log("Rolled number is too high");
            //}
        }
    }

    IEnumerator Move()
    {
        if (isMoving)
        {
            yield break;
        }
        isMoving = true;

        while (steps > 0)
        {
            routePosition++;
            routePosition %= currentRoute.childNodeList.Count;

            Vector3 nextPos = currentRoute.childNodeList[routePosition].position;

            while (MoveToNextNode(nextPos)) { yield return null; }

            yield return new WaitForSeconds(0.1f);
            steps--;
            //routePosition++;
        }
        isMoving = false;
    }

    bool MoveToNextNode(Vector3 goal)
    {
        return goal != (transform.position = Vector3.MoveTowards(transform.position, goal, 10f * Time.deltaTime));
    }
}

What canvas? I see no canvas in your script. You first Need to create a canvas (see here) and then put a reference to the Text object that you wish to fill with your Information into your script.

finally you’d set the textObject’s ‘text’ Attribute to the string you want to display. There are many great tutorials for that.