1
0
mirror of https://github.com/xiaopeng12138/MaiDXR.git synced 2024-11-23 19:40:57 +01:00

multiplayer update

This commit is contained in:
xpeng 2022-08-21 04:40:05 +02:00
parent 727ee56fa3
commit 73324dd6c8
12 changed files with 2701 additions and 2008 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,58 @@
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem.XR;
using UnityEngine.XR.Interaction.Toolkit;
public class NetworkPlayer : NetworkBehaviour
{
public Vector2 Player1Position = new Vector2(-1f, 0);
public Vector2 Player2Position = new Vector2(1f, 0);
public override void OnNetworkSpawn()
{
//base.OnNetworkSpawn();
DisableClientInput();
}
private void DisableClientInput()
{
if (!IsOwner && IsClient)
{
var clientMoveProvider = GetComponent<ActionBasedContinuousMoveProvider>();
var clientTurnProvider = GetComponent<ActionBasedContinuousTurnProvider>();
var clientControllers = GetComponentsInChildren<ActionBasedController>();
var clientRays = GetComponentsInChildren<RayManager>();
var clientHead = GetComponentInChildren<TrackedPoseDriver>();
var clientCamera = GetComponentInChildren<Camera>();
var clientAudioListener = GetComponentInChildren<AudioListener>();
var clientLIV = GetComponent<LIV.SDK.Unity.LIV>();
//var clientOVRManager = gameObject.transform.Find("OVRManager").gameObject;
clientCamera.enabled = false;
clientAudioListener.enabled = false;
clientMoveProvider.enabled = false;
clientTurnProvider.enabled = false;
clientHead.enabled = false;
foreach (var ray in clientRays)
{
ray.RaySwitch = false;
}
foreach (var controller in clientControllers)
{
controller.enabled = false;
}
clientLIV.enabled = false;
//clientOVRManager.SetActive(false);
}
}
private void Start()
{
if (IsHost)
{
transform.position = new Vector3(Player1Position.x, transform.position.y, Player1Position.y);
}
else
{
transform.position = new Vector3(Player2Position.x, transform.position.y, Player2Position.y);
}
}
}

50
Assets/Scripts/StartUp.cs Normal file
View File

@ -0,0 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Netcode;
using Unity.Netcode.Transports.UTP;
public class StartUp : MonoBehaviour
{
public List<Transform> PlayerIOs;
public List<Transform> PlayerIOsOpposite;
public Transform Player1Anchor;
public Transform Player2Anchor;
public Transform SelectButton;
bool isHost = true;
string hostIP = "127.0.0.1";
int hostPort = 7777;
void Start()
{
if (JsonConfig.HasKey("IsHost")) isHost = JsonConfig.GetBoolean("IsHost");
else JsonConfig.SetBoolean("IsHost", isHost);
if (JsonConfig.HasKey("HostIP")) hostIP = JsonConfig.GetString("HostIP");
else JsonConfig.SetString("HostIP", hostIP);
if (JsonConfig.HasKey("HostPort")) hostPort = JsonConfig.GetInt("HostPort");
else JsonConfig.SetInt("HostPort", hostPort);
if (!NetworkManager.Singleton.IsClient && !NetworkManager.Singleton.IsServer)
{
if (isHost)
{
NetworkManager.Singleton.StartHost();
foreach (var IO in PlayerIOs)
IO.position = new Vector3(Player1Anchor.position.x, IO.position.y, IO.position.z);
foreach (var IO in PlayerIOsOpposite)
IO.position = new Vector3(Player2Anchor.position.x, IO.position.y, IO.position.z);
}
else
{
NetworkManager.Singleton.StartClient();
foreach (var IO in PlayerIOs)
IO.position = new Vector3(Player2Anchor.position.x, IO.position.y, IO.position.z);
foreach (var IO in PlayerIOsOpposite)
IO.position = new Vector3(Player1Anchor.position.x, IO.position.y, IO.position.z);
SelectButton.localScale = new Vector3(SelectButton.localScale.x * -1, SelectButton.localScale.y, SelectButton.localScale.z);
}
GetComponent<UnityTransport>().SetConnectionData(hostIP, (ushort)hostPort);
}
}
}

View File

