mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
TestNT Example
This commit is contained in:
parent
505a8eca43
commit
d20bd1186a
8
Assets/Mirror/Examples/TestNT.meta
Normal file
8
Assets/Mirror/Examples/TestNT.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12608f50052323d4dadd0dfc568e0c62
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Mirror/Examples/TestNT/Materials.meta
Normal file
8
Assets/Mirror/Examples/TestNT/Materials.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86c33cc7aaee4df498ffc7ca047d8abc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Assets/Mirror/Examples/TestNT/Materials/Ice.physicMaterial
Normal file
14
Assets/Mirror/Examples/TestNT/Materials/Ice.physicMaterial
Normal file
@ -0,0 +1,14 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!134 &13400000
|
||||
PhysicMaterial:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Ice
|
||||
dynamicFriction: 0
|
||||
staticFriction: 0
|
||||
bounciness: 0.8
|
||||
frictionCombine: 0
|
||||
bounceCombine: 0
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3ac683db06890b49a15dd5009dbd6e8
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 13400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
80
Assets/Mirror/Examples/TestNT/Materials/Player.mat
Normal file
80
Assets/Mirror/Examples/TestNT/Materials/Player.mat
Normal file
@ -0,0 +1,80 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Player
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
8
Assets/Mirror/Examples/TestNT/Materials/Player.mat.meta
Normal file
8
Assets/Mirror/Examples/TestNT/Materials/Player.mat.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcc202df238253d4db8a8bda20988e76
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Mirror/Examples/TestNT/Prefabs.meta
Normal file
8
Assets/Mirror/Examples/TestNT/Prefabs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 213023a41086b734a9a9e4b5f79717af
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1346
Assets/Mirror/Examples/TestNT/Prefabs/Player.prefab
Normal file
1346
Assets/Mirror/Examples/TestNT/Prefabs/Player.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Mirror/Examples/TestNT/Prefabs/Player.prefab.meta
Normal file
7
Assets/Mirror/Examples/TestNT/Prefabs/Player.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10f39bef276942448bfdfba062b6b6e0
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Mirror/Examples/TestNT/Scenes.meta
Normal file
8
Assets/Mirror/Examples/TestNT/Scenes.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2243574be6b2d8c4f83352c563a5e923
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3400
Assets/Mirror/Examples/TestNT/Scenes/OfflineKcp.unity
Normal file
3400
Assets/Mirror/Examples/TestNT/Scenes/OfflineKcp.unity
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67f4331da875e0449896cd8c88e3ec34
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3400
Assets/Mirror/Examples/TestNT/Scenes/OfflineWeb.unity
Normal file
3400
Assets/Mirror/Examples/TestNT/Scenes/OfflineWeb.unity
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 648e8e3c315379146986361bce3a13c9
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Mirror/Examples/TestNT/Scenes/Online.meta
Normal file
8
Assets/Mirror/Examples/TestNT/Scenes/Online.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48771fe572450154b82c2293c6a4dd5c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
695
Assets/Mirror/Examples/TestNT/Scenes/Online.unity
Normal file
695
Assets/Mirror/Examples/TestNT/Scenes/Online.unity
Normal file
@ -0,0 +1,695 @@
|
||||
%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.18028378, g: 0.22571412, b: 0.30692285, 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 &287438848
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 287438851}
|
||||
- component: {fileID: 287438850}
|
||||
- component: {fileID: 287438849}
|
||||
m_Layer: 0
|
||||
m_Name: Terrain
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 2147483647
|
||||
m_IsActive: 1
|
||||
--- !u!154 &287438849
|
||||
TerrainCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 287438848}
|
||||
m_Material: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_TerrainData: {fileID: 15600000, guid: 49ea6cc998ca79b449bff823dd956d4b, type: 2}
|
||||
m_EnableTreeColliders: 1
|
||||
--- !u!218 &287438850
|
||||
Terrain:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 287438848}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 6
|
||||
m_TerrainData: {fileID: 15600000, guid: 49ea6cc998ca79b449bff823dd956d4b, type: 2}
|
||||
m_TreeDistance: 5000
|
||||
m_TreeBillboardDistance: 50
|
||||
m_TreeCrossFadeLength: 5
|
||||
m_TreeMaximumFullLODCount: 50
|
||||
m_DetailObjectDistance: 80
|
||||
m_DetailObjectDensity: 1
|
||||
m_HeightmapPixelError: 5
|
||||
m_SplatMapDistance: 1000
|
||||
m_HeightmapMaximumLOD: 0
|
||||
m_ShadowCastingMode: 0
|
||||
m_DrawHeightmap: 1
|
||||
m_DrawInstanced: 0
|
||||
m_DrawTreesAndFoliage: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_ReflectionProbeUsage: 0
|
||||
m_MaterialTemplate: {fileID: 10652, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_BakeLightProbesForTrees: 1
|
||||
m_PreserveTreePrototypeLayers: 0
|
||||
m_DeringLightProbesForTrees: 1
|
||||
m_ScaleInLightmap: 0.0256
|
||||
m_LightmapParameters: {fileID: 15203, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_GroupingID: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_AllowAutoConnect: 1
|
||||
--- !u!4 &287438851
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 287438848}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -500, y: 0, z: -500}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &328239415
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 328239418}
|
||||
- component: {fileID: 328239417}
|
||||
- component: {fileID: 328239416}
|
||||
m_Layer: 0
|
||||
m_Name: EventSystem
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &328239416
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 328239415}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_SendPointerHoverToParent: 1
|
||||
m_HorizontalAxis: Horizontal
|
||||
m_VerticalAxis: Vertical
|
||||
m_SubmitButton: Submit
|
||||
m_CancelButton: Cancel
|
||||
m_InputActionsPerSecond: 10
|
||||
m_RepeatDelay: 0.5
|
||||
m_ForceModuleActive: 0
|
||||
--- !u!114 &328239417
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 328239415}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_FirstSelected: {fileID: 0}
|
||||
m_sendNavigationEvents: 1
|
||||
m_DragThreshold: 10
|
||||
--- !u!4 &328239418
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 328239415}
|
||||
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_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &397708574
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 397708578}
|
||||
- component: {fileID: 397708577}
|
||||
- component: {fileID: 397708576}
|
||||
- component: {fileID: 397708575}
|
||||
- component: {fileID: 397708579}
|
||||
m_Layer: 0
|
||||
m_Name: Ramp
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
--- !u!65 &397708575
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 397708574}
|
||||
m_Material: {fileID: 13400000, guid: c3ac683db06890b49a15dd5009dbd6e8, type: 2}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &397708576
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 397708574}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
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!33 &397708577
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 397708574}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &397708578
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 397708574}
|
||||
m_LocalRotation: {x: -0.21643952, y: 0, z: 0, w: 0.97629607}
|
||||
m_LocalPosition: {x: -2, y: 1.2, z: 8}
|
||||
m_LocalScale: {x: 3, y: 0.1, z: 6}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 5
|
||||
m_LocalEulerAnglesHint: {x: -25, y: 0, z: 0}
|
||||
--- !u!54 &397708579
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 397708574}
|
||||
serializedVersion: 2
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 1
|
||||
m_IsKinematic: 1
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
||||
--- !u!1 &1890185205
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1890185207}
|
||||
- component: {fileID: 1890185206}
|
||||
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 &1890185206
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1890185205}
|
||||
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 &1890185207
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1890185205}
|
||||
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_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||
--- !u!1 &2013102099
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2013102102}
|
||||
- component: {fileID: 2013102101}
|
||||
- component: {fileID: 2013102100}
|
||||
- component: {fileID: 2013102103}
|
||||
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 &2013102100
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2013102099}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &2013102101
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2013102099}
|
||||
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 &2013102102
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2013102099}
|
||||
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_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &2013102103
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2013102099}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 33ffe1ccc0a52e74a8d646444ce42409, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
cameraPanSpeed: 0.2
|
||||
cameraZoomSpeed: 5
|
||||
cameraRotateSpeed: 3
|
||||
rotationAxes: 0
|
||||
--- !u!1 &2122508970
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2122508974}
|
||||
- component: {fileID: 2122508973}
|
||||
- component: {fileID: 2122508972}
|
||||
- component: {fileID: 2122508971}
|
||||
- component: {fileID: 2122508975}
|
||||
m_Layer: 0
|
||||
m_Name: Capsule
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
--- !u!136 &2122508971
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2122508970}
|
||||
m_Material: {fileID: 13400000, guid: c3ac683db06890b49a15dd5009dbd6e8, type: 2}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
m_Radius: 0.5
|
||||
m_Height: 2
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &2122508972
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2122508970}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
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!33 &2122508973
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2122508970}
|
||||
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &2122508974
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2122508970}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!54 &2122508975
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2122508970}
|
||||
serializedVersion: 2
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 1
|
||||
m_IsKinematic: 1
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
7
Assets/Mirror/Examples/TestNT/Scenes/Online.unity.meta
Normal file
7
Assets/Mirror/Examples/TestNT/Scenes/Online.unity.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 860cbde762340e2439abcc2c62efda5f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,22 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1953259897 &8574412962073106934
|
||||
TerrainLayer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: BaseLayer
|
||||
m_DiffuseTexture: {fileID: 10309, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_NormalMapTexture: {fileID: 0}
|
||||
m_MaskMapTexture: {fileID: 0}
|
||||
m_TileSize: {x: 2, y: 2}
|
||||
m_TileOffset: {x: 0, y: 0}
|
||||
m_Specular: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_Metallic: 0
|
||||
m_Smoothness: 0
|
||||
m_NormalScale: 1
|
||||
m_DiffuseRemapMin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_DiffuseRemapMax: {x: 1, y: 1, z: 1, w: 1}
|
||||
m_MaskMapRemapMin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_MaskMapRemapMax: {x: 1, y: 1, z: 1, w: 1}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9a3a9701c10ec044b88f3590e246054
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 8574412962073106934
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Mirror/Examples/TestNT/Scenes/Online/TerrainData.asset
Normal file
BIN
Assets/Mirror/Examples/TestNT/Scenes/Online/TerrainData.asset
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49ea6cc998ca79b449bff823dd956d4b
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 15600000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Mirror/Examples/TestNT/Scripts.meta
Normal file
8
Assets/Mirror/Examples/TestNT/Scripts.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c24d8781b215146499fccb73f41fe899
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
110
Assets/Mirror/Examples/TestNT/Scripts/CameraMove.cs
Normal file
110
Assets/Mirror/Examples/TestNT/Scripts/CameraMove.cs
Normal file
@ -0,0 +1,110 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace TestNT
|
||||
{
|
||||
public class CameraMove : MonoBehaviour
|
||||
{
|
||||
enum CursorStates : byte { show, hide }
|
||||
enum RotationAxes : byte { MouseXAndY, MouseX, MouseY }
|
||||
|
||||
[SerializeField, Range(0f, 1f)] float cameraPanSpeed = .2f;
|
||||
[SerializeField, Range(1f, 10f)] float cameraZoomSpeed = 5f;
|
||||
[SerializeField, Range(1f, 10f)] float cameraRotateSpeed = 3f;
|
||||
|
||||
[SerializeField] RotationAxes rotationAxes = RotationAxes.MouseXAndY;
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
// this doesn't seem to work for allowing button clicks
|
||||
if (EventSystem.current.IsPointerOverGameObject())
|
||||
return;
|
||||
|
||||
// workaround for above so can hold shift to click buttons
|
||||
if (!Input.GetKey(KeyCode.LeftShift))
|
||||
return;
|
||||
|
||||
if (Input.GetMouseButton(0))
|
||||
CameraRotate();
|
||||
else if (Input.GetMouseButton(1))
|
||||
CameraOrbit();
|
||||
else if (Input.GetMouseButton(2))
|
||||
CameraPan();
|
||||
else
|
||||
ShowHideCursor(CursorStates.show);
|
||||
|
||||
transform.position += transform.forward * cameraZoomSpeed * Input.GetAxis("Mouse ScrollWheel");
|
||||
}
|
||||
|
||||
void CameraOrbit()
|
||||
{
|
||||
if (!transform.parent) return;
|
||||
|
||||
ShowHideCursor(CursorStates.hide);
|
||||
transform.RotateAround(transform.parent.position, Vector3.up, Input.GetAxis("Mouse X") * cameraRotateSpeed);
|
||||
}
|
||||
|
||||
void CameraRotate()
|
||||
{
|
||||
ShowHideCursor(CursorStates.hide);
|
||||
|
||||
// Get initial value
|
||||
float rotationX = transform.localEulerAngles.x;
|
||||
|
||||
if (rotationAxes == RotationAxes.MouseXAndY)
|
||||
{
|
||||
float rotationY = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * cameraRotateSpeed;
|
||||
rotationX -= Input.GetAxis("Mouse Y") * cameraRotateSpeed;
|
||||
transform.localEulerAngles = new Vector3(rotationX, rotationY, 0);
|
||||
}
|
||||
else if (rotationAxes == RotationAxes.MouseX)
|
||||
{
|
||||
transform.Rotate(0, Input.GetAxis("Mouse X") * cameraRotateSpeed, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
rotationX -= Input.GetAxis("Mouse Y") * cameraRotateSpeed;
|
||||
transform.localEulerAngles = new Vector3(rotationX, transform.localEulerAngles.y, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void CameraPan()
|
||||
{
|
||||
ShowHideCursor(CursorStates.hide);
|
||||
|
||||
Vector3 mouseInputs = new Vector3(Input.GetAxis("Mouse X"), 0, Input.GetAxis("Mouse Y"));
|
||||
Vector3 pos = transform.position;
|
||||
|
||||
if (mouseInputs.x > 0.0f)
|
||||
pos -= transform.right * cameraPanSpeed;
|
||||
|
||||
if (mouseInputs.x < 0.0f)
|
||||
pos += transform.right * cameraPanSpeed;
|
||||
|
||||
if (mouseInputs.z > 0.0f)
|
||||
pos += transform.forward * cameraPanSpeed;
|
||||
|
||||
if (mouseInputs.z < 0.0f)
|
||||
pos -= transform.forward * cameraPanSpeed;
|
||||
|
||||
pos.y = transform.position.y;
|
||||
|
||||
transform.position = pos;
|
||||
}
|
||||
|
||||
void ShowHideCursor(CursorStates cursorStates)
|
||||
{
|
||||
if (cursorStates == CursorStates.show)
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
}
|
||||
|
||||
if (cursorStates == CursorStates.hide)
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Mirror/Examples/TestNT/Scripts/CameraMove.cs.meta
Normal file
11
Assets/Mirror/Examples/TestNT/Scripts/CameraMove.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33ffe1ccc0a52e74a8d646444ce42409
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
35
Assets/Mirror/Examples/TestNT/Scripts/LoginUI.cs
Normal file
35
Assets/Mirror/Examples/TestNT/Scripts/LoginUI.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace TestNT
|
||||
{
|
||||
public class LoginUI : MonoBehaviour
|
||||
{
|
||||
[Header("UI Elements")]
|
||||
[SerializeField] internal InputField networkAddressInput;
|
||||
[SerializeField] internal InputField usernameInput;
|
||||
[SerializeField] internal Button hostButton;
|
||||
[SerializeField] internal Button clientButton;
|
||||
[SerializeField] internal Text errorText;
|
||||
|
||||
public static LoginUI instance;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
|
||||
#if UNITY_WEBGL
|
||||
hostButton.gameObject.SetActive(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Called by UI element UsernameInput.OnValueChanged
|
||||
public void ToggleButtons(string username)
|
||||
{
|
||||
#if !UNITY_WEBGL
|
||||
hostButton.interactable = !string.IsNullOrWhiteSpace(username) && string.Compare(TestNTNetworkManager.singleton.networkAddress, "localhost", true) == 0;
|
||||
#endif
|
||||
clientButton.interactable = !string.IsNullOrWhiteSpace(username);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Mirror/Examples/TestNT/Scripts/LoginUI.cs.meta
Normal file
11
Assets/Mirror/Examples/TestNT/Scripts/LoginUI.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1298a3cb78b81e745a5f5d21a02cbe5d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
58
Assets/Mirror/Examples/TestNT/Scripts/NPCHandler.cs
Normal file
58
Assets/Mirror/Examples/TestNT/Scripts/NPCHandler.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TestNT
|
||||
{
|
||||
public class NPCHandler : NetworkBehaviour
|
||||
{
|
||||
readonly static List<GameObject> NpcList = new List<GameObject>();
|
||||
|
||||
void OnValidate()
|
||||
{
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
public override void OnStartLocalPlayer()
|
||||
{
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public override void OnStopLocalPlayer()
|
||||
{
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.N))
|
||||
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
|
||||
CmdKillNPC();
|
||||
else
|
||||
CmdSpawnNPC();
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdSpawnNPC()
|
||||
{
|
||||
Vector3 spawnPos = transform.position + Vector3.forward;
|
||||
GameObject npc = Instantiate(NetworkManager.singleton.playerPrefab, spawnPos, Quaternion.identity);
|
||||
npc.GetComponent<PlayerName>().playerName = "NPC";
|
||||
npc.GetComponent<NetworkTransformReliable>().syncDirection = SyncDirection.ServerToClient;
|
||||
npc.GetComponent<CharacterController>().enabled = true;
|
||||
npc.GetComponent<PlayerMove>().enabled = true;
|
||||
NetworkServer.Spawn(npc);
|
||||
NpcList.Add(npc);
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdKillNPC()
|
||||
{
|
||||
if (NpcList.Count > 0)
|
||||
{
|
||||
NetworkServer.Destroy(NpcList[0]);
|
||||
NpcList.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Mirror/Examples/TestNT/Scripts/NPCHandler.cs.meta
Normal file
11
Assets/Mirror/Examples/TestNT/Scripts/NPCHandler.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e38454473ad060c40a968b8b1f961cb1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
87
Assets/Mirror/Examples/TestNT/Scripts/NTReliableExt.cs
Normal file
87
Assets/Mirror/Examples/TestNT/Scripts/NTReliableExt.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
using System;
|
||||
|
||||
namespace TestNT
|
||||
{
|
||||
public class NTReliableExt : NetworkTransformReliable
|
||||
{
|
||||
public Action<Vector3, Vector3> VelRotChangedAction;
|
||||
|
||||
[Header("Snapshot Interpolation")]
|
||||
//public double t;
|
||||
//public int fromIndex;
|
||||
//public int toIndex;
|
||||
public Vector3 velocity;
|
||||
|
||||
#region Unity Callbacks
|
||||
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
}
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region NetworkTransformBase Methods
|
||||
|
||||
protected override bool Changed(TransformSnapshot current)
|
||||
{
|
||||
return base.Changed(current);
|
||||
}
|
||||
|
||||
protected override void OnServerToClientSync(Vector3? position, Quaternion? rotation, Vector3? scale)
|
||||
{
|
||||
base.OnServerToClientSync(position, rotation, scale);
|
||||
}
|
||||
|
||||
protected override void OnClientToServerSync(Vector3? position, Quaternion? rotation, Vector3? scale)
|
||||
{
|
||||
base.OnClientToServerSync(position, rotation, scale);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region NetworkTransformReliable Methods
|
||||
|
||||
protected override void Apply(TransformSnapshot interpolated)
|
||||
{
|
||||
if (!isOwned)
|
||||
{
|
||||
Vector3 velChange = (transform.position - interpolated.position) / Time.deltaTime;
|
||||
Vector3 rotChange = (transform.rotation.eulerAngles - interpolated.rotation.eulerAngles) / Time.deltaTime;
|
||||
velocity = velChange;
|
||||
VelRotChangedAction?.Invoke(velChange, rotChange);
|
||||
}
|
||||
|
||||
base.Apply(interpolated);
|
||||
}
|
||||
|
||||
protected override TransformSnapshot Construct()
|
||||
{
|
||||
return base.Construct();
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
11
Assets/Mirror/Examples/TestNT/Scripts/NTReliableExt.cs.meta
Normal file
11
Assets/Mirror/Examples/TestNT/Scripts/NTReliableExt.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58d4ed8e905e2f0419873bf2d4a973b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
86
Assets/Mirror/Examples/TestNT/Scripts/PlayerBuffers.cs
Normal file
86
Assets/Mirror/Examples/TestNT/Scripts/PlayerBuffers.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
using TMPro;
|
||||
|
||||
namespace TestNT
|
||||
{
|
||||
[RequireComponent(typeof(NetworkTransformReliable))]
|
||||
public class PlayerBuffers : NetworkBehaviour
|
||||
{
|
||||
Transform mainCamTransform;
|
||||
|
||||
[Header("Components")]
|
||||
public NTReliableExt networkTransformReliable;
|
||||
public TextMeshPro serverBufferText;
|
||||
public TextMeshPro clientBufferText;
|
||||
public TextMeshPro snapIntText;
|
||||
|
||||
[Header("Diagnostics - Do Not Modify")]
|
||||
public int serverSnapCount;
|
||||
public int clientSnapCount;
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
networkTransformReliable = GetComponent<NTReliableExt>();
|
||||
|
||||
// Force overrideColorTags true so we can change the color without tags
|
||||
serverBufferText.overrideColorTags = true;
|
||||
clientBufferText.overrideColorTags = true;
|
||||
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
public override void OnStartClient()
|
||||
{
|
||||
mainCamTransform = Camera.main.transform;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public override void OnStopClient()
|
||||
{
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
/////// Server
|
||||
serverSnapCount = networkTransformReliable.serverSnapshots.Count;
|
||||
|
||||
if (serverSnapCount < 2)
|
||||
serverBufferText.color = Color.gray;
|
||||
else if (serverSnapCount < 3)
|
||||
serverBufferText.color = Color.green;
|
||||
else if (serverSnapCount < 4)
|
||||
serverBufferText.color = Color.yellow;
|
||||
else
|
||||
serverBufferText.color = Color.red;
|
||||
|
||||
serverBufferText.text = "S: " + new string('-', serverSnapCount);
|
||||
|
||||
/////// Client
|
||||
clientSnapCount = networkTransformReliable.clientSnapshots.Count;
|
||||
|
||||
if (clientSnapCount < 2)
|
||||
clientBufferText.color = Color.gray;
|
||||
else if (clientSnapCount < 3)
|
||||
clientBufferText.color = Color.green;
|
||||
else if (clientSnapCount < 4)
|
||||
clientBufferText.color = Color.yellow;
|
||||
else
|
||||
clientBufferText.color = Color.red;
|
||||
|
||||
clientBufferText.text = "C: " + new string('-', clientSnapCount);
|
||||
|
||||
/////// Snap Interpolation
|
||||
snapIntText.text = $"{networkTransformReliable.velocity.magnitude:N2}" +
|
||||
$"\n{transform.position}";
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
serverBufferText.transform.forward = mainCamTransform.forward;
|
||||
clientBufferText.transform.forward = mainCamTransform.forward;
|
||||
snapIntText.transform.forward = mainCamTransform.forward;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Mirror/Examples/TestNT/Scripts/PlayerBuffers.cs.meta
Normal file
11
Assets/Mirror/Examples/TestNT/Scripts/PlayerBuffers.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 995b66880233cda49846f5cda46330ba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
42
Assets/Mirror/Examples/TestNT/Scripts/PlayerCamera.cs
Normal file
42
Assets/Mirror/Examples/TestNT/Scripts/PlayerCamera.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Mirror;
|
||||
|
||||
namespace TestNT
|
||||
{
|
||||
public class PlayerCamera : NetworkBehaviour
|
||||
{
|
||||
Camera mainCam;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
mainCam = Camera.main;
|
||||
}
|
||||
|
||||
public override void OnStartLocalPlayer()
|
||||
{
|
||||
if (mainCam != null)
|
||||
{
|
||||
// configure and make camera a child of player with 3rd person offset
|
||||
mainCam.orthographic = false;
|
||||
mainCam.transform.SetParent(transform);
|
||||
mainCam.transform.localPosition = new Vector3(0f, 3f, -8f);
|
||||
mainCam.transform.localEulerAngles = new Vector3(10f, 0f, 0f);
|
||||
}
|
||||
else
|
||||
Debug.LogWarning("PlayerCamera: Could not find a camera in scene with 'MainCamera' tag.");
|
||||
}
|
||||
|
||||
public override void OnStopLocalPlayer()
|
||||
{
|
||||
if (mainCam != null)
|
||||
{
|
||||
mainCam.transform.SetParent(null);
|
||||
SceneManager.MoveGameObjectToScene(mainCam.gameObject, SceneManager.GetActiveScene());
|
||||
mainCam.orthographic = true;
|
||||
mainCam.transform.localPosition = new Vector3(0f, 70f, 0f);
|
||||
mainCam.transform.localEulerAngles = new Vector3(90f, 0f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Mirror/Examples/TestNT/Scripts/PlayerCamera.cs.meta
Normal file
11
Assets/Mirror/Examples/TestNT/Scripts/PlayerCamera.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f5084c19de03654fb27bbb4297419a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
34
Assets/Mirror/Examples/TestNT/Scripts/PlayerColor.cs
Normal file
34
Assets/Mirror/Examples/TestNT/Scripts/PlayerColor.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
|
||||
namespace TestNT
|
||||
{
|
||||
public class PlayerColor : NetworkBehaviour
|
||||
{
|
||||
// Unity clones the material when GetComponent<Renderer>().material is called
|
||||
// Cache it here and destroy it in OnDestroy to prevent a memory leak
|
||||
Material cachedMaterial;
|
||||
|
||||
public Renderer rend;
|
||||
|
||||
// Color32 packs to 4 bytes
|
||||
[SyncVar(hook = nameof(SetColor))]
|
||||
public Color32 color = Color.black;
|
||||
|
||||
void SetColor(Color32 _, Color32 newColor)
|
||||
{
|
||||
if (cachedMaterial == null) cachedMaterial = rend.material;
|
||||
cachedMaterial.color = newColor;
|
||||
}
|
||||
|
||||
public override void OnStartServer()
|
||||
{
|
||||
color = Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
Destroy(cachedMaterial);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Mirror/Examples/TestNT/Scripts/PlayerColor.cs.meta
Normal file
11
Assets/Mirror/Examples/TestNT/Scripts/PlayerColor.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b6b6a0890f43524b9f43990b406057b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33
Assets/Mirror/Examples/TestNT/Scripts/PlayerHeight.cs
Normal file
33
Assets/Mirror/Examples/TestNT/Scripts/PlayerHeight.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using Mirror;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TestNT
|
||||
{
|
||||
public class PlayerHeight : MonoBehaviour
|
||||
{
|
||||
Transform mainCamTransform;
|
||||
float maxHeight;
|
||||
|
||||
[Header("Components")]
|
||||
public TextMeshPro playerHeightText;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
mainCamTransform = Camera.main.transform;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// subtract half height and skin width
|
||||
maxHeight = Mathf.Max(maxHeight, transform.position.y - 1.02f);
|
||||
playerHeightText.text = $"{MathF.Round(maxHeight, 2)}";
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
playerHeightText.transform.forward = mainCamTransform.forward;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Mirror/Examples/TestNT/Scripts/PlayerHeight.cs.meta
Normal file
11
Assets/Mirror/Examples/TestNT/Scripts/PlayerHeight.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b7f1c2d250732142870de62a083e134
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
45
Assets/Mirror/Examples/TestNT/Scripts/PlayerMinions.cs
Normal file
45
Assets/Mirror/Examples/TestNT/Scripts/PlayerMinions.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
|
||||
namespace TestNT
|
||||
{
|
||||
public class PlayerMinions : NetworkBehaviour
|
||||
{
|
||||
void OnValidate()
|
||||
{
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
public override void OnStartLocalPlayer()
|
||||
{
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public override void OnStopLocalPlayer()
|
||||
{
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Only spawn the minions once
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
CmdSpawnMinions();
|
||||
this.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdSpawnMinions()
|
||||
{
|
||||
for (int z = 2; z < 10; z += 2)
|
||||
for (int x = -9; x < 10; x += 2)
|
||||
{
|
||||
Vector3 spawnPos = new Vector3(transform.position.x + x, transform.position.y, transform.position.z + z);
|
||||
GameObject minion = Instantiate(NetworkManager.singleton.playerPrefab, spawnPos, Quaternion.identity);
|
||||
NetworkServer.Spawn(minion, connectionToClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Mirror/Examples/TestNT/Scripts/PlayerMinions.cs.meta
Normal file
11
Assets/Mirror/Examples/TestNT/Scripts/PlayerMinions.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07b209877818eac468cbeebeaf2681a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
314
Assets/Mirror/Examples/TestNT/Scripts/PlayerMove.cs
Normal file
314
Assets/Mirror/Examples/TestNT/Scripts/PlayerMove.cs
Normal file
@ -0,0 +1,314 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
|
||||
namespace TestNT
|
||||
{
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
[RequireComponent(typeof(CharacterController))]
|
||||
[RequireComponent(typeof(CapsuleCollider))]
|
||||
[RequireComponent(typeof(NTReliableExt))]
|
||||
public class PlayerMove : NetworkBehaviour
|
||||
{
|
||||
public enum GroundState : byte { Jumping, Falling, Grounded }
|
||||
public enum MoveMode : byte { Walking, Sneaking, Running };
|
||||
|
||||
[Header("Avatar Components")]
|
||||
public CharacterController characterController;
|
||||
public NTReliableExt NTReliableExt;
|
||||
public Animator animator;
|
||||
|
||||
[Header("Materials")]
|
||||
public PhysicMaterial physicsMaterial;
|
||||
|
||||
[Header("Movement")]
|
||||
[Range(1, 20)]
|
||||
public float moveSpeedMultiplier = 8f;
|
||||
|
||||
[Header("Turning")]
|
||||
[Range(1f, 200f)]
|
||||
public float maxTurnSpeed = 100f;
|
||||
[Range(.5f, 5f)]
|
||||
public float turnDelta = 3f;
|
||||
|
||||
[Header("Jumping")]
|
||||
[Range(0.1f, 1f)]
|
||||
public float initialJumpSpeed = 0.2f;
|
||||
[Range(1f, 10f)]
|
||||
public float maxJumpSpeed = 5f;
|
||||
[Range(0.1f, 1f)]
|
||||
public float jumpDelta = 0.2f;
|
||||
|
||||
[Header("Diagnostics - Do Not Modify")]
|
||||
public GroundState groundState = GroundState.Grounded;
|
||||
public MoveMode moveState = MoveMode.Running;
|
||||
|
||||
[Range(-1f, 1f)]
|
||||
public float horizontal;
|
||||
[Range(-1f, 1f)]
|
||||
public float vertical;
|
||||
|
||||
[Range(-200f, 200f)]
|
||||
public float turnSpeed;
|
||||
|
||||
[Range(-10f, 10f)]
|
||||
public float jumpSpeed;
|
||||
|
||||
[Range(-1.5f, 1.5f)]
|
||||
public float animVelocity;
|
||||
|
||||
[Range(-1.5f, 1.5f)]
|
||||
public float animRotation;
|
||||
|
||||
public Vector3Int velocity;
|
||||
public Vector3 direction;
|
||||
|
||||
void OnValidate()
|
||||
{
|
||||
if (animator == null)
|
||||
animator = GetComponentInChildren<Animator>();
|
||||
|
||||
if (characterController == null)
|
||||
characterController = GetComponent<CharacterController>();
|
||||
|
||||
// Override CharacterController default values
|
||||
characterController.enabled = false;
|
||||
characterController.skinWidth = 0.02f;
|
||||
characterController.minMoveDistance = 0f;
|
||||
characterController.sharedMaterial = physicsMaterial;
|
||||
|
||||
GetComponent<Rigidbody>().isKinematic = true;
|
||||
|
||||
if (NTReliableExt == null)
|
||||
NTReliableExt = GetComponent<NTReliableExt>();
|
||||
|
||||
NTReliableExt.syncDirection = SyncDirection.ClientToServer;
|
||||
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
public override void OnStartClient()
|
||||
{
|
||||
if (!isLocalPlayer)
|
||||
NTReliableExt.VelRotChangedAction = OnVelRotChanged;
|
||||
}
|
||||
|
||||
public override void OnStopClient()
|
||||
{
|
||||
NTReliableExt.VelRotChangedAction = null;
|
||||
}
|
||||
|
||||
public override void OnStartAuthority()
|
||||
{
|
||||
characterController.enabled = true;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public override void OnStopAuthority()
|
||||
{
|
||||
this.enabled = false;
|
||||
characterController.enabled = false;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!characterController.enabled)
|
||||
return;
|
||||
|
||||
#if !UNITY_SERVER
|
||||
// Not needed on headless clients
|
||||
HandleMoveState();
|
||||
#endif
|
||||
|
||||
HandleTurning();
|
||||
HandleJumping();
|
||||
HandleMove();
|
||||
|
||||
#if !UNITY_SERVER
|
||||
// Not needed on headless clients
|
||||
HandleAnimation();
|
||||
#endif
|
||||
|
||||
// Reset ground state
|
||||
if (characterController.isGrounded)
|
||||
groundState = GroundState.Grounded;
|
||||
else if (groundState != GroundState.Jumping)
|
||||
groundState = GroundState.Falling;
|
||||
|
||||
// Diagnostic velocity...FloorToInt for display purposes
|
||||
velocity = Vector3Int.FloorToInt(characterController.velocity);
|
||||
}
|
||||
|
||||
// Headless clients don't need to do either of these
|
||||
#if !UNITY_SERVER
|
||||
|
||||
void HandleMoveState()
|
||||
{
|
||||
if (Input.GetKeyUp(KeyCode.R) && moveState == MoveMode.Walking)
|
||||
moveState = MoveMode.Running;
|
||||
else if (Input.GetKeyUp(KeyCode.R) && moveState == MoveMode.Running)
|
||||
moveState = MoveMode.Walking;
|
||||
else if (Input.GetKeyUp(KeyCode.C) && moveState != MoveMode.Sneaking)
|
||||
moveState = MoveMode.Sneaking;
|
||||
else if (Input.GetKeyUp(KeyCode.C) && moveState == MoveMode.Sneaking)
|
||||
moveState = MoveMode.Walking;
|
||||
}
|
||||
|
||||
void HandleAnimation()
|
||||
{
|
||||
if (!animator) return;
|
||||
|
||||
//if (moveState != MoveState.Sneaking)
|
||||
//{
|
||||
// if (Input.GetKeyUp(KeyCode.I))
|
||||
// animator.SetTrigger("Saluting");
|
||||
// else if (Input.GetKeyUp(KeyCode.O))
|
||||
// animator.SetTrigger("Waving");
|
||||
// else if (Input.GetKeyUp(KeyCode.P))
|
||||
// animator.SetBool("Dancing", !animator.GetBool("Dancing"));
|
||||
//}
|
||||
|
||||
animVelocity = -transform.InverseTransformDirection(direction).z / moveSpeedMultiplier;
|
||||
animRotation = -turnSpeed / maxTurnSpeed;
|
||||
|
||||
animator.SetFloat("Forward", Mathf.MoveTowards(animator.GetFloat("Forward"), animVelocity, moveSpeedMultiplier * Time.deltaTime));
|
||||
animator.SetFloat("Turn", Mathf.MoveTowards(animator.GetFloat("Turn"), animRotation, maxTurnSpeed * Time.deltaTime));
|
||||
|
||||
animator.SetBool("Crouch", moveState == MoveMode.Sneaking);
|
||||
animator.SetBool("OnGround", groundState == GroundState.Grounded);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// Alternative methods provided for headless clients to act autonomously
|
||||
#if !UNITY_SERVER
|
||||
|
||||
// TODO: Turning works while airborne...feature?
|
||||
void HandleTurning()
|
||||
{
|
||||
// Q and E cancel each other out, reducing the turn to zero.
|
||||
if (Input.GetKey(KeyCode.Q))
|
||||
turnSpeed = Mathf.MoveTowards(turnSpeed, -maxTurnSpeed, turnDelta);
|
||||
if (Input.GetKey(KeyCode.E))
|
||||
turnSpeed = Mathf.MoveTowards(turnSpeed, maxTurnSpeed, turnDelta);
|
||||
|
||||
// If both pressed, reduce turning speed toward zero.
|
||||
if (Input.GetKey(KeyCode.Q) && Input.GetKey(KeyCode.E))
|
||||
turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta);
|
||||
|
||||
// If neither pressed, reduce turning speed toward zero.
|
||||
if (!Input.GetKey(KeyCode.Q) && !Input.GetKey(KeyCode.E))
|
||||
turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta);
|
||||
|
||||
if (moveState == MoveMode.Sneaking)
|
||||
turnSpeed /= 3;
|
||||
|
||||
transform.Rotate(0f, turnSpeed * Time.deltaTime, 0f);
|
||||
}
|
||||
|
||||
void HandleJumping()
|
||||
{
|
||||
// Handle variable force jumping.
|
||||
// Jump starts with initial power on takeoff, and jumps higher / longer
|
||||
// as player holds spacebar. Jump power is increased by a diminishing amout
|
||||
// every frame until it reaches maxJumpSpeed, or player releases the spacebar,
|
||||
// and then changes to the falling state until it gets grounded.
|
||||
if (groundState != GroundState.Falling && moveState != MoveMode.Sneaking && Input.GetKey(KeyCode.Space))
|
||||
{
|
||||
if (groundState != GroundState.Jumping)
|
||||
{
|
||||
// Start jump at initial power.
|
||||
groundState = GroundState.Jumping;
|
||||
jumpSpeed = initialJumpSpeed;
|
||||
}
|
||||
else
|
||||
// Jumping has already started...increase power toward maxJumpSpeed over time.
|
||||
jumpSpeed = Mathf.MoveTowards(jumpSpeed, maxJumpSpeed, jumpDelta);
|
||||
|
||||
// If power has reached maxJumpSpeed, change to falling until grounded.
|
||||
// This prevents over-applying jump power while already in the air.
|
||||
if (jumpSpeed == maxJumpSpeed)
|
||||
groundState = GroundState.Falling;
|
||||
}
|
||||
else if (groundState != GroundState.Grounded)
|
||||
{
|
||||
// handles running off a cliff and/or player released Spacebar.
|
||||
groundState = GroundState.Falling;
|
||||
jumpSpeed = Mathf.Min(jumpSpeed, maxJumpSpeed);
|
||||
jumpSpeed += Physics.gravity.y * Time.deltaTime;
|
||||
}
|
||||
else
|
||||
jumpSpeed = Physics.gravity.y * Time.deltaTime;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// Headless client forced to a slow constant turn
|
||||
void HandleTurning()
|
||||
{
|
||||
turnSpeed = maxTurnSpeed * 0.5f;
|
||||
transform.Rotate(0f, turnSpeed * Time.deltaTime, 0f);
|
||||
}
|
||||
|
||||
// Headless client forced to ground
|
||||
void HandleJumping()
|
||||
{
|
||||
jumpSpeed = Physics.gravity.y * Time.deltaTime;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// TODO: Directional input works while airborne...feature?
|
||||
void HandleMove()
|
||||
{
|
||||
// Capture inputs
|
||||
#if !UNITY_SERVER
|
||||
horizontal = Input.GetAxis("Horizontal");
|
||||
vertical = Input.GetAxis("Vertical");
|
||||
#else
|
||||
// Headless client running forward
|
||||
horizontal = 0f;
|
||||
vertical = 1f;
|
||||
#endif
|
||||
// Create initial direction vector without jumpSpeed (y-axis).
|
||||
direction = new Vector3(horizontal, 0f, vertical);
|
||||
|
||||
// Run unless Sneaking or Walking
|
||||
if (moveState == MoveMode.Sneaking)
|
||||
direction *= 0.15f;
|
||||
else if (moveState == MoveMode.Walking)
|
||||
direction *= 0.5f;
|
||||
|
||||
// Clamp so diagonal strafing isn't a speed advantage.
|
||||
direction = Vector3.ClampMagnitude(direction, 1f);
|
||||
|
||||
// Transforms direction from local space to world space.
|
||||
direction = transform.TransformDirection(direction);
|
||||
|
||||
// Multiply for desired ground speed.
|
||||
direction *= moveSpeedMultiplier;
|
||||
|
||||
// Add jumpSpeed to direction as last step.
|
||||
direction.y = jumpSpeed;
|
||||
|
||||
// Finally move the character.
|
||||
characterController.Move(direction * Time.deltaTime);
|
||||
}
|
||||
|
||||
void OnVelRotChanged(Vector3 newVelocity, Vector3 newRotation)
|
||||
{
|
||||
// Only apply to other player objects
|
||||
if (isLocalPlayer) return;
|
||||
|
||||
animVelocity = -transform.InverseTransformDirection(newVelocity).z / moveSpeedMultiplier;
|
||||
animRotation = -newRotation.y / maxTurnSpeed;
|
||||
|
||||
if (animator)
|
||||
{
|
||||
animator.SetFloat("Forward", Mathf.MoveTowards(animator.GetFloat("Forward"), animVelocity, moveSpeedMultiplier * Time.deltaTime));
|
||||
animator.SetFloat("Turn", Mathf.MoveTowards(animator.GetFloat("Turn"), animRotation, maxTurnSpeed * Time.deltaTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Mirror/Examples/TestNT/Scripts/PlayerMove.cs.meta
Normal file
11
Assets/Mirror/Examples/TestNT/Scripts/PlayerMove.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10b6173e718990b4b9d1f815187ba090
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
55
Assets/Mirror/Examples/TestNT/Scripts/PlayerName.cs
Normal file
55
Assets/Mirror/Examples/TestNT/Scripts/PlayerName.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
using TMPro;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TestNT
|
||||
{
|
||||
public class PlayerName : NetworkBehaviour
|
||||
{
|
||||
internal static readonly Dictionary<NetworkConnectionToClient, string> connNames = new Dictionary<NetworkConnectionToClient, string>();
|
||||
internal static readonly HashSet<string> playerNames = new HashSet<string>();
|
||||
|
||||
Transform mainCamTransform;
|
||||
|
||||
[Header("Components")]
|
||||
public TextMeshPro nameText;
|
||||
|
||||
[Header("SyncVars")]
|
||||
[SyncVar(hook = nameof(OnNameChanged))]
|
||||
public string playerName;
|
||||
|
||||
void OnNameChanged(string _, string newValue)
|
||||
{
|
||||
nameText.text = newValue;
|
||||
gameObject.name = newValue;
|
||||
}
|
||||
|
||||
void OnValidate()
|
||||
{
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
//public override void OnStartServer()
|
||||
//{
|
||||
// playerName = (string)connectionToClient.authenticationData;
|
||||
//}
|
||||
|
||||
public override void OnStartClient()
|
||||
{
|
||||
mainCamTransform = Camera.main.transform;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public override void OnStopClient()
|
||||
{
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
//nameText.text = transform.position.ToString();
|
||||
nameText.transform.forward = mainCamTransform.forward;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Mirror/Examples/TestNT/Scripts/PlayerName.cs.meta
Normal file
11
Assets/Mirror/Examples/TestNT/Scripts/PlayerName.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f36b822e59a38dc42aebb18802dd2c6c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,219 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Mirror;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TestNT
|
||||
{
|
||||
[AddComponentMenu("")]
|
||||
public class TestNTNetworkAuthenticator : NetworkAuthenticator
|
||||
{
|
||||
readonly HashSet<NetworkConnection> connectionsPendingDisconnect = new HashSet<NetworkConnection>();
|
||||
|
||||
[Header("Client Username")]
|
||||
public string playerName;
|
||||
public bool isBot;
|
||||
|
||||
#region Messages
|
||||
|
||||
public struct AuthRequestMessage : NetworkMessage
|
||||
{
|
||||
public string authUsername;
|
||||
public bool isBot;
|
||||
}
|
||||
|
||||
public struct AuthResponseMessage : NetworkMessage
|
||||
{
|
||||
public byte code;
|
||||
public string message;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Server
|
||||
|
||||
/// <summary>
|
||||
/// Called on server from StartServer to initialize the Authenticator
|
||||
/// <para>Server message handlers should be registered in this method.</para>
|
||||
/// </summary>
|
||||
public override void OnStartServer()
|
||||
{
|
||||
// register a handler for the authentication request we expect from client
|
||||
NetworkServer.RegisterHandler<AuthRequestMessage>(OnAuthRequestMessage, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on server from StopServer to reset the Authenticator
|
||||
/// <para>Server message handlers should be registered in this method.</para>
|
||||
/// </summary>
|
||||
public override void OnStopServer()
|
||||
{
|
||||
// unregister the handler for the authentication request
|
||||
NetworkServer.UnregisterHandler<AuthRequestMessage>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on server from OnServerConnectInternal when a client needs to authenticate
|
||||
/// </summary>
|
||||
/// <param name="conn">Connection to client.</param>
|
||||
public override void OnServerAuthenticate(NetworkConnectionToClient conn)
|
||||
{
|
||||
// do nothing...wait for AuthRequestMessage from client
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on server when the client's AuthRequestMessage arrives
|
||||
/// </summary>
|
||||
/// <param name="conn">Connection to client.</param>
|
||||
/// <param name="msg">The message payload</param>
|
||||
public void OnAuthRequestMessage(NetworkConnectionToClient conn, AuthRequestMessage msg)
|
||||
{
|
||||
Debug.Log($"Authentication Request: {msg.authUsername}");
|
||||
|
||||
if (connectionsPendingDisconnect.Contains(conn)) return;
|
||||
|
||||
// check the credentials by calling your web server, database table, playfab api, or any method appropriate.
|
||||
if (!PlayerName.playerNames.Contains(msg.authUsername))
|
||||
{
|
||||
// Add the name to the HashSet (except bots)
|
||||
if (!msg.isBot)
|
||||
PlayerName.playerNames.Add(msg.authUsername);
|
||||
|
||||
// Store username in authenticationData
|
||||
// This will be read in Player.OnStartServer
|
||||
// to set the playerName SyncVar.
|
||||
conn.authenticationData = msg;
|
||||
|
||||
// create and send msg to client so it knows to proceed
|
||||
AuthResponseMessage authResponseMessage = new AuthResponseMessage
|
||||
{
|
||||
code = 100,
|
||||
message = "Success"
|
||||
};
|
||||
|
||||
conn.Send(authResponseMessage);
|
||||
|
||||
// Accept the successful authentication
|
||||
connectionsPendingDisconnect.Remove(conn);
|
||||
ServerAccept(conn);
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionsPendingDisconnect.Add(conn);
|
||||
|
||||
// create and send msg to client so it knows to disconnect
|
||||
AuthResponseMessage authResponseMessage = new AuthResponseMessage
|
||||
{
|
||||
code = 200,
|
||||
message = "Username already in use...try again"
|
||||
};
|
||||
|
||||
conn.Send(authResponseMessage);
|
||||
|
||||
// must set NetworkConnection isAuthenticated = false
|
||||
conn.isAuthenticated = false;
|
||||
|
||||
// disconnect the client after 1 second so that response message gets delivered
|
||||
StartCoroutine(DelayedDisconnect(conn, 1f));
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator DelayedDisconnect(NetworkConnectionToClient conn, float waitTime)
|
||||
{
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
|
||||
// Reject the unsuccessful authentication
|
||||
ServerReject(conn);
|
||||
|
||||
yield return null;
|
||||
|
||||
// remove conn from pending connections
|
||||
connectionsPendingDisconnect.Remove(conn);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Client
|
||||
|
||||
// Called by UI element UsernameInput.OnValueChanged
|
||||
public void SetPlayername(string username)
|
||||
{
|
||||
playerName = username;
|
||||
|
||||
LoginUI.instance.errorText.text = string.Empty;
|
||||
LoginUI.instance.errorText.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void SetPlayername(string username, bool isBot)
|
||||
{
|
||||
playerName = username;
|
||||
this.isBot = isBot;
|
||||
|
||||
LoginUI.instance.errorText.text = string.Empty;
|
||||
LoginUI.instance.errorText.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on client from StartClient to initialize the Authenticator
|
||||
/// <para>Client message handlers should be registered in this method.</para>
|
||||
/// </summary>
|
||||
public override void OnStartClient()
|
||||
{
|
||||
// register a handler for the authentication response we expect from server
|
||||
NetworkClient.RegisterHandler<AuthResponseMessage>(OnAuthResponseMessage, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on client from StopClient to reset the Authenticator
|
||||
/// <para>Client message handlers should be unregistered in this method.</para>
|
||||
/// </summary>
|
||||
public override void OnStopClient()
|
||||
{
|
||||
// unregister the handler for the authentication response
|
||||
NetworkClient.UnregisterHandler<AuthResponseMessage>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on client from OnClientConnectInternal when a client needs to authenticate
|
||||
/// </summary>
|
||||
public override void OnClientAuthenticate()
|
||||
{
|
||||
AuthRequestMessage authRequestMessage = new AuthRequestMessage
|
||||
{
|
||||
authUsername = playerName,
|
||||
isBot = isBot
|
||||
};
|
||||
|
||||
NetworkClient.Send(authRequestMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on client when the server's AuthResponseMessage arrives
|
||||
/// </summary>
|
||||
/// <param name="msg">The message payload</param>
|
||||
public void OnAuthResponseMessage(AuthResponseMessage msg)
|
||||
{
|
||||
if (msg.code == 100)
|
||||
{
|
||||
Debug.Log($"Authentication Response: {msg.message}");
|
||||
|
||||
// Authentication has been accepted
|
||||
ClientAccept();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"Authentication Response: {msg.message}");
|
||||
|
||||
// Authentication has been rejected
|
||||
// StopHost works for both host client and remote clients
|
||||
NetworkManager.singleton.StopHost();
|
||||
|
||||
// Do this AFTER StopHost so it doesn't get cleared / hidden by OnClientDisconnect
|
||||
LoginUI.instance.errorText.text = msg.message;
|
||||
LoginUI.instance.errorText.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b2b6b6eac362ee42bbefaf297fc0c93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
297
Assets/Mirror/Examples/TestNT/Scripts/TestNTNetworkManager.cs
Normal file
297
Assets/Mirror/Examples/TestNT/Scripts/TestNTNetworkManager.cs
Normal file
@ -0,0 +1,297 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
|
||||
namespace TestNT
|
||||
{
|
||||
[AddComponentMenu("")]
|
||||
public class TestNTNetworkManager : NetworkManager
|
||||
{
|
||||
// Overrides the base singleton so we don't
|
||||
// have to cast to this type everywhere.
|
||||
public static new TestNTNetworkManager singleton { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Runs on both Server and Client
|
||||
/// Networking is NOT initialized when this fires
|
||||
/// </summary>
|
||||
public override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
// Called by OnValueChanged of Login UI element NetworkAddressInput
|
||||
public void SetHostname(string hostname)
|
||||
{
|
||||
networkAddress = hostname;
|
||||
}
|
||||
|
||||
// Called by OnValueChanged of Login UI element NetworkAddressDropdown
|
||||
public void OnSelectServer(int server)
|
||||
{
|
||||
if (server == 0)
|
||||
SetHostname("mirror.clevertech.net");
|
||||
if (server == 1)
|
||||
SetHostname("localhost");
|
||||
}
|
||||
|
||||
#region Unity Callbacks
|
||||
|
||||
public override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs on both Server and Client
|
||||
/// Networking is NOT initialized when this fires
|
||||
/// </summary>
|
||||
public override void Start()
|
||||
{
|
||||
#if UNITY_SERVER
|
||||
if (autoStartServerBuild)
|
||||
{
|
||||
StartServer();
|
||||
}
|
||||
// only start server or client, never both
|
||||
else if(autoConnectClientBuild)
|
||||
{
|
||||
((TestNTNetworkAuthenticator)authenticator).SetPlayername("Bot", true);
|
||||
StartClient();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs on both Server and Client
|
||||
/// </summary>
|
||||
public override void LateUpdate()
|
||||
{
|
||||
base.LateUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs on both Server and Client
|
||||
/// </summary>
|
||||
public override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Start & Stop
|
||||
|
||||
/// <summary>
|
||||
/// Set the frame rate for a headless server.
|
||||
/// <para>Override if you wish to disable the behavior or set your own tick rate.</para>
|
||||
/// </summary>
|
||||
public override void ConfigureHeadlessFrameRate()
|
||||
{
|
||||
base.ConfigureHeadlessFrameRate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// called when quitting the application by closing the window / pressing stop in the editor
|
||||
/// </summary>
|
||||
public override void OnApplicationQuit()
|
||||
{
|
||||
base.OnApplicationQuit();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Scene Management
|
||||
|
||||
/// <summary>
|
||||
/// This causes the server to switch scenes and sets the networkSceneName.
|
||||
/// <para>Clients that connect to this server will automatically switch to this scene. This is called automatically if onlineScene or offlineScene are set, but it can be called from user code to switch scenes again while the game is in progress. This automatically sets clients to be not-ready. The clients must call NetworkClient.Ready() again to participate in the new scene.</para>
|
||||
/// </summary>
|
||||
/// <param name="newSceneName"></param>
|
||||
public override void ServerChangeScene(string newSceneName)
|
||||
{
|
||||
base.ServerChangeScene(newSceneName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called from ServerChangeScene immediately before SceneManager.LoadSceneAsync is executed
|
||||
/// <para>This allows server to do work / cleanup / prep before the scene changes.</para>
|
||||
/// </summary>
|
||||
/// <param name="newSceneName">Name of the scene that's about to be loaded</param>
|
||||
public override void OnServerChangeScene(string newSceneName) { }
|
||||
|
||||
/// <summary>
|
||||
/// Called on the server when a scene is completed loaded, when the scene load was initiated by the server with ServerChangeScene().
|
||||
/// </summary>
|
||||
/// <param name="sceneName">The name of the new scene.</param>
|
||||
public override void OnServerSceneChanged(string sceneName) { }
|
||||
|
||||
/// <summary>
|
||||
/// Called from ClientChangeScene immediately before SceneManager.LoadSceneAsync is executed
|
||||
/// <para>This allows client to do work / cleanup / prep before the scene changes.</para>
|
||||
/// </summary>
|
||||
/// <param name="newSceneName">Name of the scene that's about to be loaded</param>
|
||||
/// <param name="sceneOperation">Scene operation that's about to happen</param>
|
||||
/// <param name="customHandling">true to indicate that scene loading will be handled through overrides</param>
|
||||
public override void OnClientChangeScene(string newSceneName, SceneOperation sceneOperation, bool customHandling)
|
||||
{
|
||||
FindObjectOfType<NetworkManagerHUD>().enabled = newSceneName == onlineScene;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on clients when a scene has completed loaded, when the scene load was initiated by the server.
|
||||
/// <para>Scene changes can cause player objects to be destroyed. The default implementation of OnClientSceneChanged in the NetworkManager is to add a player object for the connection if no player object exists.</para>
|
||||
/// </summary>
|
||||
public override void OnClientSceneChanged()
|
||||
{
|
||||
base.OnClientSceneChanged();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Server System Callbacks
|
||||
|
||||
/// <summary>
|
||||
/// Called on the server when a new client connects.
|
||||
/// <para>Unity calls this on the Server when a Client connects to the Server. Use an override to tell the NetworkManager what to do when a client connects to the server.</para>
|
||||
/// </summary>
|
||||
/// <param name="conn">Connection from client.</param>
|
||||
public override void OnServerConnect(NetworkConnectionToClient conn) { }
|
||||
|
||||
/// <summary>
|
||||
/// Called on the server when a client is ready.
|
||||
/// <para>The default implementation of this function calls NetworkServer.SetClientReady() to continue the network setup process.</para>
|
||||
/// </summary>
|
||||
/// <param name="conn">Connection from client.</param>
|
||||
public override void OnServerReady(NetworkConnectionToClient conn)
|
||||
{
|
||||
base.OnServerReady(conn);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the server when a client adds a new player with ClientScene.AddPlayer.
|
||||
/// <para>The default implementation for this function creates a new player object from the playerPrefab.</para>
|
||||
/// </summary>
|
||||
/// <param name="conn">Connection from client.</param>
|
||||
public override void OnServerAddPlayer(NetworkConnectionToClient conn)
|
||||
{
|
||||
Vector3 spawnPos = new Vector3(Random.Range(-20, 20), 5, Random.Range(-20, 20));
|
||||
GameObject player = Instantiate(playerPrefab, spawnPos, Quaternion.identity);
|
||||
player.transform.LookAt(new Vector3(0f, 5f, 0f));
|
||||
|
||||
TestNTNetworkAuthenticator.AuthRequestMessage authData = (TestNTNetworkAuthenticator.AuthRequestMessage)conn.authenticationData;
|
||||
PlayerName playerName = player.GetComponent<PlayerName>();
|
||||
if (authData.isBot)
|
||||
playerName.playerName = $"{authData.authUsername}{conn.connectionId:0000}";
|
||||
else
|
||||
playerName.playerName = authData.authUsername;
|
||||
|
||||
NetworkServer.AddPlayerForConnection(conn, player);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the server when a client disconnects.
|
||||
/// <para>This is called on the Server when a Client disconnects from the Server. Use an override to decide what should happen when a disconnection is detected.</para>
|
||||
/// </summary>
|
||||
/// <param name="conn">Connection from client.</param>
|
||||
public override void OnServerDisconnect(NetworkConnectionToClient conn)
|
||||
{
|
||||
// remove player name from the HashSet
|
||||
if (conn.authenticationData != null)
|
||||
{
|
||||
TestNTNetworkAuthenticator.AuthRequestMessage authData = (TestNTNetworkAuthenticator.AuthRequestMessage)conn.authenticationData;
|
||||
PlayerName.playerNames.Remove(authData.authUsername);
|
||||
}
|
||||
|
||||
// remove connection from Dictionary of conn > names
|
||||
PlayerName.connNames.Remove(conn);
|
||||
|
||||
base.OnServerDisconnect(conn);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on server when transport raises an exception.
|
||||
/// <para>NetworkConnection may be null.</para>
|
||||
/// </summary>
|
||||
/// <param name="conn">Connection of the client...may be null</param>
|
||||
/// <param name="exception">Exception thrown from the Transport.</param>
|
||||
public override void OnServerError(NetworkConnectionToClient conn, TransportError transportError, string message) { }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Client System Callbacks
|
||||
|
||||
/// <summary>
|
||||
/// Called on the client when connected to a server.
|
||||
/// <para>The default implementation of this function sets the client as ready and adds a player. Override the function to dictate what happens when the client connects.</para>
|
||||
/// </summary>
|
||||
public override void OnClientConnect()
|
||||
{
|
||||
base.OnClientConnect();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on clients when disconnected from a server.
|
||||
/// <para>This is called on the client when it disconnects from the server. Override this function to decide what happens when the client disconnects.</para>
|
||||
/// </summary>
|
||||
public override void OnClientDisconnect() { }
|
||||
|
||||
/// <summary>
|
||||
/// Called on clients when a servers tells the client it is no longer ready.
|
||||
/// <para>This is commonly used when switching scenes.</para>
|
||||
/// </summary>
|
||||
public override void OnClientNotReady() { }
|
||||
|
||||
/// <summary>
|
||||
/// Called on client when transport raises an exception.</summary>
|
||||
/// </summary>
|
||||
/// <param name="exception">Exception thrown from the Transport.</param>
|
||||
public override void OnClientError(TransportError transportError, string message) { }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Start & Stop Callbacks
|
||||
|
||||
// Since there are multiple versions of StartServer, StartClient and StartHost, to reliably customize
|
||||
// their functionality, users would need override all the versions. Instead these callbacks are invoked
|
||||
// from all versions, so users only need to implement this one case.
|
||||
|
||||
/// <summary>
|
||||
/// This is invoked when a host is started.
|
||||
/// <para>StartHost has multiple signatures, but they all cause this hook to be called.</para>
|
||||
/// </summary>
|
||||
public override void OnStartHost() { }
|
||||
|
||||
/// <summary>
|
||||
/// This is invoked when a server is started - including when a host is started.
|
||||
/// <para>StartServer has multiple signatures, but they all cause this hook to be called.</para>
|
||||
/// </summary>
|
||||
public override void OnStartServer()
|
||||
{
|
||||
PlayerName.connNames.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is invoked when the client is started.
|
||||
/// </summary>
|
||||
public override void OnStartClient() { }
|
||||
|
||||
/// <summary>
|
||||
/// This is called when a host is stopped.
|
||||
/// </summary>
|
||||
public override void OnStopHost() { }
|
||||
|
||||
/// <summary>
|
||||
/// This is called when a server is stopped - including when a host is stopped.
|
||||
/// </summary>
|
||||
public override void OnStopServer() { }
|
||||
|
||||
/// <summary>
|
||||
/// This is called when a client is stopped.
|
||||
/// </summary>
|
||||
public override void OnStopClient() { }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44d2be3595316814990baf6ba8e177ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user