Giter Club home page Giter Club logo

unityarkitmultipeerconnectivity's Introduction

[This is no longer maintained]

A cooler implementation can be found https://github.com/Unity-Technologies/arfoundation-samples#arcollaborationdata


UnityARKitMultipeerConnectivity

Using the MultipeerConnectivity framework to share AR world between nearby devices.

This is a reimplementation of Apple's sample code with Unity.

Usage

  1. From Source
    • Clone or download and copy Assets/UnityMultipeerConnectivity, Assets/UnitySwift (and Assets/UnityARKitPlugin) directories to your own project.

Example code

Send ARWorldMap

public static class ARWorldMapSender
{
    public static void SendARWorld()
    {
        var mcSession = UnityMCSessionNativeInterface.GetMcSessionNativeInterface();
        var arSession = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        arSession.GetCurrentWorldMapAsync(worldMap => {
            mcSession.SendToAllPeers(worldMap.SerializeToByteArray());
        });
    }
}

Receive ARWorldMap and relocalize

public class ARWorldMapReceiver : MonoBehaviour
{
    [SerializeField] UnityARCameraManager arCameraManager;

    void Start()
    {
        UnityMCSessionNativeInterface.GetMcSessionNativeInterface().DataReceivedEvent += OnDataReceived;
    }

    void OnDataReceived(byte[] data)
    {
        var worldMap = ARWorldMap.SerializeFromByteArray(data);
        UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true;
        var config = arCameraManager.sessionConfiguration;
        config.worldMap = worldMap;
        UnityARSessionRunOption runOption =
            UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors |
            UnityARSessionRunOption.ARSessionRunOptionResetTracking;
        UnityARSessionNativeInterface.GetARSessionNativeInterface()
            .RunWithConfigAndOptions(config, runOption);
    }
}

And more

See Examples.

Using neuecc/MessagePack-CSharp as serializer in this example. If you want to add or modify MessagePackObject, you need pre-code generation on Unity iOS. For more, see https://github.com/neuecc/MessagePack-CSharp/blob/master/doc/aot.md

note: Generated code path is Assets/Examples/Common/Scripts/Generated/MessagePackGenerated.cs

Requirements

  • Unity 2017.1+
    • Examples are dependent on Unity 2018.2+
  • iOS 12.0+
  • Xcode 10.0+

unityarkitmultipeerconnectivity's People

Contributors

noir-neo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unityarkitmultipeerconnectivity's Issues

Unity2017.2.1f1 error

I found this error when I unzip the project. my unity is 2017.2.1f1 Assets/Plugins/UniRx/Scripts/UnityEngineBridge/UnityEqualityComparer.cs(7,25): error CS0101: The namespace UniRx' already contains a definition for UnityEqualityComparer'

Send byte[] from swift to c#

Hi, noir-neo, You demo is good. But I have some question about how to send byte[] form swift to c#. Your swift code is this:
data.withUnsafeBytes { (ptr: UnsafePointer<UInt8>) in let rawPtr = UnsafeMutableRawPointer(mutating: ptr) DispatchQueue.main.async { self.dataReceived(rawPtr, CInt(data.count)) } }
Can you explain it? As I am using objective-c, I don't know how to write with objective-c. thank you.

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.