Skip to content
/ vuenity Public

A Vue.js wrapper with communications for WebGL Unity games.

License

Notifications You must be signed in to change notification settings

Thooto/vuenity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vuenity

A Vue.js wrapper component for Unity WebGL player based on react-unity-webgl, with in and out communications.

Installation

npm install --save vuenity

Usage

<template>
    <vuenity :unity-content="unityContent"></vuenity>
    <p>{{ message }}</p>
</template>

<script>
    import Vuenity from "vuenity";

    export default {
        components: { Vuenity },

        data() {
            return {
                unityContent: new UnityContent(
                    "Build/your_unity_project.json",
                    "Build/UnityLoader.js"
                ),
                message: undefined
            };
        },

        mounted() {
            this.unityContent.on("NiceWords", message => {
                this.message = message;
            });

            this.unityContent.message("HelloWorld", "Some nice words");
        }
    };
</script>

Build folder should be in your public folder.

In your Unity project, under Assets/Plugins/WebGL/ (or anywhere else in assets) create a VuePlugin.jslib with:

mergeInto(LibraryManager.library,
    NiceWords: function(message) {
        VueUnityWebGL.NiceWords(message);
    }
});

And finally, in one of your C# scripts:

using UnityEngine;
using System.Runtime.InteropServices;

public class GameController : MonoBehaviour {
    [DllImport("__Internal")]
    private static extern void NiceWords(string message);
    
    public void NiceWords (string message) {
        NiceWords(message);
    }
}

About

A Vue.js wrapper with communications for WebGL Unity games.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published