From bcdf7f7bf5e05e6c88314eb8fd57c55de6a08638 Mon Sep 17 00:00:00 2001 From: "M. Fatih MAR" Date: Fri, 3 Sep 2021 14:39:16 +0100 Subject: [PATCH] feat: add bootstrap sample to package --- com.unity.netcode.gameobjects/Samples.meta | 8 + .../Samples/Bootstrap.meta | 8 + .../Samples/Bootstrap/.sample.json | 4 + .../Samples/Bootstrap/Prefabs.meta | 8 + .../Bootstrap/Prefabs/BootstrapPlayer.prefab | 155 +++++++ .../Prefabs/BootstrapPlayer.prefab.meta | 7 + .../Samples/Bootstrap/Scenes.meta | 8 + .../Samples/Bootstrap/Scenes/Bootstrap.unity | 402 ++++++++++++++++++ .../Bootstrap/Scenes/Bootstrap.unity.meta | 7 + .../Samples/Bootstrap/Scripts.meta | 8 + .../Bootstrap/Scripts/Bootstrap.asmdef | 8 + .../Bootstrap/Scripts/Bootstrap.asmdef.meta | 7 + .../Bootstrap/Scripts/BootstrapManager.cs | 59 +++ .../Scripts/BootstrapManager.cs.meta | 11 + .../Bootstrap/Scripts/BootstrapPlayer.cs | 32 ++ .../Bootstrap/Scripts/BootstrapPlayer.cs.meta | 11 + 16 files changed, 743 insertions(+) create mode 100644 com.unity.netcode.gameobjects/Samples.meta create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap.meta create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap/.sample.json create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap/Prefabs.meta create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap/Prefabs/BootstrapPlayer.prefab create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap/Prefabs/BootstrapPlayer.prefab.meta create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap/Scenes.meta create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap/Scenes/Bootstrap.unity create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap/Scenes/Bootstrap.unity.meta create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts.meta create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/Bootstrap.asmdef create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/Bootstrap.asmdef.meta create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapManager.cs create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapManager.cs.meta create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapPlayer.cs create mode 100644 com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapPlayer.cs.meta diff --git a/com.unity.netcode.gameobjects/Samples.meta b/com.unity.netcode.gameobjects/Samples.meta new file mode 100644 index 0000000000..5a5e3b286a --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d48e3f2a8be084f8aae6470ef87063d9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap.meta b/com.unity.netcode.gameobjects/Samples/Bootstrap.meta new file mode 100644 index 0000000000..3d32b89c29 --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72c642b5eadc8414782ae0e0e2703037 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap/.sample.json b/com.unity.netcode.gameobjects/Samples/Bootstrap/.sample.json new file mode 100644 index 0000000000..c096af92bf --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap/.sample.json @@ -0,0 +1,4 @@ +{ + "displayName":"Bootstrap", + "description": "A lightweight sample to get started" +} \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap/Prefabs.meta b/com.unity.netcode.gameobjects/Samples/Bootstrap/Prefabs.meta new file mode 100644 index 0000000000..75f957e40d --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap/Prefabs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ca52adaafe314f728cfd0fd9c0e92fb +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap/Prefabs/BootstrapPlayer.prefab b/com.unity.netcode.gameobjects/Samples/Bootstrap/Prefabs/BootstrapPlayer.prefab new file mode 100644 index 0000000000..5b7b44713f --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap/Prefabs/BootstrapPlayer.prefab @@ -0,0 +1,155 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &3439633038736912633 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3439633038736913158} + - component: {fileID: 3439633038736913157} + - component: {fileID: 3439633038736913156} + - component: {fileID: 3439633038736912635} + - component: {fileID: 3439633038736912634} + - component: {fileID: 2776227185612554462} + - component: {fileID: 6046305264893698362} + m_Layer: 0 + m_Name: BootstrapPlayer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3439633038736913158 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3439633038736912633} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &3439633038736913157 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3439633038736912633} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &3439633038736913156 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3439633038736912633} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!135 &3439633038736912635 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3439633038736912633} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &3439633038736912634 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3439633038736912633} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} + m_Name: + m_EditorClassIdentifier: + GlobalObjectIdHash: 951099334 + AlwaysReplicateAsRoot: 0 + DontDestroyWithOwner: 0 + AutoObjectParentSync: 1 +--- !u!114 &2776227185612554462 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3439633038736912633} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3} + m_Name: + m_EditorClassIdentifier: + SyncPositionX: 1 + SyncPositionY: 1 + SyncPositionZ: 1 + SyncRotAngleX: 1 + SyncRotAngleY: 1 + SyncRotAngleZ: 1 + SyncScaleX: 1 + SyncScaleY: 1 + SyncScaleZ: 1 + PositionThreshold: 0 + RotAngleThreshold: 0 + ScaleThreshold: 0 + InLocalSpace: 0 + Interpolate: 1 + FixedSendsPerSecond: 30 +--- !u!114 &6046305264893698362 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3439633038736912633} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1aaab5fe31dc3423e89747f088d7bcaf, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap/Prefabs/BootstrapPlayer.prefab.meta b/com.unity.netcode.gameobjects/Samples/Bootstrap/Prefabs/BootstrapPlayer.prefab.meta new file mode 100644 index 0000000000..1529432024 --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap/Prefabs/BootstrapPlayer.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 398aad09d8b2a47eba664a076763cdcc +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap/Scenes.meta b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scenes.meta new file mode 100644 index 0000000000..7091e64398 --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scenes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 68b3c153b391b40219154be17a973085 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap/Scenes/Bootstrap.unity b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scenes/Bootstrap.unity new file mode 100644 index 0000000000..48f926503a --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scenes/Bootstrap.unity @@ -0,0 +1,402 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641275, b: 0.5748172, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &1114774665 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1114774669} + - component: {fileID: 1114774668} + - component: {fileID: 1114774667} + - component: {fileID: 1114774666} + m_Layer: 0 + m_Name: BootstrapManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1114774666 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1114774665} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b84c2d8dfe509a34fb59e2b81f8e1319, type: 3} + m_Name: + m_EditorClassIdentifier: + MessageBufferSize: 5120 + MaxConnections: 100 + MaxSentMessageQueueSize: 128 + ConnectAddress: 127.0.0.1 + ConnectPort: 7777 + ServerListenPort: 7777 + MessageSendMode: 0 +--- !u!114 &1114774667 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1114774665} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 593a2fe42fa9d37498c96f9a383b6521, type: 3} + m_Name: + m_EditorClassIdentifier: + DontDestroy: 1 + RunInBackground: 1 + LogLevel: 1 + NetworkConfig: + ProtocolVersion: 0 + NetworkTransport: {fileID: 1114774666} + PlayerPrefab: {fileID: 3439633038736912633, guid: 398aad09d8b2a47eba664a076763cdcc, + type: 3} + NetworkPrefabs: [] + TickRate: 30 + ClientConnectionBufferTimeout: 10 + ConnectionApproval: 0 + ConnectionData: + EnableTimeResync: 0 + TimeResyncInterval: 30 + EnableNetworkVariable: 1 + EnsureNetworkVariableLengthSafety: 0 + EnableSceneManagement: 1 + ForceSamePrefabs: 1 + RecycleNetworkIds: 1 + NetworkIdRecycleDelay: 120 + RpcHashSize: 0 + LoadSceneTimeOut: 120 + MessageBufferTimeout: 20 + EnableNetworkLogs: 1 +--- !u!114 &1114774668 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1114774665} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5fed568ebf6c14b11928f16219b5675b, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1114774669 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1114774665} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &2011451347 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2011451350} + - component: {fileID: 2011451349} + - component: {fileID: 2011451348} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &2011451348 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2011451347} + m_Enabled: 1 +--- !u!20 &2011451349 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2011451347} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &2011451350 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2011451347} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &2056444517 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2056444519} + - component: {fileID: 2056444518} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &2056444518 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2056444517} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &2056444519 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2056444517} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap/Scenes/Bootstrap.unity.meta b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scenes/Bootstrap.unity.meta new file mode 100644 index 0000000000..e5c1d3f87a --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scenes/Bootstrap.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7a6e122bd2b01425989087a299b6bb93 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts.meta b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts.meta new file mode 100644 index 0000000000..92210962ab --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5575d489edb9d4c8392de6bad7982f54 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/Bootstrap.asmdef b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/Bootstrap.asmdef new file mode 100644 index 0000000000..c236cf22d2 --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/Bootstrap.asmdef @@ -0,0 +1,8 @@ +{ + "name": "Bootstrap", + "rootNamespace": "Unity.Netcode.Samples", + "references": [ + "Unity.Netcode.Runtime", + "Unity.Netcode.Prototyping" + ] +} diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/Bootstrap.asmdef.meta b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/Bootstrap.asmdef.meta new file mode 100644 index 0000000000..ebc1bc4874 --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/Bootstrap.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 219b171db79434558b442780da267dab +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapManager.cs b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapManager.cs new file mode 100644 index 0000000000..fd1d227fef --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapManager.cs @@ -0,0 +1,59 @@ +using UnityEngine; + +namespace Unity.Netcode.Samples +{ + /// + /// Class to display helper buttons and status labels on the GUI, as well as buttons to start host/client/server. + /// Once a connection has been established to the server, the local player can be teleported to random positions via a GUI button. + /// + public class BootstrapManager : MonoBehaviour + { + private void OnGUI() + { + GUILayout.BeginArea(new Rect(10, 10, 300, 300)); + + var networkManager = NetworkManager.Singleton; + if (!networkManager.IsClient && !networkManager.IsServer) + { + if (GUILayout.Button("Host")) + { + networkManager.StartHost(); + } + + if (GUILayout.Button("Client")) + { + networkManager.StartClient(); + } + + if (GUILayout.Button("Server")) + { + networkManager.StartServer(); + } + } + else + { + GUILayout.Label($"Mode: {(networkManager.IsHost ? "Host" : networkManager.IsServer ? "Server" : "Client")}"); + + // "Random Teleport" button will only be shown to clients + if (networkManager.IsClient) + { + if (GUILayout.Button("Random Teleport")) + { + // Get the local `NetworkClient` by `LocalClientId` + if (networkManager.ConnectedClients.TryGetValue(networkManager.LocalClientId, out var networkedClient)) + { + // Get `BootstrapPlayer` component from the player's `PlayerObject` + if (networkedClient.PlayerObject.TryGetComponent(out BootstrapPlayer bootstrapPlayer)) + { + // Invoke a `ServerRpc` from client-side to teleport player to a random position on the server-side + bootstrapPlayer.RandomTeleportServerRpc(); + } + } + } + } + } + + GUILayout.EndArea(); + } + } +} diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapManager.cs.meta b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapManager.cs.meta new file mode 100644 index 0000000000..07509d10c0 --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5fed568ebf6c14b11928f16219b5675b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapPlayer.cs b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapPlayer.cs new file mode 100644 index 0000000000..af68e5037a --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapPlayer.cs @@ -0,0 +1,32 @@ +using UnityEngine; + +namespace Unity.Netcode.Samples +{ + /// + /// Component attached to the "Player Prefab" on the `NetworkManager`. + /// + public class BootstrapPlayer : NetworkBehaviour + { + /// + /// If this method is invoked on the client instance of this player, it will invoke a `ServerRpc` on the server-side. + /// If this method is invoked on the server instance of this player, it will teleport player to a random position. + /// + /// + /// Since a `NetworkTransform` component is attached to this player, and the authority on that component is set to "Server", + /// this transform's position modification can only be performed on the server, where it will then be replicated down to all clients through `NetworkTransform`. + /// + [ServerRpc] + public void RandomTeleportServerRpc() + { + var oldPosition = transform.position; + transform.position = GetRandomPositionOnXYPlane(); + var newPosition = transform.position; + print($"{nameof(RandomTeleportServerRpc)}() -> {nameof(OwnerClientId)}: {OwnerClientId} --- {nameof(oldPosition)}: {oldPosition} --- {nameof(newPosition)}: {newPosition}"); + } + + private static Vector3 GetRandomPositionOnXYPlane() + { + return new Vector3(Random.Range(-3f, 3f), Random.Range(-3f, 3f), 0f); + } + } +} diff --git a/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapPlayer.cs.meta b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapPlayer.cs.meta new file mode 100644 index 0000000000..f87f1ef9d7 --- /dev/null +++ b/com.unity.netcode.gameobjects/Samples/Bootstrap/Scripts/BootstrapPlayer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1aaab5fe31dc3423e89747f088d7bcaf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: