top of page
  • Writer's pictureDwight Gibson

An A-Press in Unity

In your scene, right-click in the hierarchy and add a UI Canvas. Add a button as the canvas' child. Create a script for loading a new scene, such as the code shown:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Below is the Unity Scene Management library
using UnityEngine.SceneManagement;

public class LoadNewScene : MonoBehaviour
{
    // A scene variable removes the need to reenter the script to make changes
    public string scene;
    public void loadScene()
    {
        SceneManager.LoadScene(scene);
    }
}

Back in Unity, add this code to the button and enter the scene you want the button to lead to. Under the button function in the inspector, add a button function, drag the button from the hierarchy into its respective field, then add your newly-written function. Make sure to go into Build Settings and check if the required scenes are implemented into the build. If it still doesn't work, go into Player Settings, Input Manager and reset.

 

This code can be pretty useful with the project we're working on. It'll help to provide an extra layer of interactivity as well as to provide more information to the player such as the controls or additional context regarding the product. The process itself seems pretty easy to remember but I've got it written here, so I'll reference it if need be.

1 view0 comments

Recent Posts

See All

Controlling and Monitoring the Production Process

Scrum is a subform of Agile which involves working on tasks in sprints, arranging meetings at the start of said sprints to coordinate and assign tasks to complete during it. The main goal is to “impro

Post: Blog2_Post
bottom of page