skka3134

skka3134

email
telegram

Unity Game Development

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 the file name can be customized.
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 with WebGL, and choose the compression method as uncompressed.

image

You can also use the third-party plugin react-unity-webgl in this project to load WebGL resources obtained from the Unity project in a React 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.