Giter Site home page Giter Site logo

pusher-websocket-unity's Introduction

Pusher Channels Unity Client Library

This library packages the official WebSocket .NET SDK for Pusher Channels as a .unitypackage and an UPM package to make it easier to use in Unity projects. For API documentation, see the pusher-websocket-dotnet README.

Repository Structure

  • BaseProject a Unity Base project which demonstrates how to integrate Pusher Channels with Unity
  • Builds a build environment for the PusherWebsocketUnity unitypackage and the Unity Package Manager (UPM) release
  • Examples example projects that combines Unity and Pusher Channels

Unity Versions Support

  • Unity 2018.1

    • Unity 2018.1.0
    • Unity 2018.1.2
    • Unity 2018.1.3
  • All Unity 2018.2.x >= 2018.2.5f1

  • All Unity 2018.3.x

  • All Unity 2018.4.x

  • All Unity 2019.1.x

  • All Unity 2019.2.x

Getting Started

  1. Create a Pusher Channels app
  2. Install the Pusher Channels Unity Client Library via unitypackage or via Unity Package Manager (UPM)
  3. Add PusherManager and run the game

1 Create a Pusher Channels app

1.1 - Create a Pusher Channels app at https://pusher.com/channels

2 Install

2.1 Install it via unitypackage

2.1.1 - Download the latest PusherWebsocketUnity-1.1.2+200211.unitypackage from releases
2.1.2 - Open a new/existing Unity project and make sure it is being opened by a supported version of Unity
2.1.3 - [if your Unity version is 2018.x.x] Make sure that under Edit -> Project Settings -> Player the Configuration -> Scripting Runtime Version is set to .NET 4.x Equivalent.
2.1.4 - Click on Assets -> Import Package -> Custom Package..., find and select the PusherWebsocketUnity-1.1.2+200211.unitypackage and click Import on the Import Unity Package window.

2.2 Install it via Unity Package Manager (UPM)

WARNING this method works only if your version of Unity is 2018.3.x or greater, if you don't satisfy that, use the unitypackage method.
2.2.1 - [if your Unity version is 2018.x.x] Make sure that under Edit -> Project Settings -> Player the Configuration -> Scripting Runtime Version is set to .NET 4.x Equivalent.
2.2.2 - Open Packages/manifest.json with your favourite editor and add the following in your dependencies (make sure to respect JSON commas):

{
 "dependencies": {
  ...
  "com.pusher.pusherwebsocketunity": "https://github.com/pusher/pusher-websocket-unity.git#1.1.2+200211"
 }
}

2.2.3 - Now Unity should auto resolve dependencies and fetch the newly defined package.

3 Add PusherManager and run the game

3.1 - Copy the sample PusherManager.cs into your project's Assets folder and add your keys as values for private const string APP_KEY and private const string APP_CLUSTER obtained when you created the Pusher Channels app in the dashboard.
3.2 - Create a new GameObject, by going on GameObject -> Create Empty. Drag the PusherManager.cs script onto the GameObject Inspector to set it as a script for the object.
3.3 - Save and click Play to start the game in Unity.
3.4 - Verify that Connection state changed, Connected, Subscribed is logged in the Console tab.
3.5 - You can now customize the channel name (by default is "my-channel") and events to bind to (by default is "my-event") in the PusherManager.cs script.

Update this package

Update the version of .unitypackage

To update the version of the .unitypackage you can delete the Assets/PusherWebsocketUnity directory and repeat the install steps.

Update the version of Unity Package Manager (UPM) package

To update the version of com.pusher.pusherwebsocketunity you just need to check the available versions in releases and change the package version in the Packages/manifest.json, like so:

From:

"com.pusher.pusherwebsocketunity": "https://github.com/pusher/pusher-websocket-unity.git#0.0.0+000000"

To:

"com.pusher.pusherwebsocketunity": "https://github.com/pusher/pusher-websocket-unity.git#1.1.2+200211"

Unity Platforms Support

Supported Platforms:

The supported platforms should be the ones that can be targeted by Unity. Thus far we tested this, and can confirm the library works, on:

  • Windows
  • MacOS
  • Android
  • iOS

Unsupported Platforms:

  • WebGL: due to incompatibility with Websockets (more here under the "No direct socket access" section)

Known Issues

This library is INCOMPATIBLE with 2018.1.4 <= Unity <= 2018.2.4 due to a bug in the Unity engine that prevents WebSocket4Net (one of the dependencies) to work correctly.

Credits

pusher-websocket-unity's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.