skka3134

skka3134

email
telegram

Unity development chain game

Skip the game client and contract client, and write about the interaction between Unity and the contract.

image

  1. In the plugins folder of the Unity project, first create a file with the .jslib extension, and customize the file name.
mergeInto(LibraryManager.library, {

  StartTime: function(){  // StartTime is the method name called by Unity
  	BeginTime();          // BeginTime is the method called to the front-end BeginTime() method
  },
});
  1. In Unity, create a script, add the namespace using System.Runtime.InteropServices; and add the following C# code:
[DllImport("__Internal")]
  private static extern void StartTime();
  1. Call the StartTime() method in Unity, which calls the StartTime() method in jslib.
    function StartTime() {
    }
  1. Package Unity using WebGL, and choose the compression method as uncompressed.

image

You can also use the third-party plugin react-unity-webgl in a React project to load the WebGL resources obtained from the Unity project.

GitHub: https://github.com/skka3134/plantsVsZombines/tree/main

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.