@ -0,0 +1 @@
{"Keys":["com.unity.services.qos.version","com.unity.services.lobby.version","com.unity.services.core.version","com.unity.services.authentication.version","com.unity.services.relay.version"],"Values":[{"m_Value":"1.0.0","m_IsReadOnly":true},{"m_Value":"1.0.0-pre.6","m_IsReadOnly":true},{"m_Value":"1.4.0","m_IsReadOnly":true},{"m_Value":"2.0.0","m_IsReadOnly":true},{"m_Value":"1.0.2","m_IsReadOnly":true}]}

0
InitCodeMarker Normal file
View File

View File

@ -1,20 +1,20 @@
{
"dependencies": {
"com.hecomi.uwindowcapture": "https://github.com/hecomi/uWindowCapture.git#upm",
"com.unity.collab-proxy": "1.15.16",
"com.unity.ide.rider": "3.0.13",
"com.unity.ide.visualstudio": "2.0.14",
"com.unity.ide.vscode": "1.2.5",
"com.unity.multiplayer.samples.coop": "https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop.git?path=/Packages/com.unity.multiplayer.samples.coop#main",
"com.unity.netcode.gameobjects": "1.0.0",
"com.unity.render-pipelines.universal": "12.1.6",
"com.unity.test-framework": "1.1.31",
"com.unity.test-framework": "2.0.1-pre.18",
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.6.4",
"com.unity.ugui": "1.0.0",
"com.unity.visualscripting": "1.7.6",
"com.unity.xr.interaction.toolkit": "2.1.1",
"com.unity.xr.management": "4.2.1",
"com.unity.xr.oculus": "3.0.2",
"com.unity.xr.openxr": "1.4.2",
"com.veriorpies.parrelsync": "https://github.com/VeriorPies/ParrelSync.git?path=/ParrelSync",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",

View File

@ -8,37 +8,36 @@
"hash": "0412fe09e11d3720197707a935f8114cc2454639"
},
"com.unity.burst": {
"version": "1.6.5",
"depth": 1,
"version": "1.6.6",
"depth": 2,
"source": "registry",
"dependencies": {
"com.unity.mathematics": "1.2.1"
},
"url": "https://packages.unity.com"
},
"com.unity.collab-proxy": {
"version": "1.15.16",
"depth": 0,
"com.unity.collections": {
"version": "1.2.4",
"depth": 2,
"source": "registry",
"dependencies": {
"com.unity.services.core": "1.0.1"
"com.unity.burst": "1.6.6",
"com.unity.test-framework": "1.1.31"
},
"url": "https://packages.unity.com"
},
"com.unity.ext.nunit": {
"version": "1.0.6",
"depth": 1,
"com.unity.editorcoroutines": {
"version": "1.0.0",
"depth": 2,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "3.0.13",
"depth": 0,
"com.unity.ext.nunit": {
"version": "2.0.2",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.ext.nunit": "1.0.6"
},
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.ide.visualstudio": {
@ -66,6 +65,16 @@
},
"url": "https://packages.unity.com"
},
"com.unity.learn.iet-framework": {
"version": "2.2.1",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.editorcoroutines": "1.0.0",
"com.unity.settings-manager": "1.0.3"
},
"url": "https://packages.unity.com"
},
"com.unity.mathematics": {
"version": "1.2.6",
"depth": 1,
@ -73,6 +82,50 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.multiplayer.samples.coop": {
"version": "https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop.git?path=/Packages/com.unity.multiplayer.samples.coop#main",
"depth": 0,
"source": "git",
"dependencies": {
"com.unity.learn.iet-framework": "1.2.1",
"com.unity.multiplayer.tools": "1.0.0-pre.7",
"com.unity.netcode.gameobjects": "1.0.0-pre.10",
"com.unity.services.authentication": "1.0.0-pre.4",
"com.unity.services.lobby": "1.0.0-pre.6",
"com.unity.services.relay": "1.0.2"
},
"hash": "55bc606b0ae04e2368bdaeda903440570bd44900"
},
"com.unity.multiplayer.tools": {
"version": "1.0.0-pre.7",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.profiling.core": "1.0.0-pre.1",
"com.unity.nuget.newtonsoft-json": "2.0.0",
"com.unity.nuget.mono-cecil": "1.10.1",
"com.unity.collections": "1.1.0",
"com.unity.modules.uielements": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.netcode.gameobjects": {
"version": "1.0.0",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.nuget.mono-cecil": "1.10.1",
"com.unity.transport": "1.1.0"
},
"url": "https://packages.unity.com"
},
"com.unity.nuget.mono-cecil": {
"version": "1.10.1",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.nuget.newtonsoft-json": {
"version": "3.0.2",
"depth": 2,
@ -80,6 +133,13 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.profiling.core": {
"version": "1.0.2",
"depth": 2,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.render-pipelines.core": {
"version": "12.1.6",
"depth": 1,
@ -108,9 +168,20 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.services.authentication": {
"version": "2.0.0",
"depth": 2,
"source": "registry",
"dependencies": {
"com.unity.nuget.newtonsoft-json": "3.0.2",
"com.unity.services.core": "1.3.1",
"com.unity.modules.unitywebrequest": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.services.core": {
"version": "1.3.1",
"depth": 1,
"version": "1.4.0",
"depth": 2,
"source": "registry",
"dependencies": {
"com.unity.modules.unitywebrequest": "1.0.0",
@ -119,6 +190,60 @@
},
"url": "https://packages.unity.com"
},
"com.unity.services.lobby": {
"version": "1.0.0-pre.6",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.services.core": "1.1.0-pre.10",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.unitywebrequesttexture": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.nuget.newtonsoft-json": "2.0.0",
"com.unity.services.authentication": "1.0.0-pre.6"
},
"url": "https://packages.unity.com"
},
"com.unity.services.qos": {
"version": "1.0.0",
"depth": 2,
"source": "registry",
"dependencies": {
"com.unity.services.core": "1.3.2",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.nuget.newtonsoft-json": "3.0.1",
"com.unity.services.authentication": "2.0.0",
"com.unity.collections": "1.2.3"
},
"url": "https://packages.unity.com"
},
"com.unity.services.relay": {
"version": "1.0.2",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.services.core": "1.4.0",
"com.unity.services.authentication": "2.0.0",
"com.unity.services.qos": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.unitywebrequesttexture": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.nuget.newtonsoft-json": "3.0.1",
"com.unity.transport": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.settings-manager": {
"version": "1.0.3",
"depth": 2,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.shadergraph": {
"version": "12.1.6",
"depth": 1,
@ -138,11 +263,11 @@
"url": "https://packages.unity.com"
},
"com.unity.test-framework": {
"version": "1.1.31",
"version": "2.0.1-pre.18",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.ext.nunit": "1.0.6",
"com.unity.ext.nunit": "2.0.2",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
},
@ -169,6 +294,17 @@
},
"url": "https://packages.unity.com"
},
"com.unity.transport": {
"version": "1.1.0",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.collections": "1.2.4",
"com.unity.burst": "1.6.6",
"com.unity.mathematics": "1.2.6"
},
"url": "https://packages.unity.com"
},
"com.unity.ugui": {
"version": "1.0.0",
"depth": 0,
@ -178,16 +314,6 @@
"com.unity.modules.imgui": "1.0.0"
}
},
"com.unity.visualscripting": {
"version": "1.7.6",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.ugui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.core-utils": {
"version": "2.0.0",
"depth": 1,
@ -255,6 +381,13 @@
},
"url": "https://packages.unity.com"
},
"com.veriorpies.parrelsync": {
"version": "https://github.com/VeriorPies/ParrelSync.git?path=/ParrelSync",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "f45424822189ebd875d864a17d7f03b72eafbff7"
},
"com.unity.modules.ai": {
"version": "1.0.0",
"depth": 0,

View File

@ -0,0 +1,7 @@
{
"m_Name": "Settings",
"m_Path": "ProjectSettings/Packages/com.unity.learn.iet-framework/Settings.json",
"m_Dictionary": {
"m_DictionaryValues": []
}
}

View File

@ -89,7 +89,7 @@ PlayerSettings:
submitAnalytics: 1
usePlayerLog: 1
bakeCollisionMeshes: 1
forceSingleInstance: 1
forceSingleInstance: 0
useFlipModelSwapchain: 1
resizableWindow: 1
useMacAppStoreValidation: 0
@ -137,7 +137,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 0.8.1
bundleVersion: 0.9.0
preloadedAssets:
- {fileID: 0}
- {fileID: 0}
@ -170,6 +170,10 @@ PlayerSettings:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 6536100391545742739, guid: 55d1ec7a4296de343b6d3bb6f9a19731, type: 2}
- {fileID: -6018045015233401694, guid: 3999ab811e936714280a476b3a032d86, type: 2}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1

View File

@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 61
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a287be6c49135cd4f9b2b8666c39d999, type: 3}
m_Name:
m_EditorClassIdentifier:
assetDefaultFramerate: 60
m_DefaultFrameRate: 60