Index

  • Summary
  • Calling a Unity scene from UNITE
  • Accessing UNITE from a Unity scene
  • About Asset
  • Sample

 

Summary

This function allows you to go back and forth between scenes created in Unity and UNITE.

By using this function, you can create completely different expressions that are not bound by the restrictions of UNITE.

To use this function, you need to create a scene in Unity beforehand.

We have prepared a sample to check the operation, so please check it when you want to check it with something that works.

 

 

Calling a Unity scene from UNITE

It can be used from the [Scene Control] > [Call Unity Scene] event.

mceclip0_34_46b13faf5c

 

The “Call Unity Scene” event command has the following settings

mceclip2_24_35a97248f3

 

① Select the Unity scene to call.

Open the Build Settings window

mceclip0_35_d7f5c02d01

 

A previously created Unity scene must be added to the “Scenes included in build” in the Build Settings.

60d39830_17e5_4e97_9012_7b1c9f86e395_1_1227227e97

Doing so will allow the scene to be selected by the event command.

mceclip3_19_b55b220a5f

 

② Select whether to unload the map scene

Each unloading of a scene has its own advantages/disadvantages.

1_drawio_1_527a5679b0

 

③ Specify variables to be passed

The variable specified here can refer to its value on the Unite scene side.

Also, when returning to UNITE, the resulting value of the Unity scene will be stored in that variable.

(If “(none)” is specified, the value becomes 0 when referenced, and the resulting value is not stored.

Variables are referenced and stored as int type.

 

Accessing UNITE from a Unity scene

4c7b33b6_043c_4a55_b20b_195573e9fa9b_1_7214e3a9b3

 

① namespace.

using RPGMaker.Codebase.Runtime.Event.Screen;

② Obtains the value of a “variable.

CallUnitySceneProcessor.GetVariableValue()

 

③ Return to UNITE scene with return value.

CallUnitySceneProcessor.ReturnToUnite(num)

The Unity scene is unloaded, the return value (num) is stored in a variable and returns to UNITE.

 

Unloading Scenes

When CallUnitySceneProcessor.ReturnToUnite() is called,

All loaded scenes are unloaded (except for DontDestroyOnLoad and SceneMap)

GameObjects that you do not want to be destroyed should be moved to DontDestroyOnLoad using Object.DontDestroyOnLoad().

Please make those GameObjects inactive by setting them to SetActive(false) whenever possible.

This is to reduce the possibility of conflict problems, for example, if there are multiple AudioListners.

GameObjects that have been deactivated should be set back to active when the Unity scene is called.

 

About Asset

The assets referenced by a Unity scene at runtime must be included in the assets managed by Unity, the assets referenced by the scene included in the build, or the assets under Resources, StreamingAssets.

AddressableAsset management performed by UNITE is for UNITE assets, so if your Unity scene references an AddressableAsset, you will need to take additional action.

 

Sample

Below is a sample of this functionality.

A Unity scene and an event that calls the Unity scene are set up.

Please try with a newly created empty project when importing.

 

The import method is shown below.

  1. Download the sample package
  2. Import the sample package
  3. Perform BuildSetting
  4. Perform test play

1. Download

Download sample data from here(https://cdn.tkool.jp/updata/unite/UnityScene_Sample.unitypackage).

The downloaded data is in unitpackage format.

 

2. Import the sample package

Open UNITE and select [Assets]>[Import Package]>[Custom Package...]. Select [Assets]>[Import Package]>[Custom Package...].

mceclip4_12_244d20e610

 

Select the downloaded unitypackage file and the following pop-up window will appear.

Click the “Import” button.

mceclip5_16_cbd74a7ccd

 

After a while, a map called “Unity Scene Calling Test” will be added.

(If the map is not added, please restart the program.)

 

3.BuildSetting

Select [RPG Maker]>[Layout]>[RPG Maker + Unity Editor].

mceclip6_12_efd1e0015b

 

Double-click Assets\UnityScene_Sample\UnityScene\TestScene.unity to open the scene.

mceclip13_9_5a467d5ddb

 

Return to the UNITE window and select the “Build executable file” icon.

mceclip5_17_84df4dbff8

 

Click the “Add Open Scene” button.

If “UnityScene_Sample/UnityScene/TestScene” is added to the scenes included in the build, it is successful.

mceclip8_4_b50c27a2c5

 

Return to the map and set the player's initial position.

mceclip7_7_ffdd34730f

 

Run a test play and action the crystal events.

mceclip11_6_e233cbfeb5

 

If the following scene is displayed, the transition to the Unity scene was successful.

After 5 seconds, it will return to UNITE.

mceclip10_5_93ce19d6d1