first commit
This commit is contained in:
commit
4d6bd72555
12
.editorconfig
Normal file
12
.editorconfig
Normal file
@ -0,0 +1,12 @@
|
||||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = false
|
72
.gitignore
vendored
Normal file
72
.gitignore
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
# This .gitignore file should be placed at the root of your Unity project directory
|
||||
#
|
||||
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
|
||||
#
|
||||
/[Ll]ibrary/
|
||||
/[Tt]emp/
|
||||
/[Oo]bj/
|
||||
/[Bb]uild/
|
||||
/[Bb]uilds/
|
||||
/[Ll]ogs/
|
||||
/[Uu]ser[Ss]ettings/
|
||||
|
||||
# MemoryCaptures can get excessive in size.
|
||||
# They also could contain extremely sensitive data
|
||||
/[Mm]emoryCaptures/
|
||||
|
||||
# Recordings can get excessive in size
|
||||
/[Rr]ecordings/
|
||||
|
||||
# Uncomment this line if you wish to ignore the asset store tools plugin
|
||||
# /[Aa]ssets/AssetStoreTools*
|
||||
|
||||
# Autogenerated Jetbrains Rider plugin
|
||||
/[Aa]ssets/Plugins/Editor/JetBrains*
|
||||
|
||||
# Visual Studio cache directory
|
||||
.vs/
|
||||
|
||||
# Gradle cache directory
|
||||
.gradle/
|
||||
|
||||
# Autogenerated VS/MD/Consulo solution and project files
|
||||
ExportedObj/
|
||||
.consulo/
|
||||
*.csproj
|
||||
*.unityproj
|
||||
*.sln
|
||||
*.suo
|
||||
*.tmp
|
||||
*.user
|
||||
*.userprefs
|
||||
*.pidb
|
||||
*.booproj
|
||||
*.svd
|
||||
*.pdb
|
||||
*.mdb
|
||||
*.opendb
|
||||
*.VC.db
|
||||
|
||||
# Unity3D generated meta files
|
||||
*.pidb.meta
|
||||
*.pdb.meta
|
||||
*.mdb.meta
|
||||
|
||||
# Unity3D generated file on crash reports
|
||||
sysinfo.txt
|
||||
|
||||
# Builds
|
||||
*.apk
|
||||
*.aab
|
||||
*.unitypackage
|
||||
*.app
|
||||
|
||||
# Crashlytics generated file
|
||||
crashlytics-build.properties
|
||||
|
||||
# Packed Addressables
|
||||
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
|
||||
|
||||
# Temporary auto-generated Android Assets
|
||||
/[Aa]ssets/[Ss]treamingAssets/aa.meta
|
||||
/[Aa]ssets/[Ss]treamingAssets/aa/*
|
58
.vscode/settings.json
vendored
Normal file
58
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
{
|
||||
"files.exclude":
|
||||
{
|
||||
"**/.DS_Store":true,
|
||||
"**/.git":true,
|
||||
"**/.gitmodules":true,
|
||||
"**/*.booproj":true,
|
||||
"**/*.pidb":true,
|
||||
"**/*.suo":true,
|
||||
"**/*.user":true,
|
||||
"**/*.userprefs":true,
|
||||
"**/*.unityproj":true,
|
||||
"**/*.dll":true,
|
||||
"**/*.exe":true,
|
||||
"**/*.pdf":true,
|
||||
"**/*.mid":true,
|
||||
"**/*.midi":true,
|
||||
"**/*.wav":true,
|
||||
"**/*.gif":true,
|
||||
"**/*.ico":true,
|
||||
"**/*.jpg":true,
|
||||
"**/*.jpeg":true,
|
||||
"**/*.png":true,
|
||||
"**/*.psd":true,
|
||||
"**/*.tga":true,
|
||||
"**/*.tif":true,
|
||||
"**/*.tiff":true,
|
||||
"**/*.3ds":true,
|
||||
"**/*.3DS":true,
|
||||
"**/*.fbx":true,
|
||||
"**/*.FBX":true,
|
||||
"**/*.lxo":true,
|
||||
"**/*.LXO":true,
|
||||
"**/*.ma":true,
|
||||
"**/*.MA":true,
|
||||
"**/*.obj":true,
|
||||
"**/*.OBJ":true,
|
||||
"**/*.asset":true,
|
||||
"**/*.cubemap":true,
|
||||
"**/*.flare":true,
|
||||
"**/*.mat":true,
|
||||
"**/*.meta":true,
|
||||
"**/*.prefab":true,
|
||||
"**/*.unity":true,
|
||||
"build/":true,
|
||||
"Build/":true,
|
||||
"Library/":true,
|
||||
"library/":true,
|
||||
"obj/":true,
|
||||
"Obj/":true,
|
||||
"ProjectSettings/":true,
|
||||
"temp/":true,
|
||||
"Temp/":true
|
||||
},
|
||||
"cSpell.words": [
|
||||
"Prefs"
|
||||
]
|
||||
}
|
BIN
Assets/.DS_Store
vendored
Normal file
BIN
Assets/.DS_Store
vendored
Normal file
Binary file not shown.
7
Assets/Animator.meta
Normal file
7
Assets/Animator.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 672f16104dfe347ffb09aef29b1e6b85
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
715
Assets/Animator/Kyle Robot.controller
Normal file
715
Assets/Animator/Kyle Robot.controller
Normal file
@ -0,0 +1,715 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!91 &9100000
|
||||
AnimatorController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Kyle Robot
|
||||
serializedVersion: 5
|
||||
m_AnimatorParameters:
|
||||
- m_Name: Speed
|
||||
m_Type: 1
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Direction
|
||||
m_Type: 1
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Hi
|
||||
m_Type: 4
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Jump
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base Layer
|
||||
m_StateMachine: {fileID: 110700000}
|
||||
m_Mask: {fileID: 0}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 0
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
--- !u!206 &20600000
|
||||
BlendTree:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Blend Tree
|
||||
m_Childs:
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400002, guid: 1062212255550964e974f3ffb3cbaae3, type: 3}
|
||||
m_Threshold: -1
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1.5
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter:
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: 1cb8ed3cbba15f0479fbae54e0a963df, type: 3}
|
||||
m_Threshold: 0
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter:
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: 1062212255550964e974f3ffb3cbaae3, type: 3}
|
||||
m_Threshold: 1
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1.5
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter:
|
||||
m_Mirror: 0
|
||||
m_BlendParameter: Direction
|
||||
m_BlendParameterY: Blend
|
||||
m_MinThreshold: -1
|
||||
m_MaxThreshold: 1
|
||||
m_UseAutomaticThresholds: 1
|
||||
m_NormalizedBlendValues: 0
|
||||
m_BlendType: 0
|
||||
--- !u!1101 &110124237
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Hi
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 110231924}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.1
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.9
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 0
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &110170435
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 110287193}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.09740261
|
||||
m_TransitionOffset: 0.8736468
|
||||
m_ExitTime: 0.7913838
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 0
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &110181839
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Jump
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 110246486}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 1.0523655
|
||||
m_TransitionOffset: 0.050623525
|
||||
m_ExitTime: 0.28997093
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 0
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &110195122
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 110260110}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.06880733
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.93119264
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 0
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &110200000
|
||||
AnimatorState:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Idle 0
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0.4
|
||||
m_Transitions:
|
||||
- {fileID: 1101045175781524788}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 432, y: 216, z: 0}
|
||||
m_IKOnFeet: 1
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: dffa50cfe77e0434bbfa71245b3dd529, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &110231924
|
||||
AnimatorState:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Wave
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 577, y: 69, z: 0}
|
||||
m_IKOnFeet: 1
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400002, guid: c387a0e47b4244f2b86c50372341024a, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &110246486
|
||||
AnimatorState:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Jump
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 110170435}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 432, y: -48, z: 0}
|
||||
m_IKOnFeet: 1
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400008, guid: 0d9d26e2162aa4d11ab075b34c029673, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &110260110
|
||||
AnimatorState:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: New State
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 275, y: 157, z: 0}
|
||||
m_IKOnFeet: 1
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 0}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &110287193
|
||||
AnimatorState:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Run
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 110181839}
|
||||
- {fileID: 1101019833995191196}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 432, y: 84, z: 0}
|
||||
m_IKOnFeet: 1
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 20600000}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1107 &110700000
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Base Layer
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 110200000}
|
||||
m_Position: {x: 432, y: 192, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 110287193}
|
||||
m_Position: {x: 432, y: 84, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 110246486}
|
||||
m_Position: {x: 432, y: -48, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 48, y: 24, z: 0}
|
||||
m_EntryPosition: {x: 168, y: 192, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 110200000}
|
||||
--- !u!206 &206410856599954346
|
||||
BlendTree:
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Blend Tree
|
||||
m_Childs:
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: c59a2a721fc964a949c27fa965d044d9, type: 3}
|
||||
m_Threshold: -1
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1.5
|
||||
m_CycleOffset: 0.5
|
||||
m_DirectBlendParameter:
|
||||
m_Mirror: 1
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: cd0e3010ec4a7471ab652a490698f310, type: 3}
|
||||
m_Threshold: 0
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter:
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: c59a2a721fc964a949c27fa965d044d9, type: 3}
|
||||
m_Threshold: 1
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1.5
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter:
|
||||
m_Mirror: 0
|
||||
m_BlendParameter: Direction
|
||||
m_BlendParameterY: Blend
|
||||
m_MinThreshold: -1
|
||||
m_MaxThreshold: 1
|
||||
m_UseAutomaticThresholds: 1
|
||||
m_NormalizedBlendValues: 0
|
||||
m_BlendType: 0
|
||||
--- !u!1101 &1101019833995191196
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 4
|
||||
m_ConditionEvent: Speed
|
||||
m_EventTreshold: 0.1
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 110200000}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.7144106
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.9
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 0
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &1101045175781524788
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 3
|
||||
m_ConditionEvent: Speed
|
||||
m_EventTreshold: 0.1
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 110287193}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.15988465
|
||||
m_TransitionOffset: 0.032576416
|
||||
m_ExitTime: 0.6846458
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 0
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &1101139164504168234
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 4
|
||||
m_ConditionEvent: Speed
|
||||
m_EventTreshold: 0.1
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 1102636063383119256}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.7144106
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.9
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 0
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &1101149867596243010
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 1102350464198559504}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.92268044
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &1101510316954946038
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 3
|
||||
m_ConditionEvent: Speed
|
||||
m_EventTreshold: 0.1
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 110287193}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.15988465
|
||||
m_TransitionOffset: 0.032576416
|
||||
m_ExitTime: 0.6846458
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 0
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &1101554705896622378
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 3
|
||||
m_ConditionEvent: Speed
|
||||
m_EventTreshold: 0.1
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 1102350464198559504}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.15988465
|
||||
m_TransitionOffset: 0.032576416
|
||||
m_ExitTime: 0.6846458
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 0
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &1101675693162883996
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 4
|
||||
m_ConditionEvent: Speed
|
||||
m_EventTreshold: 0.1
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 1102468607708738168}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.7144106
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.9
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 0
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &1101891933812236490
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Jump
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 1102207359190810060}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 1.0523655
|
||||
m_TransitionOffset: 0.050623525
|
||||
m_ExitTime: 0.28997093
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 0
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &1101911601743559670
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 1102350464198559504}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.09740261
|
||||
m_TransitionOffset: 0.8736468
|
||||
m_ExitTime: 0.7913838
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 0
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &1102207359190810060
|
||||
AnimatorState:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Jump
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 1101911601743559670}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 432, y: -48, z: 0}
|
||||
m_IKOnFeet: 1
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 4837cfbf121a64f23adf6658e7bacb39, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &1102350464198559504
|
||||
AnimatorState:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Run
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 1101891933812236490}
|
||||
- {fileID: 1101139164504168234}
|
||||
- {fileID: 1101675693162883996}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 432, y: 84, z: 0}
|
||||
m_IKOnFeet: 1
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 206410856599954346}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &1102468607708738168
|
||||
AnimatorState:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Idle 0
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0.4
|
||||
m_Transitions:
|
||||
- {fileID: 1101149867596243010}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 432, y: 216, z: 0}
|
||||
m_IKOnFeet: 1
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 4837cfbf121a64f23adf6658e7bacb39, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &1102636063383119256
|
||||
AnimatorState:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Idle
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 1101554705896622378}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 432, y: 216, z: 0}
|
||||
m_IKOnFeet: 1
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 7a7c998f8e27048128d544a06bd9ab28, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1107 &1107903822756934300
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 3
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Base Layer
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 1102468607708738168}
|
||||
m_Position: {x: 432, y: 192, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 1102350464198559504}
|
||||
m_Position: {x: 432, y: 84, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 1102207359190810060}
|
||||
m_Position: {x: 432, y: -48, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 1102636063383119256}
|
||||
m_Position: {x: 636, y: 228, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 48, y: 24, z: 0}
|
||||
m_EntryPosition: {x: -24, y: 144, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 1102468607708738168}
|
8
Assets/Animator/Kyle Robot.controller.meta
Normal file
8
Assets/Animator/Kyle Robot.controller.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 273d16959730b442e9b3cb881e975cf9
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 9100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Materials.meta
Normal file
8
Assets/Materials.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02e4d1a80252d46db8c777d5ce63a67b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
80
Assets/Materials/Blue.mat
Normal file
80
Assets/Materials/Blue.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: Blue
|
||||
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: 0, g: 0.86100054, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
8
Assets/Materials/Blue.mat.meta
Normal file
8
Assets/Materials/Blue.mat.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97983262878f74b99a0fff7786503b4b
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
80
Assets/Materials/Red Beam.mat
Normal file
80
Assets/Materials/Red Beam.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: Red Beam
|
||||
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: 0.08018869, b: 0.08018869, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
8
Assets/Materials/Red Beam.mat.meta
Normal file
8
Assets/Materials/Red Beam.mat.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5803a1f04f0124abd9fae5cc679f4bbd
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
80
Assets/Materials/Robot_Color.mat
Normal file
80
Assets/Materials/Robot_Color.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: Robot_Color
|
||||
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
|
||||
- _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/Materials/Robot_Color.mat.meta
Normal file
8
Assets/Materials/Robot_Color.mat.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0faec2d7824234bd2a400d392f3b3f16
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
80
Assets/Materials/Yellow.mat
Normal file
80
Assets/Materials/Yellow.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: Yellow
|
||||
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: 0.93673176, b: 0.06666667, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
8
Assets/Materials/Yellow.mat.meta
Normal file
8
Assets/Materials/Yellow.mat.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e851eeff549e7462b9235ce3200e73d8
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Photon.meta
Normal file
9
Assets/Photon.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98951132346795f438babe7a3183da43
|
||||
folderAsset: yes
|
||||
timeCreated: 1523536679
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
7
Assets/Photon/PhotonChat.meta
Normal file
7
Assets/Photon/PhotonChat.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea05e6479d592944d955c2a5e1a6d6f1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Photon/PhotonChat/Code.meta
Normal file
9
Assets/Photon/PhotonChat/Code.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af83a98aaa4f7b64eb7fcec95ee7b1ed
|
||||
folderAsset: yes
|
||||
timeCreated: 1523525757
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
22
Assets/Photon/PhotonChat/Code/ChannelCreationOptions.cs
Normal file
22
Assets/Photon/PhotonChat/Code/ChannelCreationOptions.cs
Normal file
@ -0,0 +1,22 @@
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
|
||||
// <remarks>ChannelCreationOptions is a parameter used when subscribing to a public channel for the first time.</remarks>
|
||||
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2018 Exit Games GmbH</copyright>
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Photon.Chat
|
||||
{
|
||||
public class ChannelCreationOptions
|
||||
{
|
||||
/// <summary>Default values of channel creation options.</summary>
|
||||
public static ChannelCreationOptions Default = new ChannelCreationOptions();
|
||||
/// <summary>Whether or not the channel to be created will allow client to keep a list of users.</summary>
|
||||
public bool PublishSubscribers { get; set; }
|
||||
/// <summary>Limit of the number of users subscribed to the channel to be created.</summary>
|
||||
public int MaxSubscribers { get; set; }
|
||||
|
||||
#if CHAT_EXTENDED
|
||||
public System.Collections.Generic.Dictionary<string, object> CustomProperties { get; set; }
|
||||
#endif
|
||||
}
|
||||
}
|
12
Assets/Photon/PhotonChat/Code/ChannelCreationOptions.cs.meta
Normal file
12
Assets/Photon/PhotonChat/Code/ChannelCreationOptions.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c1aa0fceaa2bc14eabdf85976f4e2c8
|
||||
timeCreated: 1549546375
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Assets/Photon/PhotonChat/Code/ChannelWellKnownProperties.cs
Normal file
14
Assets/Photon/PhotonChat/Code/ChannelWellKnownProperties.cs
Normal file
@ -0,0 +1,14 @@
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
|
||||
// <remarks>ChannelWellKnownProperties contains the list of well-known channel properties.</remarks>
|
||||
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2018 Exit Games GmbH</copyright>
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Photon.Chat
|
||||
{
|
||||
public class ChannelWellKnownProperties
|
||||
{
|
||||
public const byte MaxSubscribers = 255;
|
||||
public const byte PublishSubscribers = 254;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5eb508ffb7b7b0f47882f0087a668283
|
||||
timeCreated: 1547826678
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
73
Assets/Photon/PhotonChat/Code/ChatAppSettings.cs
Normal file
73
Assets/Photon/PhotonChat/Code/ChatAppSettings.cs
Normal file
@ -0,0 +1,73 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// <copyright file="ChatAppSettings.cs" company="Exit Games GmbH">
|
||||
// Chat API for Photon - Copyright (C) 2018 Exit Games GmbH
|
||||
// </copyright>
|
||||
// <summary>Settings for Photon Chat application and the server to connect to.</summary>
|
||||
// <author>developer@photonengine.com</author>
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if UNITY_4_7 || UNITY_5 || UNITY_5_3_OR_NEWER
|
||||
#define SUPPORTED_UNITY
|
||||
#endif
|
||||
|
||||
|
||||
namespace Photon.Chat
|
||||
{
|
||||
using System;
|
||||
using ExitGames.Client.Photon;
|
||||
#if SUPPORTED_UNITY
|
||||
using UnityEngine.Serialization;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Settings for Photon application(s) and the server to connect to.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is Serializable for Unity, so it can be included in ScriptableObject instances.
|
||||
/// </remarks>
|
||||
#if !NETFX_CORE || SUPPORTED_UNITY
|
||||
[Serializable]
|
||||
#endif
|
||||
public class ChatAppSettings
|
||||
{
|
||||
/// <summary>AppId for the Chat Api.</summary>
|
||||
#if SUPPORTED_UNITY
|
||||
[FormerlySerializedAs("AppId")]
|
||||
#endif
|
||||
public string AppIdChat;
|
||||
|
||||
/// <summary>The AppVersion can be used to identify builds and will split the AppId distinct "Virtual AppIds" (important for the users to find each other).</summary>
|
||||
public string AppVersion;
|
||||
|
||||
/// <summary>Can be set to any of the Photon Cloud's region names to directly connect to that region.</summary>
|
||||
public string FixedRegion;
|
||||
|
||||
/// <summary>The address (hostname or IP) of the server to connect to.</summary>
|
||||
public string Server;
|
||||
|
||||
/// <summary>If not null, this sets the port of the first Photon server to connect to (that will "forward" the client as needed).</summary>
|
||||
public ushort Port;
|
||||
|
||||
/// <summary>The network level protocol to use.</summary>
|
||||
public ConnectionProtocol Protocol = ConnectionProtocol.Udp;
|
||||
|
||||
/// <summary>Enables a fallback to another protocol in case a connect to the Name Server fails.</summary>
|
||||
/// <remarks>See: LoadBalancingClient.EnableProtocolFallback.</remarks>
|
||||
public bool EnableProtocolFallback = true;
|
||||
|
||||
/// <summary>Log level for the network lib.</summary>
|
||||
public DebugLevel NetworkLogging = DebugLevel.ERROR;
|
||||
|
||||
/// <summary>If true, the default nameserver address for the Photon Cloud should be used.</summary>
|
||||
public bool IsDefaultNameServer { get { return string.IsNullOrEmpty(this.Server); } }
|
||||
|
||||
|
||||
/// <summary>Available to not immediately break compatibility.</summary>
|
||||
[Obsolete("Use AppIdChat instead.")]
|
||||
public string AppId
|
||||
{
|
||||
get { return this.AppIdChat; }
|
||||
set { this.AppIdChat = value; }
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Photon/PhotonChat/Code/ChatAppSettings.cs.meta
Normal file
11
Assets/Photon/PhotonChat/Code/ChatAppSettings.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87776a9b1f405644abcc38ecd70c37fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
193
Assets/Photon/PhotonChat/Code/ChatChannel.cs
Normal file
193
Assets/Photon/PhotonChat/Code/ChatChannel.cs
Normal file
@ -0,0 +1,193 @@
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
|
||||
// <remarks>ChatClient is the main class of this api.</remarks>
|
||||
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#if UNITY_4_7 || UNITY_5 || UNITY_5_3_OR_NEWER
|
||||
#define SUPPORTED_UNITY
|
||||
#endif
|
||||
|
||||
namespace Photon.Chat
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
#if SUPPORTED_UNITY || NETFX_CORE
|
||||
using Hashtable = ExitGames.Client.Photon.Hashtable;
|
||||
using SupportClass = ExitGames.Client.Photon.SupportClass;
|
||||
#endif
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A channel of communication in Photon Chat, updated by ChatClient and provided as READ ONLY.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Contains messages and senders to use (read!) and display by your GUI.
|
||||
/// Access these by:
|
||||
/// ChatClient.PublicChannels
|
||||
/// ChatClient.PrivateChannels
|
||||
/// </remarks>
|
||||
public class ChatChannel
|
||||
{
|
||||
/// <summary>Name of the channel (used to subscribe and unsubscribe).</summary>
|
||||
public readonly string Name;
|
||||
|
||||
/// <summary>Senders of messages in chronological order. Senders and Messages refer to each other by index. Senders[x] is the sender of Messages[x].</summary>
|
||||
public readonly List<string> Senders = new List<string>();
|
||||
|
||||
/// <summary>Messages in chronological order. Senders and Messages refer to each other by index. Senders[x] is the sender of Messages[x].</summary>
|
||||
public readonly List<object> Messages = new List<object>();
|
||||
|
||||
/// <summary>If greater than 0, this channel will limit the number of messages, that it caches locally.</summary>
|
||||
public int MessageLimit;
|
||||
|
||||
/// <summary>Unique channel ID.</summary>
|
||||
public int ChannelID;
|
||||
|
||||
/// <summary>Is this a private 1:1 channel?</summary>
|
||||
public bool IsPrivate { get; protected internal set; }
|
||||
|
||||
/// <summary>Count of messages this client still buffers/knows for this channel.</summary>
|
||||
public int MessageCount { get { return this.Messages.Count; } }
|
||||
|
||||
/// <summary>
|
||||
/// ID of the last message received.
|
||||
/// </summary>
|
||||
public int LastMsgId { get; protected set; }
|
||||
|
||||
private Dictionary<object, object> properties;
|
||||
|
||||
/// <summary>Whether or not this channel keeps track of the list of its subscribers.</summary>
|
||||
public bool PublishSubscribers { get; protected set; }
|
||||
|
||||
/// <summary>Maximum number of channel subscribers. 0 means infinite.</summary>
|
||||
public int MaxSubscribers { get; protected set; }
|
||||
|
||||
/// <summary>Subscribed users.</summary>
|
||||
public readonly HashSet<string> Subscribers = new HashSet<string>();
|
||||
|
||||
/// <summary>Used internally to create new channels. This does NOT create a channel on the server! Use ChatClient.Subscribe.</summary>
|
||||
public ChatChannel(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
|
||||
/// <summary>Used internally to add messages to this channel.</summary>
|
||||
public void Add(string sender, object message, int msgId)
|
||||
{
|
||||
this.Senders.Add(sender);
|
||||
this.Messages.Add(message);
|
||||
this.LastMsgId = msgId;
|
||||
this.TruncateMessages();
|
||||
}
|
||||
|
||||
/// <summary>Used internally to add messages to this channel.</summary>
|
||||
public void Add(string[] senders, object[] messages, int lastMsgId)
|
||||
{
|
||||
this.Senders.AddRange(senders);
|
||||
this.Messages.AddRange(messages);
|
||||
this.LastMsgId = lastMsgId;
|
||||
this.TruncateMessages();
|
||||
}
|
||||
|
||||
/// <summary>Reduces the number of locally cached messages in this channel to the MessageLimit (if set).</summary>
|
||||
public void TruncateMessages()
|
||||
{
|
||||
if (this.MessageLimit <= 0 || this.Messages.Count <= this.MessageLimit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int excessCount = this.Messages.Count - this.MessageLimit;
|
||||
this.Senders.RemoveRange(0, excessCount);
|
||||
this.Messages.RemoveRange(0, excessCount);
|
||||
}
|
||||
|
||||
/// <summary>Clear the local cache of messages currently stored. This frees memory but doesn't affect the server.</summary>
|
||||
public void ClearMessages()
|
||||
{
|
||||
this.Senders.Clear();
|
||||
this.Messages.Clear();
|
||||
}
|
||||
|
||||
/// <summary>Provides a string-representation of all messages in this channel.</summary>
|
||||
/// <returns>All known messages in format "Sender: Message", line by line.</returns>
|
||||
public string ToStringMessages()
|
||||
{
|
||||
StringBuilder txt = new StringBuilder();
|
||||
for (int i = 0; i < this.Messages.Count; i++)
|
||||
{
|
||||
txt.AppendLine(string.Format("{0}: {1}", this.Senders[i], this.Messages[i]));
|
||||
}
|
||||
return txt.ToString();
|
||||
}
|
||||
|
||||
internal void ReadChannelProperties(Dictionary<object, object> newProperties)
|
||||
{
|
||||
if (newProperties != null && newProperties.Count > 0)
|
||||
{
|
||||
if (this.properties == null)
|
||||
{
|
||||
this.properties = new Dictionary<object, object>(newProperties.Count);
|
||||
}
|
||||
foreach (var pair in newProperties)
|
||||
{
|
||||
if (pair.Value == null)
|
||||
{
|
||||
this.properties.Remove(pair.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.properties[pair.Key] = pair.Value;
|
||||
}
|
||||
}
|
||||
object temp;
|
||||
if (this.properties.TryGetValue(ChannelWellKnownProperties.PublishSubscribers, out temp))
|
||||
{
|
||||
this.PublishSubscribers = (bool)temp;
|
||||
}
|
||||
if (this.properties.TryGetValue(ChannelWellKnownProperties.MaxSubscribers, out temp))
|
||||
{
|
||||
this.MaxSubscribers = (int)temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void AddSubscribers(string[] users)
|
||||
{
|
||||
if (users == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < users.Length; i++)
|
||||
{
|
||||
this.Subscribers.Add(users[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#if CHAT_EXTENDED
|
||||
internal void ReadUserProperties(string userId, Dictionary<object, object> changedProperties)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
internal bool TryGetChannelProperty<T>(object propertyKey, out T propertyValue)
|
||||
{
|
||||
propertyValue = default(T);
|
||||
object temp;
|
||||
if (properties != null && properties.TryGetValue(propertyKey, out temp) && temp is T)
|
||||
{
|
||||
propertyValue = (T)temp;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetCustomChannelProperty<T>(string propertyKey, out T propertyValue)
|
||||
{
|
||||
return this.TryGetChannelProperty(propertyKey, out propertyValue);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
8
Assets/Photon/PhotonChat/Code/ChatChannel.cs.meta
Normal file
8
Assets/Photon/PhotonChat/Code/ChatChannel.cs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35b2a4878e5e99e438c97fbe8dbbd863
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
1828
Assets/Photon/PhotonChat/Code/ChatClient.cs
Normal file
1828
Assets/Photon/PhotonChat/Code/ChatClient.cs
Normal file
File diff suppressed because it is too large
Load Diff
8
Assets/Photon/PhotonChat/Code/ChatClient.cs.meta
Normal file
8
Assets/Photon/PhotonChat/Code/ChatClient.cs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 692e391fa2a297c45b3d530aa85be610
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
43
Assets/Photon/PhotonChat/Code/ChatDisconnectCause.cs
Normal file
43
Assets/Photon/PhotonChat/Code/ChatDisconnectCause.cs
Normal file
@ -0,0 +1,43 @@
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
|
||||
// <remarks>ChatClient is the main class of this api.</remarks>
|
||||
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Photon.Chat
|
||||
{
|
||||
/// <summary>Enumeration of causes for Disconnects (used in <see cref="ChatClient.DisconnectedCause"/>).</summary>
|
||||
/// <remarks>Read the individual descriptions to find out what to do about this type of disconnect.</remarks>
|
||||
public enum ChatDisconnectCause
|
||||
{
|
||||
/// <summary>No error was tracked.</summary>
|
||||
None,
|
||||
/// <summary>OnStatusChanged: The server is not available or the address is wrong. Make sure the port is provided and the server is up.</summary>
|
||||
ExceptionOnConnect,
|
||||
/// <summary>OnStatusChanged: The server disconnected this client from within the room's logic (the C# code).</summary>
|
||||
DisconnectByServerLogic,
|
||||
/// <summary>OnStatusChanged: The server disconnected this client for unknown reasons.</summary>
|
||||
DisconnectByServerReasonUnknown,
|
||||
/// <summary>OnStatusChanged: The server disconnected this client due to timing out (missing acknowledgement from the client).</summary>
|
||||
ServerTimeout,
|
||||
|
||||
/// <summary>OnStatusChanged: This client detected that the server's responses are not received in due time.</summary>
|
||||
ClientTimeout,
|
||||
/// <summary>OnStatusChanged: Some internal exception caused the socket code to fail. Contact Exit Games.</summary>
|
||||
Exception,
|
||||
/// <summary>OnOperationResponse: Authenticate in the Photon Cloud with invalid AppId. Update your subscription or contact Exit Games.</summary>
|
||||
InvalidAuthentication,
|
||||
/// <summary>OnOperationResponse: Authenticate (temporarily) failed when using a Photon Cloud subscription without CCU Burst. Update your subscription.</summary>
|
||||
MaxCcuReached,
|
||||
/// <summary>OnOperationResponse: Authenticate when the app's Photon Cloud subscription is locked to some (other) region(s). Update your subscription or change region.</summary>
|
||||
InvalidRegion,
|
||||
/// <summary>OnOperationResponse: Operation that's (currently) not available for this client (not authorized usually). Only tracked for op Authenticate.</summary>
|
||||
OperationNotAllowedInCurrentState,
|
||||
/// <summary>OnOperationResponse: Authenticate in the Photon Cloud with invalid client values or custom authentication setup in Cloud Dashboard.</summary>
|
||||
CustomAuthenticationFailed,
|
||||
/// <summary>The authentication ticket should provide access to any Photon Cloud server without doing another authentication-service call. However, the ticket expired.</summary>
|
||||
AuthenticationTicketExpired,
|
||||
/// <summary>OnStatusChanged: The client disconnected from within the logic (the C# code).</summary>
|
||||
DisconnectByClientLogic
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b90b85043f1857f43b94fd00edfc1ef1
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
39
Assets/Photon/PhotonChat/Code/ChatEventCode.cs
Normal file
39
Assets/Photon/PhotonChat/Code/ChatEventCode.cs
Normal file
@ -0,0 +1,39 @@
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
|
||||
// <remarks>ChatClient is the main class of this api.</remarks>
|
||||
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Photon.Chat
|
||||
{
|
||||
/// <summary>
|
||||
/// Wraps up internally used constants in Photon Chat events. You don't have to use them directly usually.
|
||||
/// </summary>
|
||||
public class ChatEventCode
|
||||
{
|
||||
/// <summary>(0) Event code for messages published in public channels.</summary>
|
||||
public const byte ChatMessages = 0;
|
||||
/// <summary>(1) Not Used. </summary>
|
||||
public const byte Users = 1;// List of users or List of changes for List of users
|
||||
/// <summary>(2) Event code for messages published in private channels</summary>
|
||||
public const byte PrivateMessage = 2;
|
||||
/// <summary>(3) Not Used. </summary>
|
||||
public const byte FriendsList = 3;
|
||||
/// <summary>(4) Event code for status updates. </summary>
|
||||
public const byte StatusUpdate = 4;
|
||||
/// <summary>(5) Event code for subscription acks. </summary>
|
||||
public const byte Subscribe = 5;
|
||||
/// <summary>(6) Event code for unsubscribe acks. </summary>
|
||||
public const byte Unsubscribe = 6;
|
||||
/// <summary>(7) Event code for properties update. </summary>
|
||||
public const byte PropertiesChanged = 7;
|
||||
|
||||
/// <summary>(8) Event code for new user subscription to a channel where <see cref="ChatChannel.PublishSubscribers"/> is enabled. </summary>
|
||||
public const byte UserSubscribed = 8;
|
||||
/// <summary>(9) Event code for when user unsubscribes from a channel where <see cref="ChatChannel.PublishSubscribers"/> is enabled. </summary>
|
||||
public const byte UserUnsubscribed = 9;
|
||||
/// <summary>(10) Event code for when the server sends an error to the client. </summary>
|
||||
/// <remarks> This is currently only used by Chat WebHooks. </remarks>
|
||||
public const byte ErrorInfo = 10;
|
||||
}
|
||||
}
|
8
Assets/Photon/PhotonChat/Code/ChatEventCode.cs.meta
Normal file
8
Assets/Photon/PhotonChat/Code/ChatEventCode.cs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 188e4a680bce12d4cbad8d57a24f7d44
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
38
Assets/Photon/PhotonChat/Code/ChatOperationCode.cs
Normal file
38
Assets/Photon/PhotonChat/Code/ChatOperationCode.cs
Normal file
@ -0,0 +1,38 @@
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
|
||||
// <remarks>ChatClient is the main class of this api.</remarks>
|
||||
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Photon.Chat
|
||||
{
|
||||
/// <summary>
|
||||
/// Wraps up codes for operations used internally in Photon Chat. You don't have to use them directly usually.
|
||||
/// </summary>
|
||||
public class ChatOperationCode
|
||||
{
|
||||
/// <summary>(230) Operation Authenticate.</summary>
|
||||
public const byte Authenticate = 230;
|
||||
|
||||
/// <summary>(0) Operation to subscribe to chat channels.</summary>
|
||||
public const byte Subscribe = 0;
|
||||
/// <summary>(1) Operation to unsubscribe from chat channels.</summary>
|
||||
public const byte Unsubscribe = 1;
|
||||
/// <summary>(2) Operation to publish a message in a chat channel.</summary>
|
||||
public const byte Publish = 2;
|
||||
/// <summary>(3) Operation to send a private message to some other user.</summary>
|
||||
public const byte SendPrivate = 3;
|
||||
|
||||
/// <summary>(4) Not used yet.</summary>
|
||||
public const byte ChannelHistory = 4;
|
||||
|
||||
/// <summary>(5) Set your (client's) status.</summary>
|
||||
public const byte UpdateStatus = 5;
|
||||
/// <summary>(6) Add friends the list of friends that should update you of their status.</summary>
|
||||
public const byte AddFriends = 6;
|
||||
/// <summary>(7) Remove friends from list of friends that should update you of their status.</summary>
|
||||
public const byte RemoveFriends = 7;
|
||||
/// <summary>(8) Operation to set properties of public chat channel or users in public chat channels.</summary>
|
||||
public const byte SetProperties = 8;
|
||||
}
|
||||
}
|
8
Assets/Photon/PhotonChat/Code/ChatOperationCode.cs.meta
Normal file
8
Assets/Photon/PhotonChat/Code/ChatOperationCode.cs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c90a2a73f3ce648409739c724d3e6cef
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
85
Assets/Photon/PhotonChat/Code/ChatParameterCode.cs
Normal file
85
Assets/Photon/PhotonChat/Code/ChatParameterCode.cs
Normal file
@ -0,0 +1,85 @@
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
|
||||
// <remarks>ChatClient is the main class of this api.</remarks>
|
||||
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Photon.Chat
|
||||
{
|
||||
/// <summary>
|
||||
/// Wraps up codes for parameters (in operations and events) used internally in Photon Chat. You don't have to use them directly usually.
|
||||
/// </summary>
|
||||
public class ChatParameterCode
|
||||
{
|
||||
/// <summary>(0) Array of chat channels.</summary>
|
||||
public const byte Channels = 0;
|
||||
/// <summary>(1) Name of a single chat channel.</summary>
|
||||
public const byte Channel = 1;
|
||||
/// <summary>(2) Array of chat messages.</summary>
|
||||
public const byte Messages = 2;
|
||||
/// <summary>(3) A single chat message.</summary>
|
||||
public const byte Message = 3;
|
||||
/// <summary>(4) Array of names of the users who sent the array of chat messages.</summary>
|
||||
public const byte Senders = 4;
|
||||
/// <summary>(5) Name of a the user who sent a chat message.</summary>
|
||||
public const byte Sender = 5;
|
||||
/// <summary>(6) Not used.</summary>
|
||||
public const byte ChannelUserCount = 6;
|
||||
/// <summary>(225) Name of user to send a (private) message to.</summary><remarks>The code is used in LoadBalancing and copied over here.</remarks>
|
||||
public const byte UserId = 225;
|
||||
/// <summary>(8) Id of a message.</summary>
|
||||
public const byte MsgId = 8;
|
||||
/// <summary>(9) Not used.</summary>
|
||||
public const byte MsgIds = 9;
|
||||
/// <summary>(221) Secret token to identify an authorized user.</summary><remarks>The code is used in LoadBalancing and copied over here.</remarks>
|
||||
public const byte Secret = 221;
|
||||
/// <summary>(15) Subscribe operation result parameter. A bool[] with result per channel.</summary>
|
||||
public const byte SubscribeResults = 15;
|
||||
|
||||
/// <summary>(10) Status</summary>
|
||||
public const byte Status = 10;
|
||||
/// <summary>(11) Friends</summary>
|
||||
public const byte Friends = 11;
|
||||
/// <summary>(12) SkipMessage is used in SetOnlineStatus and if true, the message is not being broadcast.</summary>
|
||||
public const byte SkipMessage = 12;
|
||||
|
||||
/// <summary>(14) Number of message to fetch from history. 0: no history. 1 and higher: number of messages in history. -1: all history.</summary>
|
||||
public const byte HistoryLength = 14;
|
||||
|
||||
public const byte DebugMessage = 17;
|
||||
|
||||
/// <summary>(21) WebFlags object for changing behaviour of webhooks from client.</summary>
|
||||
public const byte WebFlags = 21;
|
||||
|
||||
/// <summary>(22) WellKnown or custom properties of channel or user.</summary>
|
||||
/// <remarks>
|
||||
/// In event <see cref="ChatEventCode.Subscribe"/> it's always channel properties,
|
||||
/// in event <see cref="ChatEventCode.UserSubscribed"/> it's always user properties,
|
||||
/// in event <see cref="ChatEventCode.PropertiesChanged"/> it's channel properties unless <see cref="UserId"/> parameter value is not null
|
||||
/// </remarks>
|
||||
public const byte Properties = 22;
|
||||
/// <summary>(23) Array of UserIds of users already subscribed to a channel.</summary>
|
||||
/// <remarks>Used in Subscribe event when PublishSubscribers is enabled.
|
||||
/// Does not include local user who just subscribed.
|
||||
/// Maximum length is (<see cref="ChatChannel.MaxSubscribers"/> - 1).</remarks>
|
||||
public const byte ChannelSubscribers = 23;
|
||||
/// <summary>(24) Optional data sent in ErrorInfo event from Chat WebHooks. </summary>
|
||||
public const byte DebugData = 24;
|
||||
/// <summary>(25) Code for values to be used for "Check And Swap" (CAS) when changing properties.</summary>
|
||||
public const byte ExpectedValues = 25;
|
||||
/// <summary>(26) Code for broadcast parameter of <see cref="ChatOperationCode.SetProperties"/> method.</summary>
|
||||
public const byte Broadcast = 26;
|
||||
/// <summary>
|
||||
/// WellKnown and custom user properties.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Used only in event <see cref="ChatEventCode.Subscribe"/>
|
||||
/// </remarks>
|
||||
public const byte UserProperties = 28;
|
||||
|
||||
/// <summary>
|
||||
/// Generated unique reusable room id
|
||||
/// </summary>
|
||||
public const byte UniqueRoomId = 29;
|
||||
}
|
||||
}
|
8
Assets/Photon/PhotonChat/Code/ChatParameterCode.cs.meta
Normal file
8
Assets/Photon/PhotonChat/Code/ChatParameterCode.cs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7a17b60c85fb30448492e397c58c7ce
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
465
Assets/Photon/PhotonChat/Code/ChatPeer.cs
Normal file
465
Assets/Photon/PhotonChat/Code/ChatPeer.cs
Normal file
@ -0,0 +1,465 @@
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
|
||||
// <remarks>ChatClient is the main class of this api.</remarks>
|
||||
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#if UNITY_4_7 || UNITY_5 || UNITY_5_3_OR_NEWER
|
||||
#define SUPPORTED_UNITY
|
||||
#endif
|
||||
|
||||
namespace Photon.Chat
|
||||
{
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using ExitGames.Client.Photon;
|
||||
|
||||
#if SUPPORTED_UNITY || NETFX_CORE
|
||||
using Hashtable = ExitGames.Client.Photon.Hashtable;
|
||||
using SupportClass = ExitGames.Client.Photon.SupportClass;
|
||||
#endif
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Provides basic operations of the Photon Chat server. This internal class is used by public ChatClient.
|
||||
/// </summary>
|
||||
public class ChatPeer : PhotonPeer
|
||||
{
|
||||
/// <summary>Name Server Host Name for Photon Cloud. Without port and without any prefix.</summary>
|
||||
public string NameServerHost = "ns.photonengine.io";
|
||||
|
||||
/// <summary>Name Server port per protocol (the UDP port is different than TCP, etc).</summary>
|
||||
private static readonly Dictionary<ConnectionProtocol, int> ProtocolToNameServerPort = new Dictionary<ConnectionProtocol, int>() { { ConnectionProtocol.Udp, 5058 }, { ConnectionProtocol.Tcp, 4533 }, { ConnectionProtocol.WebSocket, 9093 }, { ConnectionProtocol.WebSocketSecure, 19093 } }; //, { ConnectionProtocol.RHttp, 6063 } };
|
||||
|
||||
/// <summary>Name Server Address for Photon Cloud (based on current protocol). You can use the default values and usually won't have to set this value.</summary>
|
||||
public string NameServerAddress { get { return this.GetNameServerAddress(); } }
|
||||
|
||||
virtual internal bool IsProtocolSecure { get { return this.UsedProtocol == ConnectionProtocol.WebSocketSecure; } }
|
||||
|
||||
/// <summary> Chat Peer constructor. </summary>
|
||||
/// <param name="listener">Chat listener implementation.</param>
|
||||
/// <param name="protocol">Protocol to be used by the peer.</param>
|
||||
public ChatPeer(IPhotonPeerListener listener, ConnectionProtocol protocol) : base(listener, protocol)
|
||||
{
|
||||
this.ConfigUnitySockets();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Sets up the socket implementations to use, depending on platform
|
||||
[System.Diagnostics.Conditional("SUPPORTED_UNITY")]
|
||||
private void ConfigUnitySockets()
|
||||
{
|
||||
Type websocketType = null;
|
||||
#if (UNITY_XBOXONE || UNITY_GAMECORE) && !UNITY_EDITOR
|
||||
websocketType = Type.GetType("ExitGames.Client.Photon.SocketNativeSource, Assembly-CSharp", false);
|
||||
if (websocketType == null)
|
||||
{
|
||||
websocketType = Type.GetType("ExitGames.Client.Photon.SocketNativeSource, Assembly-CSharp-firstpass", false);
|
||||
}
|
||||
if (websocketType == null)
|
||||
{
|
||||
websocketType = Type.GetType("ExitGames.Client.Photon.SocketNativeSource, PhotonRealtime", false);
|
||||
}
|
||||
if (websocketType != null)
|
||||
{
|
||||
this.SocketImplementationConfig[ConnectionProtocol.Udp] = websocketType; // on Xbox, the native socket plugin supports UDP as well
|
||||
}
|
||||
#else
|
||||
// to support WebGL export in Unity, we find and assign the SocketWebTcp class (if it's in the project).
|
||||
// alternatively class SocketWebTcp might be in the Photon3Unity3D.dll
|
||||
websocketType = Type.GetType("ExitGames.Client.Photon.SocketWebTcp, PhotonWebSocket", false);
|
||||
if (websocketType == null)
|
||||
{
|
||||
websocketType = Type.GetType("ExitGames.Client.Photon.SocketWebTcp, Assembly-CSharp-firstpass", false);
|
||||
}
|
||||
if (websocketType == null)
|
||||
{
|
||||
websocketType = Type.GetType("ExitGames.Client.Photon.SocketWebTcp, Assembly-CSharp", false);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (websocketType != null)
|
||||
{
|
||||
this.SocketImplementationConfig[ConnectionProtocol.WebSocket] = websocketType;
|
||||
this.SocketImplementationConfig[ConnectionProtocol.WebSocketSecure] = websocketType;
|
||||
}
|
||||
|
||||
#if NET_4_6 && (UNITY_EDITOR || !ENABLE_IL2CPP) && !NETFX_CORE
|
||||
this.SocketImplementationConfig[ConnectionProtocol.Udp] = typeof(SocketUdpAsync);
|
||||
this.SocketImplementationConfig[ConnectionProtocol.Tcp] = typeof(SocketTcpAsync);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>If not zero, this is used for the name server port on connect. Independent of protocol (so this better matches). Set by ChatClient.ConnectUsingSettings.</summary>
|
||||
/// <remarks>This is reset when the protocol fallback is used.</remarks>
|
||||
public ushort NameServerPortOverride;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the NameServer Address (with prefix and port), based on the set protocol (this.UsedProtocol).
|
||||
/// </summary>
|
||||
/// <returns>NameServer Address (with prefix and port).</returns>
|
||||
private string GetNameServerAddress()
|
||||
{
|
||||
var protocolPort = 0;
|
||||
ProtocolToNameServerPort.TryGetValue(this.TransportProtocol, out protocolPort);
|
||||
|
||||
if (this.NameServerPortOverride != 0)
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.INFO, string.Format("Using NameServerPortInAppSettings as port for Name Server: {0}", this.NameServerPortOverride));
|
||||
protocolPort = this.NameServerPortOverride;
|
||||
}
|
||||
|
||||
switch (this.TransportProtocol)
|
||||
{
|
||||
case ConnectionProtocol.Udp:
|
||||
case ConnectionProtocol.Tcp:
|
||||
return string.Format("{0}:{1}", NameServerHost, protocolPort);
|
||||
case ConnectionProtocol.WebSocket:
|
||||
return string.Format("ws://{0}:{1}", NameServerHost, protocolPort);
|
||||
case ConnectionProtocol.WebSocketSecure:
|
||||
return string.Format("wss://{0}:{1}", NameServerHost, protocolPort);
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Connects to NameServer. </summary>
|
||||
/// <returns>If the connection attempt could be sent.</returns>
|
||||
public bool Connect()
|
||||
{
|
||||
if (this.DebugOut >= DebugLevel.INFO)
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.INFO, "Connecting to nameserver " + this.NameServerAddress);
|
||||
}
|
||||
|
||||
return this.Connect(this.NameServerAddress, "NameServer");
|
||||
}
|
||||
|
||||
/// <summary> Authenticates on NameServer. </summary>
|
||||
/// <returns>If the authentication operation request could be sent.</returns>
|
||||
public bool AuthenticateOnNameServer(string appId, string appVersion, string region, AuthenticationValues authValues)
|
||||
{
|
||||
if (this.DebugOut >= DebugLevel.INFO)
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.INFO, "OpAuthenticate()");
|
||||
}
|
||||
|
||||
var opParameters = new Dictionary<byte, object>();
|
||||
|
||||
opParameters[ParameterCode.AppVersion] = appVersion;
|
||||
opParameters[ParameterCode.ApplicationId] = appId;
|
||||
opParameters[ParameterCode.Region] = region;
|
||||
|
||||
if (authValues != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(authValues.UserId))
|
||||
{
|
||||
opParameters[ParameterCode.UserId] = authValues.UserId;
|
||||
}
|
||||
|
||||
if (authValues.AuthType != CustomAuthenticationType.None)
|
||||
{
|
||||
opParameters[ParameterCode.ClientAuthenticationType] = (byte) authValues.AuthType;
|
||||
if (authValues.Token != null)
|
||||
{
|
||||
opParameters[ParameterCode.Secret] = authValues.Token;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(authValues.AuthGetParameters))
|
||||
{
|
||||
opParameters[ParameterCode.ClientAuthenticationParams] = authValues.AuthGetParameters;
|
||||
}
|
||||
if (authValues.AuthPostData != null)
|
||||
{
|
||||
opParameters[ParameterCode.ClientAuthenticationData] = authValues.AuthPostData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.SendOperation(ChatOperationCode.Authenticate, opParameters, new SendOptions() { Reliability = true, Encrypt = this.IsEncryptionAvailable });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Options for optional "Custom Authentication" services used with Photon. Used by OpAuthenticate after connecting to Photon.
|
||||
/// </summary>
|
||||
public enum CustomAuthenticationType : byte
|
||||
{
|
||||
/// <summary>Use a custom authentication service. Currently the only implemented option.</summary>
|
||||
Custom = 0,
|
||||
|
||||
/// <summary>Authenticates users by their Steam Account. Set Steam's ticket as "ticket" via AddAuthParameter().</summary>
|
||||
Steam = 1,
|
||||
|
||||
/// <summary>Authenticates users by their Facebook Account. Set Facebooks's tocken as "token" via AddAuthParameter().</summary>
|
||||
Facebook = 2,
|
||||
|
||||
/// <summary>Authenticates users by their Oculus Account and token. Set Oculus' userid as "userid" and nonce as "nonce" via AddAuthParameter().</summary>
|
||||
Oculus = 3,
|
||||
|
||||
/// <summary>Authenticates users by their PSN Account and token on PS4. Set token as "token", env as "env" and userName as "userName" via AddAuthParameter().</summary>
|
||||
PlayStation4 = 4,
|
||||
[Obsolete("Use PlayStation4 or PlayStation5 as needed")]
|
||||
PlayStation = 4,
|
||||
|
||||
/// <summary>Authenticates users by their Xbox Account. Pass the XSTS token via SetAuthPostData().</summary>
|
||||
Xbox = 5,
|
||||
|
||||
/// <summary>Authenticates users by their HTC Viveport Account. Set userToken as "userToken" via AddAuthParameter().</summary>
|
||||
Viveport = 10,
|
||||
|
||||
/// <summary>Authenticates users by their NSA ID. Set token as "token" and appversion as "appversion" via AddAuthParameter(). The appversion is optional.</summary>
|
||||
NintendoSwitch = 11,
|
||||
|
||||
/// <summary>Authenticates users by their PSN Account and token on PS5. Set token as "token", env as "env" and userName as "userName" via AddAuthParameter().</summary>
|
||||
PlayStation5 = 12,
|
||||
[Obsolete("Use PlayStation4 or PlayStation5 as needed")]
|
||||
Playstation5 = 12,
|
||||
|
||||
/// <summary>Authenticates users with Epic Online Services (EOS). Set token as "token" and ownershipToken as "ownershipToken" via AddAuthParameter(). The ownershipToken is optional.</summary>
|
||||
Epic = 13,
|
||||
|
||||
/// <summary>Authenticates users with Facebook Gaming api. Set token as "token" via AddAuthParameter().</summary>
|
||||
FacebookGaming = 15,
|
||||
|
||||
/// <summary>Disables custom authentication. Same as not providing any AuthenticationValues for connect (more precisely for: OpAuthenticate).</summary>
|
||||
None = byte.MaxValue
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Container for user authentication in Photon. Set AuthValues before you connect - all else is handled.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// On Photon, user authentication is optional but can be useful in many cases.
|
||||
/// If you want to FindFriends, a unique ID per user is very practical.
|
||||
///
|
||||
/// There are basically three options for user authentication: None at all, the client sets some UserId
|
||||
/// or you can use some account web-service to authenticate a user (and set the UserId server-side).
|
||||
///
|
||||
/// Custom Authentication lets you verify end-users by some kind of login or token. It sends those
|
||||
/// values to Photon which will verify them before granting access or disconnecting the client.
|
||||
///
|
||||
/// The AuthValues are sent in OpAuthenticate when you connect, so they must be set before you connect.
|
||||
/// If the AuthValues.UserId is null or empty when it's sent to the server, then the Photon Server assigns a UserId!
|
||||
///
|
||||
/// The Photon Cloud Dashboard will let you enable this feature and set important server values for it.
|
||||
/// https://dashboard.photonengine.com
|
||||
/// </remarks>
|
||||
public class AuthenticationValues
|
||||
{
|
||||
/// <summary>See AuthType.</summary>
|
||||
private CustomAuthenticationType authType = CustomAuthenticationType.None;
|
||||
|
||||
/// <summary>The type of authentication provider that should be used. Defaults to None (no auth whatsoever).</summary>
|
||||
/// <remarks>Several auth providers are available and CustomAuthenticationType.Custom can be used if you build your own service.</remarks>
|
||||
public CustomAuthenticationType AuthType
|
||||
{
|
||||
get { return authType; }
|
||||
set { authType = value; }
|
||||
}
|
||||
|
||||
/// <summary>This string must contain any (http get) parameters expected by the used authentication service. By default, username and token.</summary>
|
||||
/// <remarks>
|
||||
/// Maps to operation parameter 216.
|
||||
/// Standard http get parameters are used here and passed on to the service that's defined in the server (Photon Cloud Dashboard).
|
||||
/// </remarks>
|
||||
public string AuthGetParameters { get; set; }
|
||||
|
||||
/// <summary>Data to be passed-on to the auth service via POST. Default: null (not sent). Either string or byte[] (see setters).</summary>
|
||||
/// <remarks>Maps to operation parameter 214.</remarks>
|
||||
public object AuthPostData { get; private set; }
|
||||
|
||||
/// <summary>Internal <b>Photon token</b>. After initial authentication, Photon provides a token for this client, subsequently used as (cached) validation.</summary>
|
||||
/// <remarks>Any token for custom authentication should be set via SetAuthPostData or AddAuthParameter.</remarks>
|
||||
public object Token { get; protected internal set; }
|
||||
|
||||
/// <summary>The UserId should be a unique identifier per user. This is for finding friends, etc..</summary>
|
||||
/// <remarks>See remarks of AuthValues for info about how this is set and used.</remarks>
|
||||
public string UserId { get; set; }
|
||||
|
||||
|
||||
/// <summary>Creates empty auth values without any info.</summary>
|
||||
public AuthenticationValues()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Creates minimal info about the user. If this is authenticated or not, depends on the set AuthType.</summary>
|
||||
/// <param name="userId">Some UserId to set in Photon.</param>
|
||||
public AuthenticationValues(string userId)
|
||||
{
|
||||
this.UserId = userId;
|
||||
}
|
||||
|
||||
/// <summary>Sets the data to be passed-on to the auth service via POST.</summary>
|
||||
/// <remarks>AuthPostData is just one value. Each SetAuthPostData replaces any previous value. It can be either a string, a byte[] or a dictionary.</remarks>
|
||||
/// <param name="stringData">String data to be used in the body of the POST request. Null or empty string will set AuthPostData to null.</param>
|
||||
public virtual void SetAuthPostData(string stringData)
|
||||
{
|
||||
this.AuthPostData = (string.IsNullOrEmpty(stringData)) ? null : stringData;
|
||||
}
|
||||
|
||||
/// <summary>Sets the data to be passed-on to the auth service via POST.</summary>
|
||||
/// <remarks>AuthPostData is just one value. Each SetAuthPostData replaces any previous value. It can be either a string, a byte[] or a dictionary.</remarks>
|
||||
/// <param name="byteData">Binary token / auth-data to pass on.</param>
|
||||
public virtual void SetAuthPostData(byte[] byteData)
|
||||
{
|
||||
this.AuthPostData = byteData;
|
||||
}
|
||||
|
||||
/// <summary>Sets data to be passed-on to the auth service as Json (Content-Type: "application/json") via Post.</summary>
|
||||
/// <remarks>AuthPostData is just one value. Each SetAuthPostData replaces any previous value. It can be either a string, a byte[] or a dictionary.</remarks>
|
||||
/// <param name="dictData">A authentication-data dictionary will be converted to Json and passed to the Auth webservice via HTTP Post.</param>
|
||||
public virtual void SetAuthPostData(Dictionary<string, object> dictData)
|
||||
{
|
||||
this.AuthPostData = dictData;
|
||||
}
|
||||
|
||||
/// <summary>Adds a key-value pair to the get-parameters used for Custom Auth (AuthGetParameters).</summary>
|
||||
/// <remarks>This method does uri-encoding for you.</remarks>
|
||||
/// <param name="key">Key for the value to set.</param>
|
||||
/// <param name="value">Some value relevant for Custom Authentication.</param>
|
||||
public virtual void AddAuthParameter(string key, string value)
|
||||
{
|
||||
string ampersand = string.IsNullOrEmpty(this.AuthGetParameters) ? "" : "&";
|
||||
this.AuthGetParameters = string.Format("{0}{1}{2}={3}", this.AuthGetParameters, ampersand, System.Uri.EscapeDataString(key), System.Uri.EscapeDataString(value));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transform this object into string.
|
||||
/// </summary>
|
||||
/// <returns>string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("AuthenticationValues Type: {3} UserId: {0}, GetParameters: {1} Token available: {2}", this.UserId, this.AuthGetParameters, this.Token != null, this.AuthType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make a copy of the current object.
|
||||
/// </summary>
|
||||
/// <param name="copy">The object to be copied into.</param>
|
||||
/// <returns>The copied object.</returns>
|
||||
public AuthenticationValues CopyTo(AuthenticationValues copy)
|
||||
{
|
||||
copy.AuthType = this.AuthType;
|
||||
copy.AuthGetParameters = this.AuthGetParameters;
|
||||
copy.AuthPostData = this.AuthPostData;
|
||||
copy.UserId = this.UserId;
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Class for constants. Codes for parameters of Operations and Events.</summary>
|
||||
public class ParameterCode
|
||||
{
|
||||
/// <summary>(224) Your application's ID: a name on your own Photon or a GUID on the Photon Cloud</summary>
|
||||
public const byte ApplicationId = 224;
|
||||
/// <summary>(221) Internally used to establish encryption</summary>
|
||||
public const byte Secret = 221;
|
||||
/// <summary>(220) Version of your application</summary>
|
||||
public const byte AppVersion = 220;
|
||||
/// <summary>(217) This key's (byte) value defines the target custom authentication type/service the client connects with. Used in OpAuthenticate</summary>
|
||||
public const byte ClientAuthenticationType = 217;
|
||||
/// <summary>(216) This key's (string) value provides parameters sent to the custom authentication type/service the client connects with. Used in OpAuthenticate</summary>
|
||||
public const byte ClientAuthenticationParams = 216;
|
||||
/// <summary>(214) This key's (string or byte[]) value provides parameters sent to the custom authentication service setup in Photon Dashboard. Used in OpAuthenticate</summary>
|
||||
public const byte ClientAuthenticationData = 214;
|
||||
/// <summary>(210) Used for region values in OpAuth and OpGetRegions.</summary>
|
||||
public const byte Region = 210;
|
||||
/// <summary>(230) Address of a (game) server to use.</summary>
|
||||
public const byte Address = 230;
|
||||
/// <summary>(225) User's ID</summary>
|
||||
public const byte UserId = 225;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ErrorCode defines the default codes associated with Photon client/server communication.
|
||||
/// </summary>
|
||||
public class ErrorCode
|
||||
{
|
||||
/// <summary>(0) is always "OK", anything else an error or specific situation.</summary>
|
||||
public const int Ok = 0;
|
||||
|
||||
// server - Photon low(er) level: <= 0
|
||||
|
||||
/// <summary>
|
||||
/// (-3) Operation can't be executed yet (e.g. OpJoin can't be called before being authenticated, RaiseEvent cant be used before getting into a room).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Before you call any operations on the Cloud servers, the automated client workflow must complete its authorization.
|
||||
/// In PUN, wait until State is: JoinedLobby or ConnectedToMaster
|
||||
/// </remarks>
|
||||
public const int OperationNotAllowedInCurrentState = -3;
|
||||
|
||||
/// <summary>(-2) The operation you called is not implemented on the server (application) you connect to. Make sure you run the fitting applications.</summary>
|
||||
public const int InvalidOperationCode = -2;
|
||||
|
||||
/// <summary>(-1) Something went wrong in the server. Try to reproduce and contact Exit Games.</summary>
|
||||
public const int InternalServerError = -1;
|
||||
|
||||
// server - PhotonNetwork: 0x7FFF and down
|
||||
// logic-level error codes start with short.max
|
||||
|
||||
/// <summary>(32767) Authentication failed. Possible cause: AppId is unknown to Photon (in cloud service).</summary>
|
||||
public const int InvalidAuthentication = 0x7FFF;
|
||||
|
||||
/// <summary>(32766) GameId (name) already in use (can't create another). Change name.</summary>
|
||||
public const int GameIdAlreadyExists = 0x7FFF - 1;
|
||||
|
||||
/// <summary>(32765) Game is full. This rarely happens when some player joined the room before your join completed.</summary>
|
||||
public const int GameFull = 0x7FFF - 2;
|
||||
|
||||
/// <summary>(32764) Game is closed and can't be joined. Join another game.</summary>
|
||||
public const int GameClosed = 0x7FFF - 3;
|
||||
|
||||
/// <summary>(32762) Not in use currently.</summary>
|
||||
public const int ServerFull = 0x7FFF - 5;
|
||||
|
||||
/// <summary>(32761) Not in use currently.</summary>
|
||||
public const int UserBlocked = 0x7FFF - 6;
|
||||
|
||||
/// <summary>(32760) Random matchmaking only succeeds if a room exists that is neither closed nor full. Repeat in a few seconds or create a new room.</summary>
|
||||
public const int NoRandomMatchFound = 0x7FFF - 7;
|
||||
|
||||
/// <summary>(32758) Join can fail if the room (name) is not existing (anymore). This can happen when players leave while you join.</summary>
|
||||
public const int GameDoesNotExist = 0x7FFF - 9;
|
||||
|
||||
/// <summary>(32757) Authorization on the Photon Cloud failed because the concurrent users (CCU) limit of the app's subscription is reached.</summary>
|
||||
/// <remarks>
|
||||
/// Unless you have a plan with "CCU Burst", clients might fail the authentication step during connect.
|
||||
/// Affected client are unable to call operations. Please note that players who end a game and return
|
||||
/// to the master server will disconnect and re-connect, which means that they just played and are rejected
|
||||
/// in the next minute / re-connect.
|
||||
/// This is a temporary measure. Once the CCU is below the limit, players will be able to connect an play again.
|
||||
///
|
||||
/// OpAuthorize is part of connection workflow but only on the Photon Cloud, this error can happen.
|
||||
/// Self-hosted Photon servers with a CCU limited license won't let a client connect at all.
|
||||
/// </remarks>
|
||||
public const int MaxCcuReached = 0x7FFF - 10;
|
||||
|
||||
/// <summary>(32756) Authorization on the Photon Cloud failed because the app's subscription does not allow to use a particular region's server.</summary>
|
||||
/// <remarks>
|
||||
/// Some subscription plans for the Photon Cloud are region-bound. Servers of other regions can't be used then.
|
||||
/// Check your master server address and compare it with your Photon Cloud Dashboard's info.
|
||||
/// https://cloud.photonengine.com/dashboard
|
||||
///
|
||||
/// OpAuthorize is part of connection workflow but only on the Photon Cloud, this error can happen.
|
||||
/// Self-hosted Photon servers with a CCU limited license won't let a client connect at all.
|
||||
/// </remarks>
|
||||
public const int InvalidRegion = 0x7FFF - 11;
|
||||
|
||||
/// <summary>
|
||||
/// (32755) Custom Authentication of the user failed due to setup reasons (see Cloud Dashboard) or the provided user data (like username or token). Check error message for details.
|
||||
/// </summary>
|
||||
public const int CustomAuthenticationFailed = 0x7FFF - 12;
|
||||
|
||||
/// <summary>(32753) The Authentication ticket expired. Usually, this is refreshed behind the scenes. Connect (and authorize) again.</summary>
|
||||
public const int AuthenticationTicketExpired = 0x7FF1;
|
||||
}
|
||||
|
||||
}
|
8
Assets/Photon/PhotonChat/Code/ChatPeer.cs.meta
Normal file
8
Assets/Photon/PhotonChat/Code/ChatPeer.cs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f712805dec728943a668b3bf19dc422
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
39
Assets/Photon/PhotonChat/Code/ChatState.cs
Normal file
39
Assets/Photon/PhotonChat/Code/ChatState.cs
Normal file
@ -0,0 +1,39 @@
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
|
||||
// <remarks>ChatClient is the main class of this api.</remarks>
|
||||
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Photon.Chat
|
||||
{
|
||||
/// <summary>Possible states for a Chat Client.</summary>
|
||||
public enum ChatState
|
||||
{
|
||||
/// <summary>Peer is created but not used yet.</summary>
|
||||
Uninitialized,
|
||||
/// <summary>Connecting to name server.</summary>
|
||||
ConnectingToNameServer,
|
||||
/// <summary>Connected to name server.</summary>
|
||||
ConnectedToNameServer,
|
||||
/// <summary>Authenticating on current server.</summary>
|
||||
Authenticating,
|
||||
/// <summary>Finished authentication on current server.</summary>
|
||||
Authenticated,
|
||||
/// <summary>Disconnecting from name server. This is usually a transition from name server to frontend server.</summary>
|
||||
DisconnectingFromNameServer,
|
||||
/// <summary>Connecting to frontend server.</summary>
|
||||
ConnectingToFrontEnd,
|
||||
/// <summary>Connected to frontend server.</summary>
|
||||
ConnectedToFrontEnd,
|
||||
/// <summary>Disconnecting from frontend server.</summary>
|
||||
DisconnectingFromFrontEnd,
|
||||
/// <summary>Currently not used.</summary>
|
||||
QueuedComingFromFrontEnd,
|
||||
/// <summary>The client disconnects (from any server).</summary>
|
||||
Disconnecting,
|
||||
/// <summary>The client is no longer connected (to any server).</summary>
|
||||
Disconnected,
|
||||
/// <summary>Client was unable to connect to Name Server and will attempt to connect with an alternative network protocol (TCP).</summary>
|
||||
ConnectWithFallbackProtocol
|
||||
}
|
||||
}
|
8
Assets/Photon/PhotonChat/Code/ChatState.cs.meta
Normal file
8
Assets/Photon/PhotonChat/Code/ChatState.cs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f482d8c4fe7ade4cbb08eb4a2d83b39
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
35
Assets/Photon/PhotonChat/Code/ChatUserStatus.cs
Normal file
35
Assets/Photon/PhotonChat/Code/ChatUserStatus.cs
Normal file
@ -0,0 +1,35 @@
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
|
||||
// <remarks>ChatClient is the main class of this api.</remarks>
|
||||
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Photon.Chat
|
||||
{
|
||||
/// <summary>Contains commonly used status values for SetOnlineStatus. You can define your own.</summary>
|
||||
/// <remarks>
|
||||
/// While "online" (value 2 and up), the status message will be sent to anyone who has you on his friend list.
|
||||
///
|
||||
/// Define custom online status values as you like with these rules:
|
||||
/// 0: Means "offline". It will be used when you are not connected. In this status, there is no status message.
|
||||
/// 1: Means "invisible" and is sent to friends as "offline". They see status 0, no message but you can chat.
|
||||
/// 2: And any higher value will be treated as "online". Status can be set.
|
||||
/// </remarks>
|
||||
public static class ChatUserStatus
|
||||
{
|
||||
/// <summary>(0) Offline.</summary>
|
||||
public const int Offline = 0;
|
||||
/// <summary>(1) Be invisible to everyone. Sends no message.</summary>
|
||||
public const int Invisible = 1;
|
||||
/// <summary>(2) Online and available.</summary>
|
||||
public const int Online = 2;
|
||||
/// <summary>(3) Online but not available.</summary>
|
||||
public const int Away = 3;
|
||||
/// <summary>(4) Do not disturb.</summary>
|
||||
public const int DND = 4;
|
||||
/// <summary>(5) Looking For Game/Group. Could be used when you want to be invited or do matchmaking.</summary>
|
||||
public const int LFG = 5;
|
||||
/// <summary>(6) Could be used when in a room, playing.</summary>
|
||||
public const int Playing = 6;
|
||||
}
|
||||
}
|
8
Assets/Photon/PhotonChat/Code/ChatUserStatus.cs.meta
Normal file
8
Assets/Photon/PhotonChat/Code/ChatUserStatus.cs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7db67e7f5face2e42b6daafcaf4e6c82
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
148
Assets/Photon/PhotonChat/Code/IChatClientListener.cs
Normal file
148
Assets/Photon/PhotonChat/Code/IChatClientListener.cs
Normal file
@ -0,0 +1,148 @@
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
|
||||
// <remarks>ChatClient is the main class of this api.</remarks>
|
||||
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
|
||||
// ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Photon.Chat
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using ExitGames.Client.Photon;
|
||||
|
||||
/// <summary>
|
||||
/// Callback interface for Chat client side. Contains callback methods to notify your app about updates.
|
||||
/// Must be provided to new ChatClient in constructor
|
||||
/// </summary>
|
||||
public interface IChatClientListener
|
||||
{
|
||||
/// <summary>
|
||||
/// All debug output of the library will be reported through this method. Print it or put it in a
|
||||
/// buffer to use it on-screen.
|
||||
/// </summary>
|
||||
/// <param name="level">DebugLevel (severity) of the message.</param>
|
||||
/// <param name="message">Debug text. Print to System.Console or screen.</param>
|
||||
void DebugReturn(DebugLevel level, string message);
|
||||
|
||||
/// <summary>
|
||||
/// Disconnection happened.
|
||||
/// </summary>
|
||||
void OnDisconnected();
|
||||
|
||||
/// <summary>
|
||||
/// Client is connected now.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Clients have to be connected before they can send their state, subscribe to channels and send any messages.
|
||||
/// </remarks>
|
||||
void OnConnected();
|
||||
|
||||
/// <summary>The ChatClient's state changed. Usually, OnConnected and OnDisconnected are the callbacks to react to.</summary>
|
||||
/// <param name="state">The new state.</param>
|
||||
void OnChatStateChange(ChatState state);
|
||||
|
||||
/// <summary>
|
||||
/// Notifies app that client got new messages from server
|
||||
/// Number of senders is equal to number of messages in 'messages'. Sender with number '0' corresponds to message with
|
||||
/// number '0', sender with number '1' corresponds to message with number '1' and so on
|
||||
/// </summary>
|
||||
/// <param name="channelName">channel from where messages came</param>
|
||||
/// <param name="senders">list of users who sent messages</param>
|
||||
/// <param name="messages">list of messages it self</param>
|
||||
void OnGetMessages(string channelName, string[] senders, object[] messages);
|
||||
|
||||
/// <summary>
|
||||
/// Notifies client about private message
|
||||
/// </summary>
|
||||
/// <param name="sender">user who sent this message</param>
|
||||
/// <param name="message">message it self</param>
|
||||
/// <param name="channelName">channelName for private messages (messages you sent yourself get added to a channel per target username)</param>
|
||||
void OnPrivateMessage(string sender, object message, string channelName);
|
||||
|
||||
/// <summary>
|
||||
/// Result of Subscribe operation. Returns subscription result for every requested channel name.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If multiple channels sent in Subscribe operation, OnSubscribed may be called several times, each call with part of sent array or with single channel in "channels" parameter.
|
||||
/// Calls order and order of channels in "channels" parameter may differ from order of channels in "channels" parameter of Subscribe operation.
|
||||
/// </remarks>
|
||||
/// <param name="channels">Array of channel names.</param>
|
||||
/// <param name="results">Per channel result if subscribed.</param>
|
||||
void OnSubscribed(string[] channels, bool[] results);
|
||||
|
||||
/// <summary>
|
||||
/// Result of Unsubscribe operation. Returns for channel name if the channel is now unsubscribed.
|
||||
/// </summary>
|
||||
/// If multiple channels sent in Unsubscribe operation, OnUnsubscribed may be called several times, each call with part of sent array or with single channel in "channels" parameter.
|
||||
/// Calls order and order of channels in "channels" parameter may differ from order of channels in "channels" parameter of Unsubscribe operation.
|
||||
/// <param name="channels">Array of channel names that are no longer subscribed.</param>
|
||||
void OnUnsubscribed(string[] channels);
|
||||
|
||||
/// <summary>
|
||||
/// New status of another user (you get updates for users set in your friends list).
|
||||
/// </summary>
|
||||
/// <param name="user">Name of the user.</param>
|
||||
/// <param name="status">New status of that user.</param>
|
||||
/// <param name="gotMessage">True if the status contains a message you should cache locally. False: This status update does not include a message (keep any you have).</param>
|
||||
/// <param name="message">Message that user set.</param>
|
||||
void OnStatusUpdate(string user, int status, bool gotMessage, object message);
|
||||
|
||||
/// <summary>
|
||||
/// A user has subscribed to a public chat channel
|
||||
/// </summary>
|
||||
/// <param name="channel">Name of the chat channel</param>
|
||||
/// <param name="user">UserId of the user who subscribed</param>
|
||||
void OnUserSubscribed(string channel, string user);
|
||||
|
||||
/// <summary>
|
||||
/// A user has unsubscribed from a public chat channel
|
||||
/// </summary>
|
||||
/// <param name="channel">Name of the chat channel</param>
|
||||
/// <param name="user">UserId of the user who unsubscribed</param>
|
||||
void OnUserUnsubscribed(string channel, string user);
|
||||
|
||||
|
||||
#if CHAT_EXTENDED
|
||||
|
||||
/// <summary>
|
||||
/// Properties of a public channel has been changed
|
||||
/// </summary>
|
||||
/// <param name="channel">Channel name in which the properties have changed</param>
|
||||
/// <param name="senderUserId">The UserID of the user who changed the properties</param>
|
||||
/// <param name="properties">The properties that have changed</param>
|
||||
void OnChannelPropertiesChanged(string channel, string senderUserId, Dictionary<object, object> properties);
|
||||
|
||||
/// <summary>
|
||||
/// Properties of a user in a public channel has been changed
|
||||
/// </summary>
|
||||
/// <param name="channel">Channel name in which the properties have changed</param>
|
||||
/// <param name="targetUserId">The UserID whom properties have changed</param>
|
||||
/// <param name="senderUserId">The UserID of the user who changed the properties</param>
|
||||
/// <param name="properties">The properties that have changed</param>
|
||||
void OnUserPropertiesChanged(string channel, string targetUserId, string senderUserId, Dictionary<object, object> properties);
|
||||
|
||||
/// <summary>
|
||||
/// The server uses error events to make the client aware of some issues.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is currently used only in Chat WebHooks.
|
||||
/// </remarks>
|
||||
/// <param name="channel">The name of the channel in which this error info has been received</param>
|
||||
/// <param name="error">The text message of the error info</param>
|
||||
/// <param name="data">Optional error data</param>
|
||||
void OnErrorInfo(string channel, string error, object data);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if SDK_V4
|
||||
/// <summary>
|
||||
/// Received a broadcast message
|
||||
/// </summary>
|
||||
/// <param name="channel">Name of the chat channel</param>
|
||||
/// <param name="message">Message data</param>
|
||||
void OnReceiveBroadcastMessage(string channel, byte[] message);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bab7c8053b486e34aa0d4ca99dcbec80
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
12
Assets/Photon/PhotonChat/Code/PhotonChat.asmdef
Normal file
12
Assets/Photon/PhotonChat/Code/PhotonChat.asmdef
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "PhotonChat",
|
||||
"references": [],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": []
|
||||
}
|
8
Assets/Photon/PhotonChat/Code/PhotonChat.asmdef.meta
Normal file
8
Assets/Photon/PhotonChat/Code/PhotonChat.asmdef.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08a110bd598f7604f9519c2d7e1fb3cc
|
||||
timeCreated: 1537459565
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
137
Assets/Photon/PhotonChat/Code/changes-chat.txt
Normal file
137
Assets/Photon/PhotonChat/Code/changes-chat.txt
Normal file
@ -0,0 +1,137 @@
|
||||
|
||||
Photon Chat C# Client - Changelog
|
||||
Exit Games GmbH - www.photonengine.com - forum.photonengine.com
|
||||
|
||||
|
||||
Version 4.1.6.11 (22. November 2021)
|
||||
Added: CustomAuthenticationType.Epic to authenticate via Epic Online Services (EOS).
|
||||
Added: CustomAuthenticationType.FacebookGaming to authenticate via Facebook Gaming services.
|
||||
|
||||
Version 4.1.6.10 (21. October 2021 - rev6243)
|
||||
Fixed: The ChatPeer.ConfigUnitySockets(), which used a surplus typeof() for Xbox configuration.
|
||||
|
||||
Version 4.1.6.6 (21. September 2021 - rev6204)
|
||||
Changed: For Xbox, order of checked assemblies when getting Type SocketNativeSource. It's more likely to be in Assembly-CSharp.
|
||||
|
||||
Version 4.1.6.5 (24. August 2021 - rev6181)
|
||||
Updated: The default name server host to "ns.photonengine.io". When using WSS on this, it expects TLS1.2 (Win 7 and old Unity versions may not support this).
|
||||
|
||||
Version 4.1.6.2 (17. June 2021)
|
||||
Changed: The enumeration CustomAuthenticationType was changed to fix naming inconsistencies. Use PlayStation4 and PlayStation5 respectively. Old variants are available as obsolete.
|
||||
|
||||
Version 4.1.5.2 (12. March 2021)
|
||||
ADDED: CustomAuthenticationType.Playstation5 (value 12).
|
||||
|
||||
Version 4.1.5.0 (03. March 2021)
|
||||
Updated: ChatPeer ConfigUnitySockets() to the analog of the Realtime API.
|
||||
|
||||
Version 4.1.5.0 (3. February 2021)
|
||||
Internal: AuthenticationValues.Token is now an object instead of a string (so some internal code changed). This enables the server to send a byte[], which is more effective than a string.
|
||||
|
||||
Version 4.1.4.6 (16. November 2020)
|
||||
Added: ChatClient.PrivateChatHistoryLength field. If set before you connect, this can be used to limit the number of private messages when the server (re)subscribes the client to (still alive) a private chat channel.
|
||||
Added: Protocol Fallback option for Chat. Analog to the Realtime API, Chat can now try another protocol, if the initial connect to the Name Server fails. After the timeout or when an error happened, UDP will fallback to TCP. TCP will fallback to UDP.
|
||||
Added: EnableProtocolFallback in ChatClient and ChatAppSettings. When using ConnectUsingSettings, the ChatClient's value gets set and used.
|
||||
Changed: Connect(appid, appversion, authValues) will only apply the authvalues parameter, if that's non-null.
|
||||
Changed: ChatAppSettings field AppId is now AppIdChat (matching the value in Realtime API AppSettings). The old name is currently just obsolete.
|
||||
Added: ChatAppSettings.Port to override the Name Server Port if needed. Note: Chat does not support "Alternative Ports" yet (ports pre-defined per server).
|
||||
Added: ChatPeer.NameServerPortOverride value to replace/override the default per-protocol port value (by the one in the AppSettings, e.g.).
|
||||
|
||||
Version 4.1.4.5 (02. September 2020)
|
||||
Added: Option for extended features: Channels may send a user list, channels and users can have custom properties and there are web-forwarding flags. Needs compile define CHAT_EXTENDED. This also adds new methods to the IChatClientListener.
|
||||
Changed: AuthenticationValues has been refined, analog to the changes in the Realtime API.
|
||||
|
||||
Version 4.1.4.2 (8. May 2020 - rev5519)
|
||||
Added: Broadcast receive and read channel using UniqueRoomID UniqueRoomID read from SubscribeChannel response
|
||||
|
||||
Version 4.1.2.20
|
||||
Changed: ChatDisconnectCause enum and OnDisconnected callback usage updated to be in sync. with Realtime.
|
||||
Added: ChatClient.ConnectUsingSettings(ChatAppSettings appSettings).
|
||||
Added: more error logs when something fails internally.
|
||||
|
||||
Version 4.1.2.19 (12. November 2019 - rev5266)
|
||||
Changed: ChatPeer now look for SocketNativeSource instead of SocketWebTcpNativeDynamic when the target platform is XB One. A new Xbox addon is coming up on our SDK page.
|
||||
|
||||
Version 4.1.2.16 (25. June 2019 - rev5168)
|
||||
Added: ChatClient.TryGetPrivateChannelByUser.
|
||||
|
||||
Version 4.1.2.14 (6. May 2019 - rev5097)
|
||||
Changed: Chat API changes are now listed in a separate changes file.
|
||||
|
||||
Version 4.1.2.13 (3. May 2019 - rev5086)
|
||||
Fixed: Properly add local client's UserId to public channels' Subscribers list when applicable.
|
||||
|
||||
Version 4.1.2.11 (15. April 2019 - rev5043)
|
||||
Added: Feature: PublishSubscribers. Per channel, you can now define if the server broadcasts users joining and leaving.
|
||||
Fixed: proper way to handle Subscribe event when channel properties are returned.
|
||||
Added: Viveport Auth Provider enum value.
|
||||
Added: Switch-related workaround. Setting a Thread.Name was causing a crash in some exports on console. This affects Unity to Nintendo Switch exports.
|
||||
Added: ChannelCreationOptions class to be used in the new Subscribe overload method.
|
||||
Changed: Chat to use the same 1.8 serialization as Realtime/PUN. This also now matches the SocketWebTcp.SerializationProtocol default.
|
||||
|
||||
Version 4.1.2.9 (13. February 2019 - rev4985)
|
||||
Added: Client API for Max Subscribers and Publish Subscribers features inside public channels.
|
||||
|
||||
Version 4.1.2.1 (31. July 2018 - rev4787)
|
||||
Changed: Namespace from "ExitGames.Client.Photon.Chat" to "Photon.Chat".
|
||||
Added: ConnectAndSetStatus method.
|
||||
|
||||
Version 4.1.1.17 (11. October 2017 - rev4465)
|
||||
Fixed: Unity "6" compile define is now UNITY_2017.
|
||||
|
||||
Version 4.1.1.15 (17. July 2017 - rev4232)
|
||||
Added: ChatClient.TransportProtocol as shortcut to the use PhotonPeer's TransportProtocol value. This enables setting the protocol easily while not connected.
|
||||
Added: ChatClient.SocketImplementationConfig as shortcut to modify PhotonPeer's SocketImplementationConfig. This enables you to setup which IPhotonSocket implementation to use for which network protocol.
|
||||
Changed: ChatPeer.ConfigUnitySockets() to try to find our websocket implementations in the assembly, making the SocketWebTcpCoroutine and SocketWebTcpThread classes optional.
|
||||
Removed: Class "SocketWebTcp" is no longer found by ConfigUnitySockets().
|
||||
|
||||
Version 4.1.1.14 (5. July 2017 - rev4191)
|
||||
Added: ChatClient can optionally run a thread to call SendOutgoingCommands in intervals. This makes sure the connection doesn't fail easily (e.g. when Unity is loading scenes, etc.). You still have to call Service to dispatch received messages.
|
||||
Added: ChatClient.UseBackgroundWorkerForSending. Set this to true, to use the new background thread. Note: Do not use this in WebGL exports from Unity cause Threads are unavailable in them.
|
||||
|
||||
Version 4.1.1.2 (13. September 2016 - rev3652)
|
||||
Changed: GetNameServerAddress() is the same in Chat and LoadBalancing APIs now.
|
||||
Changed: ChatPeer now has ConfigUnitySockets(), which defines the SocketImplementationConfig. It's only used in Unity (using UNITY define).
|
||||
Changed: ChatClient is not setting socket implementations anymore.
|
||||
Added: Hashtable definition to use Photon's own implementation for Windows Store builds (NETFX_CORE). This must be used but it means you to use the same Hashtable definition in all builds (no matter if 8.1 or 10).
|
||||
Added: Support for WebGL export in Unity.
|
||||
|
||||
Version 4.0.5.0 (3. December 2015 - rev3144)
|
||||
Added: A MessageLimit field for ChatClient and ChatChannel to limit the number of messages the client keeps locally. It might be useful to limit memory usage in long running chats. Set ChatClient.MessageLimit to apply the limit to any channel subscribed afterwards or apply a limit individually.
|
||||
|
||||
Version 4.0.0.11 (28. October 2015 - rev3093)
|
||||
Added: More sanity checks on operations (empty userId or secret, max friends).
|
||||
Added: Special debug logging when the server returns an error for "Operation Unknown". In this case, it's highly likely that you don't use a Chat AppId.
|
||||
Added: More helpful error logging.
|
||||
|
||||
Version 4.0.0.10 (14. July 2015 - rev2988)
|
||||
Added: A Unity 4.6 demo with uGUI. It's missing a few features but should give you a good start to making your own.
|
||||
Added: Unity/WebGL support (merged from PUN).
|
||||
Added: Breaking! IChatClientListener.DebugReturn(). Photon lib and chat client log via this method (no logging to console by default).
|
||||
Changed: ChatClient.CustomAuthenticationValues is now .AuthValues. You can use those values to identify a user, even if you don't setup an external, custom authentication service.
|
||||
Changed: ChatClient.UserId no longer directly stores the id but puts it into AuthValues. This means, the UserId could also be set via setting AuthValues.
|
||||
Changed: The API of AuthenticationValues. There is now the UserId and AddAuthParameter() replaces the less general SetAuthParameters() (which only set specific key/values).
|
||||
Note: All users should have a UserId. You can set chatClient.UserId before you connect, or you can set the AuthenticationValues in Connect(..., authValues) to set a UserId.
|
||||
Added: ChatChannel.ToStringMessages(), which gets all messages in a single string, line by line. The format is "Sender:Message".
|
||||
Added: ChatClient.TryGetChannel() to find a channel only by name, no matter if public or private.
|
||||
|
||||
Version 4.0.0.7 (12. January 2015 - rev2763)
|
||||
Internal: Changed code for UserID from 7 to 225. The latter is used in LoadBalancing, too, so we want to re-use the code here.
|
||||
|
||||
Version 4.0.0.1 (17. June 2014 - rev2663)
|
||||
Changed: How the server responds to Subscribe and Unsubscribe. Events will now contain success/failure of those. This allows us to send the answer after calling a WebHook if needed and we can even send it to multiple clients (which authenticated with the same userID).
|
||||
Changed: Handling of subscription responsed. This is done to allow web services to subscribe a client remotely and to be able to prevent joining some channel that a user should not join (the channel of some guild or another team, e.g.).
|
||||
Changed: Debug loggging. In Unity we can't use Debug.Assert, etc. So we have to log more cleanly. This works in Editor and several platforms (but not all).
|
||||
Changed: Folder for Chat API. It now begins with "Photon" which provides some context no matter where you copy the files. Easier to find in Unity projects.
|
||||
Changed: Operation FriendList and method SendFriendList renamed to AddFriends
|
||||
Added: Operation RemoveFriends and corresponding method in ChatClient.cs
|
||||
Added: Console Demo has new command 'fr' to remove friends
|
||||
|
||||
Version 4.0.0.0 (23. May 2014 - rev2614)
|
||||
Added: SendPrivateMessage() overload that has option to encrypt private messages. Public messages don't need encryption.
|
||||
Removed: lastId and LastMessageIndex from channels. Those were impractical and should be removed from the API.
|
||||
Changed: UserStatus class to ChatUserStatus.
|
||||
Changed: Most classes are defined in their own file now.
|
||||
Removed: Folders "Shared" and their subfolders. This gives a much better overview.
|
||||
Added: Handling for event SubscribeResponse. This is not actually a response but gives you info about channels that got subscribed (e.g. when you re-login quickly or when a user is logged in in multiple clients).
|
||||
Added: HandleSubscriptionResults() method to handle the event and proper responses.
|
7
Assets/Photon/PhotonChat/Code/changes-chat.txt.meta
Normal file
7
Assets/Photon/PhotonChat/Code/changes-chat.txt.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5c3dda6f11fe7845989297c8a603dc2
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Photon/PhotonChat/Demos.meta
Normal file
9
Assets/Photon/PhotonChat/Demos.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 801c62f7d03cb463ba20067deb330234
|
||||
folderAsset: yes
|
||||
timeCreated: 1537874612
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Photon/PhotonChat/Demos/Common.meta
Normal file
9
Assets/Photon/PhotonChat/Demos/Common.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1aab6e4c105054f7e91af2cf027064d1
|
||||
folderAsset: yes
|
||||
timeCreated: 1538395282
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
40
Assets/Photon/PhotonChat/Demos/Common/EventSystemSpawner.cs
Normal file
40
Assets/Photon/PhotonChat/Demos/Common/EventSystemSpawner.cs
Normal file
@ -0,0 +1,40 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="EventSystemSpawner.cs" company="Exit Games GmbH">
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// For additive Scene Loading context, eventSystem can't be added to each scene and instead should be instantiated only if necessary.
|
||||
// https://answers.unity.com/questions/1403002/multiple-eventsystem-in-scene-this-is-not-supporte.html
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Photon.Chat.UtilityScripts
|
||||
{
|
||||
/// <summary>
|
||||
/// Event system spawner. Will add an EventSystem GameObject with an EventSystem component and a StandaloneInputModule component.
|
||||
/// Use this in additive scene loading context where you would otherwise get a "Multiple EventSystem in scene... this is not supported" error from Unity.
|
||||
/// </summary>
|
||||
public class EventSystemSpawner : MonoBehaviour
|
||||
{
|
||||
void OnEnable()
|
||||
{
|
||||
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
|
||||
Debug.LogError("PUN Demos are not compatible with the New Input System, unless you enable \"Both\" in: Edit > Project Settings > Player > Active Input Handling. Pausing App.");
|
||||
Debug.Break();
|
||||
return;
|
||||
#endif
|
||||
|
||||
EventSystem sceneEventSystem = FindObjectOfType<EventSystem>();
|
||||
if (sceneEventSystem == null)
|
||||
{
|
||||
GameObject eventSystem = new GameObject("EventSystem");
|
||||
|
||||
eventSystem.AddComponent<EventSystem>();
|
||||
eventSystem.AddComponent<StandaloneInputModule>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd5ff9965d0784cad8e07f5eb9cb9c06
|
||||
timeCreated: 1538396402
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
24
Assets/Photon/PhotonChat/Demos/Common/OnStartDelete.cs
Normal file
24
Assets/Photon/PhotonChat/Demos/Common/OnStartDelete.cs
Normal file
@ -0,0 +1,24 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="OnStartDelete.cs" company="Exit Games GmbH">
|
||||
// Part of: Photon Unity Utilities,
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// This component will destroy the GameObject it is attached to (in Start()).
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Photon.Chat.UtilityScripts
|
||||
{
|
||||
/// <summary>This component will destroy the GameObject it is attached to (in Start()).</summary>
|
||||
public class OnStartDelete : MonoBehaviour
|
||||
{
|
||||
// Use this for initialization
|
||||
private void Start()
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
12
Assets/Photon/PhotonChat/Demos/Common/OnStartDelete.cs.meta
Normal file
12
Assets/Photon/PhotonChat/Demos/Common/OnStartDelete.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b1cdd4de66f84fa1af4cb197e5d901d
|
||||
timeCreated: 1538396603
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,70 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="TextButtonTransition.cs" company="Exit Games GmbH">
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// Use this on Button texts to have some color transition on the text as well without corrupting button's behaviour.
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Chat.UtilityScripts
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Use this on Button texts to have some color transition on the text as well without corrupting button's behaviour.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Text))]
|
||||
public class TextButtonTransition : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
|
||||
Text _text;
|
||||
|
||||
/// <summary>
|
||||
/// The selectable Component.
|
||||
/// </summary>
|
||||
public Selectable Selectable;
|
||||
|
||||
/// <summary>
|
||||
/// The color of the normal of the transition state.
|
||||
/// </summary>
|
||||
public Color NormalColor= Color.white;
|
||||
|
||||
/// <summary>
|
||||
/// The color of the hover of the transition state.
|
||||
/// </summary>
|
||||
public Color HoverColor = Color.black;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
_text = GetComponent<Text>();
|
||||
}
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
_text.color = NormalColor;
|
||||
}
|
||||
|
||||
public void OnDisable()
|
||||
{
|
||||
_text.color = NormalColor;
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
if (Selectable == null || Selectable.IsInteractable()) {
|
||||
_text.color = HoverColor;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
if (Selectable == null || Selectable.IsInteractable()) {
|
||||
_text.color = NormalColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 060fe8295761a47268586d33ef5673e0
|
||||
timeCreated: 1538395273
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,86 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="TextToggleIsOnTransition.cs" company="Exit Games GmbH">
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// Use this on Button texts to have some color transition on the text as well without corrupting button's behaviour.
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Chat.UtilityScripts
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Use this on toggles texts to have some color transition on the text depending on the isOn State.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Text))]
|
||||
public class TextToggleIsOnTransition : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The toggle Component.
|
||||
/// </summary>
|
||||
public Toggle toggle;
|
||||
|
||||
Text _text;
|
||||
|
||||
/// <summary>
|
||||
/// The color of the normal on transition state.
|
||||
/// </summary>
|
||||
public Color NormalOnColor= Color.white;
|
||||
|
||||
/// <summary>
|
||||
/// The color of the normal off transition state.
|
||||
/// </summary>
|
||||
public Color NormalOffColor = Color.black;
|
||||
|
||||
/// <summary>
|
||||
/// The color of the hover on transition state.
|
||||
/// </summary>
|
||||
public Color HoverOnColor= Color.black;
|
||||
|
||||
/// <summary>
|
||||
/// The color of the hover off transition state.
|
||||
/// </summary>
|
||||
public Color HoverOffColor = Color.black;
|
||||
|
||||
bool isHover;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
_text = GetComponent<Text>();
|
||||
|
||||
OnValueChanged (toggle.isOn);
|
||||
|
||||
toggle.onValueChanged.AddListener(OnValueChanged);
|
||||
|
||||
}
|
||||
|
||||
public void OnDisable()
|
||||
{
|
||||
toggle.onValueChanged.RemoveListener(OnValueChanged);
|
||||
}
|
||||
|
||||
public void OnValueChanged(bool isOn)
|
||||
{
|
||||
_text.color = isOn? (isHover?HoverOnColor:HoverOnColor) : (isHover?NormalOffColor:NormalOffColor) ;
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
isHover = true;
|
||||
_text.color = toggle.isOn?HoverOnColor:HoverOffColor;
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
isHover = false;
|
||||
_text.color = toggle.isOn?NormalOnColor:NormalOffColor;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e808171e8963498bb1db072a977d750
|
||||
timeCreated: 1538395754
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Photon/PhotonChat/Demos/DemoChat.meta
Normal file
9
Assets/Photon/PhotonChat/Demos/DemoChat.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e3a46219ebf94310a9f347733f88f31
|
||||
folderAsset: yes
|
||||
timeCreated: 1537874626
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,30 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright company="Exit Games GmbH"/>
|
||||
// <summary>Demo code for Photon Chat in Unity.</summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
using Photon.Realtime;
|
||||
|
||||
|
||||
namespace Photon.Chat.Demo
|
||||
{
|
||||
public static class AppSettingsExtensions
|
||||
{
|
||||
public static ChatAppSettings GetChatSettings(this AppSettings appSettings)
|
||||
{
|
||||
return new ChatAppSettings
|
||||
{
|
||||
AppIdChat = appSettings.AppIdChat,
|
||||
AppVersion = appSettings.AppVersion,
|
||||
FixedRegion = appSettings.IsBestRegion ? null : appSettings.FixedRegion,
|
||||
NetworkLogging = appSettings.NetworkLogging,
|
||||
Protocol = appSettings.Protocol,
|
||||
EnableProtocolFallback = appSettings.EnableProtocolFallback,
|
||||
Server = appSettings.IsDefaultNameServer ? null : appSettings.Server,
|
||||
Port = (ushort)appSettings.Port
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fcf4818ecc9abf4e9b7e0c37af9b851
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
32
Assets/Photon/PhotonChat/Demos/DemoChat/ChannelSelector.cs
Normal file
32
Assets/Photon/PhotonChat/Demos/DemoChat/ChannelSelector.cs
Normal file
@ -0,0 +1,32 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright company="Exit Games GmbH"/>
|
||||
// <summary>Demo code for Photon Chat in Unity.</summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
namespace Photon.Chat.Demo
|
||||
{
|
||||
public class ChannelSelector : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public string Channel;
|
||||
|
||||
public void SetChannel(string channel)
|
||||
{
|
||||
this.Channel = channel;
|
||||
Text t = this.GetComponentInChildren<Text>();
|
||||
t.text = this.Channel;
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
ChatGui handler = FindObjectOfType<ChatGui>();
|
||||
handler.ShowChannel(this.Channel);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48caa72710147fc4f9389b0b5ec6137d
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,54 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright company="Exit Games GmbH"/>
|
||||
// <summary>Demo code for Photon Chat in Unity.</summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
#if PHOTON_UNITY_NETWORKING
|
||||
using UnityEngine.UI;
|
||||
using Photon.Pun;
|
||||
|
||||
namespace Photon.Chat.Demo
|
||||
{
|
||||
/// <summary>
|
||||
/// This is used in the Editor Splash to properly inform the developer about the chat AppId requirement.
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
public class ChatAppIdCheckerUI : MonoBehaviour
|
||||
{
|
||||
public Text Description;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (string.IsNullOrEmpty(PhotonNetwork.PhotonServerSettings.AppSettings.AppIdChat))
|
||||
{
|
||||
if (this.Description != null)
|
||||
{
|
||||
this.Description.text = "<Color=Red>WARNING:</Color>\nPlease setup a Chat AppId in the PhotonServerSettings file.";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.Description != null)
|
||||
{
|
||||
this.Description.text = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
namespace Photon.Chat.Demo
|
||||
{
|
||||
public class ChatAppIdCheckerUI : MonoBehaviour
|
||||
{
|
||||
// empty class. if PUN is not present, we currently don't check Chat-AppId "presence".
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4eb1284704a754507acb17b07b888086
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
649
Assets/Photon/PhotonChat/Demos/DemoChat/ChatGui.cs
Normal file
649
Assets/Photon/PhotonChat/Demos/DemoChat/ChatGui.cs
Normal file
@ -0,0 +1,649 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright company="Exit Games GmbH"/>
|
||||
// <summary>Demo code for Photon Chat in Unity.</summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
using Photon.Chat;
|
||||
using Photon.Realtime;
|
||||
using AuthenticationValues = Photon.Chat.AuthenticationValues;
|
||||
#if PHOTON_UNITY_NETWORKING
|
||||
using Photon.Pun;
|
||||
#endif
|
||||
|
||||
|
||||
namespace Photon.Chat.Demo
|
||||
{
|
||||
/// <summary>
|
||||
/// This simple Chat UI demonstrate basics usages of the Chat Api
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The ChatClient basically lets you create any number of channels.
|
||||
///
|
||||
/// some friends are already set in the Chat demo "DemoChat-Scene", 'Joe', 'Jane' and 'Bob', simply log with them so that you can see the status changes in the Interface
|
||||
///
|
||||
/// Workflow:
|
||||
/// Create ChatClient, Connect to a server with your AppID, Authenticate the user (apply a unique name,)
|
||||
/// and subscribe to some channels.
|
||||
/// Subscribe a channel before you publish to that channel!
|
||||
///
|
||||
///
|
||||
/// Note:
|
||||
/// Don't forget to call ChatClient.Service() on Update to keep the Chatclient operational.
|
||||
/// </remarks>
|
||||
public class ChatGui : MonoBehaviour, IChatClientListener
|
||||
{
|
||||
|
||||
public string[] ChannelsToJoinOnConnect; // set in inspector. Demo channels to join automatically.
|
||||
|
||||
public string[] FriendsList;
|
||||
|
||||
public int HistoryLengthToFetch; // set in inspector. Up to a certain degree, previously sent messages can be fetched for context
|
||||
|
||||
public string UserName { get; set; }
|
||||
|
||||
private string selectedChannelName; // mainly used for GUI/input
|
||||
|
||||
public ChatClient chatClient;
|
||||
|
||||
#if !PHOTON_UNITY_NETWORKING
|
||||
[SerializeField]
|
||||
#endif
|
||||
protected internal ChatAppSettings chatAppSettings;
|
||||
|
||||
|
||||
public GameObject missingAppIdErrorPanel;
|
||||
public GameObject ConnectingLabel;
|
||||
|
||||
public RectTransform ChatPanel; // set in inspector (to enable/disable panel)
|
||||
public GameObject UserIdFormPanel;
|
||||
public InputField InputFieldChat; // set in inspector
|
||||
public Text CurrentChannelText; // set in inspector
|
||||
public Toggle ChannelToggleToInstantiate; // set in inspector
|
||||
|
||||
|
||||
public GameObject FriendListUiItemtoInstantiate;
|
||||
|
||||
private readonly Dictionary<string, Toggle> channelToggles = new Dictionary<string, Toggle>();
|
||||
|
||||
private readonly Dictionary<string,FriendItem> friendListItemLUT = new Dictionary<string, FriendItem>();
|
||||
|
||||
public bool ShowState = true;
|
||||
public GameObject Title;
|
||||
public Text StateText; // set in inspector
|
||||
public Text UserIdText; // set in inspector
|
||||
|
||||
// private static string WelcomeText = "Welcome to chat. Type \\help to list commands.";
|
||||
private static string HelpText = "\n -- HELP --\n" +
|
||||
"To subscribe to channel(s) (channelnames are case sensitive) : \n" +
|
||||
"\t<color=#E07B00>\\subscribe</color> <color=green><list of channelnames></color>\n" +
|
||||
"\tor\n" +
|
||||
"\t<color=#E07B00>\\s</color> <color=green><list of channelnames></color>\n" +
|
||||
"\n" +
|
||||
"To leave channel(s):\n" +
|
||||
"\t<color=#E07B00>\\unsubscribe</color> <color=green><list of channelnames></color>\n" +
|
||||
"\tor\n" +
|
||||
"\t<color=#E07B00>\\u</color> <color=green><list of channelnames></color>\n" +
|
||||
"\n" +
|
||||
"To switch the active channel\n" +
|
||||
"\t<color=#E07B00>\\join</color> <color=green><channelname></color>\n" +
|
||||
"\tor\n" +
|
||||
"\t<color=#E07B00>\\j</color> <color=green><channelname></color>\n" +
|
||||
"\n" +
|
||||
"To send a private message: (username are case sensitive)\n" +
|
||||
"\t\\<color=#E07B00>msg</color> <color=green><username></color> <color=green><message></color>\n" +
|
||||
"\n" +
|
||||
"To change status:\n" +
|
||||
"\t\\<color=#E07B00>state</color> <color=green><stateIndex></color> <color=green><message></color>\n" +
|
||||
"<color=green>0</color> = Offline " +
|
||||
"<color=green>1</color> = Invisible " +
|
||||
"<color=green>2</color> = Online " +
|
||||
"<color=green>3</color> = Away \n" +
|
||||
"<color=green>4</color> = Do not disturb " +
|
||||
"<color=green>5</color> = Looking For Group " +
|
||||
"<color=green>6</color> = Playing" +
|
||||
"\n\n" +
|
||||
"To clear the current chat tab (private chats get closed):\n" +
|
||||
"\t<color=#E07B00>\\clear</color>";
|
||||
|
||||
|
||||
public void Start()
|
||||
{
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
|
||||
this.UserIdText.text = "";
|
||||
this.StateText.text = "";
|
||||
this.StateText.gameObject.SetActive(true);
|
||||
this.UserIdText.gameObject.SetActive(true);
|
||||
this.Title.SetActive(true);
|
||||
this.ChatPanel.gameObject.SetActive(false);
|
||||
this.ConnectingLabel.SetActive(false);
|
||||
|
||||
if (string.IsNullOrEmpty(this.UserName))
|
||||
{
|
||||
this.UserName = "user" + Environment.TickCount%99; //made-up username
|
||||
}
|
||||
|
||||
#if PHOTON_UNITY_NETWORKING
|
||||
this.chatAppSettings = PhotonNetwork.PhotonServerSettings.AppSettings.GetChatSettings();
|
||||
#endif
|
||||
|
||||
bool appIdPresent = !string.IsNullOrEmpty(this.chatAppSettings.AppIdChat);
|
||||
|
||||
this.missingAppIdErrorPanel.SetActive(!appIdPresent);
|
||||
this.UserIdFormPanel.gameObject.SetActive(appIdPresent);
|
||||
|
||||
if (!appIdPresent)
|
||||
{
|
||||
Debug.LogError("You need to set the chat app ID in the PhotonServerSettings file in order to continue.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
this.UserIdFormPanel.gameObject.SetActive(false);
|
||||
|
||||
this.chatClient = new ChatClient(this);
|
||||
#if !UNITY_WEBGL
|
||||
this.chatClient.UseBackgroundWorkerForSending = true;
|
||||
#endif
|
||||
this.chatClient.AuthValues = new AuthenticationValues(this.UserName);
|
||||
this.chatClient.ConnectUsingSettings(this.chatAppSettings);
|
||||
|
||||
this.ChannelToggleToInstantiate.gameObject.SetActive(false);
|
||||
Debug.Log("Connecting as: " + this.UserName);
|
||||
|
||||
this.ConnectingLabel.SetActive(true);
|
||||
}
|
||||
|
||||
/// <summary>To avoid that the Editor becomes unresponsive, disconnect all Photon connections in OnDestroy.</summary>
|
||||
public void OnDestroy()
|
||||
{
|
||||
if (this.chatClient != null)
|
||||
{
|
||||
this.chatClient.Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>To avoid that the Editor becomes unresponsive, disconnect all Photon connections in OnApplicationQuit.</summary>
|
||||
public void OnApplicationQuit()
|
||||
{
|
||||
if (this.chatClient != null)
|
||||
{
|
||||
this.chatClient.Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (this.chatClient != null)
|
||||
{
|
||||
this.chatClient.Service(); // make sure to call this regularly! it limits effort internally, so calling often is ok!
|
||||
}
|
||||
|
||||
// check if we are missing context, which means we got kicked out to get back to the Photon Demo hub.
|
||||
if ( this.StateText == null)
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
this.StateText.gameObject.SetActive(this.ShowState); // this could be handled more elegantly, but for the demo it's ok.
|
||||
}
|
||||
|
||||
|
||||
public void OnEnterSend()
|
||||
{
|
||||
if (Input.GetKey(KeyCode.Return) || Input.GetKey(KeyCode.KeypadEnter))
|
||||
{
|
||||
this.SendChatMessage(this.InputFieldChat.text);
|
||||
this.InputFieldChat.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClickSend()
|
||||
{
|
||||
if (this.InputFieldChat != null)
|
||||
{
|
||||
this.SendChatMessage(this.InputFieldChat.text);
|
||||
this.InputFieldChat.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int TestLength = 2048;
|
||||
private byte[] testBytes = new byte[2048];
|
||||
|
||||
private void SendChatMessage(string inputLine)
|
||||
{
|
||||
if (string.IsNullOrEmpty(inputLine))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ("test".Equals(inputLine))
|
||||
{
|
||||
if (this.TestLength != this.testBytes.Length)
|
||||
{
|
||||
this.testBytes = new byte[this.TestLength];
|
||||
}
|
||||
|
||||
this.chatClient.SendPrivateMessage(this.chatClient.AuthValues.UserId, this.testBytes, true);
|
||||
}
|
||||
|
||||
|
||||
bool doingPrivateChat = this.chatClient.PrivateChannels.ContainsKey(this.selectedChannelName);
|
||||
string privateChatTarget = string.Empty;
|
||||
if (doingPrivateChat)
|
||||
{
|
||||
// the channel name for a private conversation is (on the client!!) always composed of both user's IDs: "this:remote"
|
||||
// so the remote ID is simple to figure out
|
||||
|
||||
string[] splitNames = this.selectedChannelName.Split(new char[] { ':' });
|
||||
privateChatTarget = splitNames[1];
|
||||
}
|
||||
//UnityEngine.Debug.Log("selectedChannelName: " + selectedChannelName + " doingPrivateChat: " + doingPrivateChat + " privateChatTarget: " + privateChatTarget);
|
||||
|
||||
|
||||
if (inputLine[0].Equals('\\'))
|
||||
{
|
||||
string[] tokens = inputLine.Split(new char[] {' '}, 2);
|
||||
if (tokens[0].Equals("\\help"))
|
||||
{
|
||||
this.PostHelpToCurrentChannel();
|
||||
}
|
||||
if (tokens[0].Equals("\\state"))
|
||||
{
|
||||
int newState = 0;
|
||||
|
||||
|
||||
List<string> messages = new List<string>();
|
||||
messages.Add ("i am state " + newState);
|
||||
string[] subtokens = tokens[1].Split(new char[] {' ', ','});
|
||||
|
||||
if (subtokens.Length > 0)
|
||||
{
|
||||
newState = int.Parse(subtokens[0]);
|
||||
}
|
||||
|
||||
if (subtokens.Length > 1)
|
||||
{
|
||||
messages.Add(subtokens[1]);
|
||||
}
|
||||
|
||||
this.chatClient.SetOnlineStatus(newState,messages.ToArray()); // this is how you set your own state and (any) message
|
||||
}
|
||||
else if ((tokens[0].Equals("\\subscribe") || tokens[0].Equals("\\s")) && !string.IsNullOrEmpty(tokens[1]))
|
||||
{
|
||||
this.chatClient.Subscribe(tokens[1].Split(new char[] {' ', ','}));
|
||||
}
|
||||
else if ((tokens[0].Equals("\\unsubscribe") || tokens[0].Equals("\\u")) && !string.IsNullOrEmpty(tokens[1]))
|
||||
{
|
||||
this.chatClient.Unsubscribe(tokens[1].Split(new char[] {' ', ','}));
|
||||
}
|
||||
else if (tokens[0].Equals("\\clear"))
|
||||
{
|
||||
if (doingPrivateChat)
|
||||
{
|
||||
this.chatClient.PrivateChannels.Remove(this.selectedChannelName);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatChannel channel;
|
||||
if (this.chatClient.TryGetChannel(this.selectedChannelName, doingPrivateChat, out channel))
|
||||
{
|
||||
channel.ClearMessages();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tokens[0].Equals("\\msg") && !string.IsNullOrEmpty(tokens[1]))
|
||||
{
|
||||
string[] subtokens = tokens[1].Split(new char[] {' ', ','}, 2);
|
||||
if (subtokens.Length < 2) return;
|
||||
|
||||
string targetUser = subtokens[0];
|
||||
string message = subtokens[1];
|
||||
this.chatClient.SendPrivateMessage(targetUser, message);
|
||||
}
|
||||
else if ((tokens[0].Equals("\\join") || tokens[0].Equals("\\j")) && !string.IsNullOrEmpty(tokens[1]))
|
||||
{
|
||||
string[] subtokens = tokens[1].Split(new char[] { ' ', ',' }, 2);
|
||||
|
||||
// If we are already subscribed to the channel we directly switch to it, otherwise we subscribe to it first and then switch to it implicitly
|
||||
if (this.channelToggles.ContainsKey(subtokens[0]))
|
||||
{
|
||||
this.ShowChannel(subtokens[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.chatClient.Subscribe(new string[] { subtokens[0] });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("The command '" + tokens[0] + "' is invalid.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (doingPrivateChat)
|
||||
{
|
||||
this.chatClient.SendPrivateMessage(privateChatTarget, inputLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.chatClient.PublishMessage(this.selectedChannelName, inputLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PostHelpToCurrentChannel()
|
||||
{
|
||||
this.CurrentChannelText.text += HelpText;
|
||||
}
|
||||
|
||||
public void DebugReturn(ExitGames.Client.Photon.DebugLevel level, string message)
|
||||
{
|
||||
if (level == ExitGames.Client.Photon.DebugLevel.ERROR)
|
||||
{
|
||||
Debug.LogError(message);
|
||||
}
|
||||
else if (level == ExitGames.Client.Photon.DebugLevel.WARNING)
|
||||
{
|
||||
Debug.LogWarning(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log(message);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnConnected()
|
||||
{
|
||||
if (this.ChannelsToJoinOnConnect != null && this.ChannelsToJoinOnConnect.Length > 0)
|
||||
{
|
||||
this.chatClient.Subscribe(this.ChannelsToJoinOnConnect, this.HistoryLengthToFetch);
|
||||
}
|
||||
|
||||
this.ConnectingLabel.SetActive(false);
|
||||
|
||||
this.UserIdText.text = "Connected as "+ this.UserName;
|
||||
|
||||
this.ChatPanel.gameObject.SetActive(true);
|
||||
|
||||
if (this.FriendsList!=null && this.FriendsList.Length>0)
|
||||
{
|
||||
this.chatClient.AddFriends(this.FriendsList); // Add some users to the server-list to get their status updates
|
||||
|
||||
// add to the UI as well
|
||||
foreach(string _friend in this.FriendsList)
|
||||
{
|
||||
if (this.FriendListUiItemtoInstantiate != null && _friend!= this.UserName)
|
||||
{
|
||||
this.InstantiateFriendButton(_friend);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (this.FriendListUiItemtoInstantiate != null)
|
||||
{
|
||||
this.FriendListUiItemtoInstantiate.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
this.chatClient.SetOnlineStatus(ChatUserStatus.Online); // You can set your online state (without a mesage).
|
||||
}
|
||||
|
||||
public void OnDisconnected()
|
||||
{
|
||||
this.ConnectingLabel.SetActive(false);
|
||||
}
|
||||
|
||||
public void OnChatStateChange(ChatState state)
|
||||
{
|
||||
// use OnConnected() and OnDisconnected()
|
||||
// this method might become more useful in the future, when more complex states are being used.
|
||||
|
||||
this.StateText.text = state.ToString();
|
||||
}
|
||||
|
||||
public void OnSubscribed(string[] channels, bool[] results)
|
||||
{
|
||||
// in this demo, we simply send a message into each channel. This is NOT a must have!
|
||||
foreach (string channel in channels)
|
||||
{
|
||||
this.chatClient.PublishMessage(channel, "says 'hi'."); // you don't HAVE to send a msg on join but you could.
|
||||
|
||||
if (this.ChannelToggleToInstantiate != null)
|
||||
{
|
||||
this.InstantiateChannelButton(channel);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log("OnSubscribed: " + string.Join(", ", channels));
|
||||
|
||||
/*
|
||||
// select first subscribed channel in alphabetical order
|
||||
if (this.chatClient.PublicChannels.Count > 0)
|
||||
{
|
||||
var l = new List<string>(this.chatClient.PublicChannels.Keys);
|
||||
l.Sort();
|
||||
string selected = l[0];
|
||||
if (this.channelToggles.ContainsKey(selected))
|
||||
{
|
||||
ShowChannel(selected);
|
||||
foreach (var c in this.channelToggles)
|
||||
{
|
||||
c.Value.isOn = false;
|
||||
}
|
||||
this.channelToggles[selected].isOn = true;
|
||||
AddMessageToSelectedChannel(WelcomeText);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Switch to the first newly created channel
|
||||
this.ShowChannel(channels[0]);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnSubscribed(string channel, string[] users, Dictionary<object, object> properties)
|
||||
{
|
||||
Debug.LogFormat("OnSubscribed: {0}, users.Count: {1} Channel-props: {2}.", channel, users.Length, properties.ToStringFull());
|
||||
}
|
||||
|
||||
private void InstantiateChannelButton(string channelName)
|
||||
{
|
||||
if (this.channelToggles.ContainsKey(channelName))
|
||||
{
|
||||
Debug.Log("Skipping creation for an existing channel toggle.");
|
||||
return;
|
||||
}
|
||||
|
||||
Toggle cbtn = (Toggle)Instantiate(this.ChannelToggleToInstantiate);
|
||||
cbtn.gameObject.SetActive(true);
|
||||
cbtn.GetComponentInChildren<ChannelSelector>().SetChannel(channelName);
|
||||
cbtn.transform.SetParent(this.ChannelToggleToInstantiate.transform.parent, false);
|
||||
|
||||
this.channelToggles.Add(channelName, cbtn);
|
||||
}
|
||||
|
||||
private void InstantiateFriendButton(string friendId)
|
||||
{
|
||||
GameObject fbtn = (GameObject)Instantiate(this.FriendListUiItemtoInstantiate);
|
||||
fbtn.gameObject.SetActive(true);
|
||||
FriendItem _friendItem = fbtn.GetComponent<FriendItem>();
|
||||
|
||||
_friendItem.FriendId = friendId;
|
||||
|
||||
fbtn.transform.SetParent(this.FriendListUiItemtoInstantiate.transform.parent, false);
|
||||
|
||||
this.friendListItemLUT[friendId] = _friendItem;
|
||||
}
|
||||
|
||||
|
||||
public void OnUnsubscribed(string[] channels)
|
||||
{
|
||||
foreach (string channelName in channels)
|
||||
{
|
||||
if (this.channelToggles.ContainsKey(channelName))
|
||||
{
|
||||
Toggle t = this.channelToggles[channelName];
|
||||
Destroy(t.gameObject);
|
||||
|
||||
this.channelToggles.Remove(channelName);
|
||||
|
||||
Debug.Log("Unsubscribed from channel '" + channelName + "'.");
|
||||
|
||||
// Showing another channel if the active channel is the one we unsubscribed from before
|
||||
if (channelName == this.selectedChannelName && this.channelToggles.Count > 0)
|
||||
{
|
||||
IEnumerator<KeyValuePair<string, Toggle>> firstEntry = this.channelToggles.GetEnumerator();
|
||||
firstEntry.MoveNext();
|
||||
|
||||
this.ShowChannel(firstEntry.Current.Key);
|
||||
|
||||
firstEntry.Current.Value.isOn = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Can't unsubscribe from channel '" + channelName + "' because you are currently not subscribed to it.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnGetMessages(string channelName, string[] senders, object[] messages)
|
||||
{
|
||||
if (channelName.Equals(this.selectedChannelName))
|
||||
{
|
||||
// update text
|
||||
this.ShowChannel(this.selectedChannelName);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPrivateMessage(string sender, object message, string channelName)
|
||||
{
|
||||
// as the ChatClient is buffering the messages for you, this GUI doesn't need to do anything here
|
||||
// you also get messages that you sent yourself. in that case, the channelName is determinded by the target of your msg
|
||||
this.InstantiateChannelButton(channelName);
|
||||
|
||||
byte[] msgBytes = message as byte[];
|
||||
if (msgBytes != null)
|
||||
{
|
||||
Debug.Log("Message with byte[].Length: "+ msgBytes.Length);
|
||||
}
|
||||
if (this.selectedChannelName.Equals(channelName))
|
||||
{
|
||||
this.ShowChannel(channelName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// New status of another user (you get updates for users set in your friends list).
|
||||
/// </summary>
|
||||
/// <param name="user">Name of the user.</param>
|
||||
/// <param name="status">New status of that user.</param>
|
||||
/// <param name="gotMessage">True if the status contains a message you should cache locally. False: This status update does not include a
|
||||
/// message (keep any you have).</param>
|
||||
/// <param name="message">Message that user set.</param>
|
||||
public void OnStatusUpdate(string user, int status, bool gotMessage, object message)
|
||||
{
|
||||
|
||||
Debug.LogWarning("status: " + string.Format("{0} is {1}. Msg:{2}", user, status, message));
|
||||
|
||||
if (this.friendListItemLUT.ContainsKey(user))
|
||||
{
|
||||
FriendItem _friendItem = this.friendListItemLUT[user];
|
||||
if ( _friendItem!=null) _friendItem.OnFriendStatusUpdate(status,gotMessage,message);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnUserSubscribed(string channel, string user)
|
||||
{
|
||||
Debug.LogFormat("OnUserSubscribed: channel=\"{0}\" userId=\"{1}\"", channel, user);
|
||||
}
|
||||
|
||||
public void OnUserUnsubscribed(string channel, string user)
|
||||
{
|
||||
Debug.LogFormat("OnUserUnsubscribed: channel=\"{0}\" userId=\"{1}\"", channel, user);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnChannelPropertiesChanged(string channel, string userId, Dictionary<object, object> properties)
|
||||
{
|
||||
Debug.LogFormat("OnChannelPropertiesChanged: {0} by {1}. Props: {2}.", channel, userId, Extensions.ToStringFull(properties));
|
||||
}
|
||||
|
||||
public void OnUserPropertiesChanged(string channel, string targetUserId, string senderUserId, Dictionary<object, object> properties)
|
||||
{
|
||||
Debug.LogFormat("OnUserPropertiesChanged: (channel:{0} user:{1}) by {2}. Props: {3}.", channel, targetUserId, senderUserId, Extensions.ToStringFull(properties));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnErrorInfo(string channel, string error, object data)
|
||||
{
|
||||
Debug.LogFormat("OnErrorInfo for channel {0}. Error: {1} Data: {2}", channel, error, data);
|
||||
}
|
||||
|
||||
public void AddMessageToSelectedChannel(string msg)
|
||||
{
|
||||
ChatChannel channel = null;
|
||||
bool found = this.chatClient.TryGetChannel(this.selectedChannelName, out channel);
|
||||
if (!found)
|
||||
{
|
||||
Debug.Log("AddMessageToSelectedChannel failed to find channel: " + this.selectedChannelName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (channel != null)
|
||||
{
|
||||
channel.Add("Bot", msg,0); //TODO: how to use msgID?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void ShowChannel(string channelName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(channelName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ChatChannel channel = null;
|
||||
bool found = this.chatClient.TryGetChannel(channelName, out channel);
|
||||
if (!found)
|
||||
{
|
||||
Debug.Log("ShowChannel failed to find channel: " + channelName);
|
||||
return;
|
||||
}
|
||||
|
||||
this.selectedChannelName = channelName;
|
||||
this.CurrentChannelText.text = channel.ToStringMessages();
|
||||
Debug.Log("ShowChannel: " + this.selectedChannelName);
|
||||
|
||||
foreach (KeyValuePair<string, Toggle> pair in this.channelToggles)
|
||||
{
|
||||
pair.Value.isOn = pair.Key == channelName ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenDashboard()
|
||||
{
|
||||
Application.OpenURL("https://dashboard.photonengine.com");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
10
Assets/Photon/PhotonChat/Demos/DemoChat/ChatGui.cs.meta
Normal file
10
Assets/Photon/PhotonChat/Demos/DemoChat/ChatGui.cs.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02d148d0890b2d44dbdf7f1c1b39a499
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
6246
Assets/Photon/PhotonChat/Demos/DemoChat/DemoChat-Scene.unity
Normal file
6246
Assets/Photon/PhotonChat/Demos/DemoChat/DemoChat-Scene.unity
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec07267f6a28fb044ac89845274e79af
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
84
Assets/Photon/PhotonChat/Demos/DemoChat/FriendItem.cs
Normal file
84
Assets/Photon/PhotonChat/Demos/DemoChat/FriendItem.cs
Normal file
@ -0,0 +1,84 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright company="Exit Games GmbH"/>
|
||||
// <summary>Demo code for Photon Chat in Unity.</summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
namespace Photon.Chat.Demo
|
||||
{
|
||||
/// <summary>
|
||||
/// Friend UI item used to represent the friend status as well as message.
|
||||
/// It aims at showing how to share health for a friend that plays on a different room than you for example.
|
||||
/// But of course the message can be anything and a lot more complex.
|
||||
/// </summary>
|
||||
public class FriendItem : MonoBehaviour
|
||||
{
|
||||
[HideInInspector]
|
||||
public string FriendId
|
||||
{
|
||||
set { this.NameLabel.text = value; }
|
||||
get { return this.NameLabel.text; }
|
||||
}
|
||||
|
||||
public Text NameLabel;
|
||||
public Text StatusLabel;
|
||||
public Text Health;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
this.Health.text = string.Empty;
|
||||
}
|
||||
|
||||
public void OnFriendStatusUpdate(int status, bool gotMessage, object message)
|
||||
{
|
||||
string _status;
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case 1:
|
||||
_status = "Invisible";
|
||||
break;
|
||||
case 2:
|
||||
_status = "Online";
|
||||
break;
|
||||
case 3:
|
||||
_status = "Away";
|
||||
break;
|
||||
case 4:
|
||||
_status = "Do not disturb";
|
||||
break;
|
||||
case 5:
|
||||
_status = "Looking For Game/Group";
|
||||
break;
|
||||
case 6:
|
||||
_status = "Playing";
|
||||
break;
|
||||
default:
|
||||
_status = "Offline";
|
||||
break;
|
||||
}
|
||||
|
||||
this.StatusLabel.text = _status;
|
||||
|
||||
if (gotMessage)
|
||||
{
|
||||
string _health = string.Empty;
|
||||
if (message != null)
|
||||
{
|
||||
string[] _messages = message as string[];
|
||||
if (_messages != null && _messages.Length >= 2)
|
||||
{
|
||||
_health = (string)_messages[1] + "%";
|
||||
}
|
||||
}
|
||||
|
||||
this.Health.text = _health;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
10
Assets/Photon/PhotonChat/Demos/DemoChat/FriendItem.cs.meta
Normal file
10
Assets/Photon/PhotonChat/Demos/DemoChat/FriendItem.cs.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 660b16ba396d0465b98be14947420288
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,20 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright company="Exit Games GmbH"/>
|
||||
// <summary>Demo code for Photon Chat in Unity.</summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Photon.Chat.Demo
|
||||
{
|
||||
public class IgnoreUiRaycastWhenInactive : MonoBehaviour, ICanvasRaycastFilter
|
||||
{
|
||||
public bool IsRaycastLocationValid(Vector2 screenPoint, Camera eventCamera)
|
||||
{
|
||||
return this.gameObject.activeInHierarchy;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ba4c747f6975ea46bcc0a55ffe3bfe8
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
55
Assets/Photon/PhotonChat/Demos/DemoChat/NamePickGui.cs
Normal file
55
Assets/Photon/PhotonChat/Demos/DemoChat/NamePickGui.cs
Normal file
@ -0,0 +1,55 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright company="Exit Games GmbH"/>
|
||||
// <summary>Demo code for Photon Chat in Unity.</summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
namespace Photon.Chat.Demo
|
||||
{
|
||||
[RequireComponent(typeof(ChatGui))]
|
||||
public class NamePickGui : MonoBehaviour
|
||||
{
|
||||
private const string UserNamePlayerPref = "NamePickUserName";
|
||||
|
||||
public ChatGui chatNewComponent;
|
||||
|
||||
public InputField idInput;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
this.chatNewComponent = FindObjectOfType<ChatGui>();
|
||||
|
||||
|
||||
string prefsName = PlayerPrefs.GetString(UserNamePlayerPref);
|
||||
if (!string.IsNullOrEmpty(prefsName))
|
||||
{
|
||||
this.idInput.text = prefsName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// new UI will fire "EndEdit" event also when loosing focus. So check "enter" key and only then StartChat.
|
||||
public void EndEditOnEnter()
|
||||
{
|
||||
if (Input.GetKey(KeyCode.Return) || Input.GetKey(KeyCode.KeypadEnter))
|
||||
{
|
||||
this.StartChat();
|
||||
}
|
||||
}
|
||||
|
||||
public void StartChat()
|
||||
{
|
||||
ChatGui chatNewComponent = FindObjectOfType<ChatGui>();
|
||||
chatNewComponent.UserName = this.idInput.text.Trim();
|
||||
chatNewComponent.Connect();
|
||||
this.enabled = false;
|
||||
|
||||
PlayerPrefs.SetString(UserNamePlayerPref, chatNewComponent.UserName);
|
||||
}
|
||||
}
|
||||
}
|
10
Assets/Photon/PhotonChat/Demos/DemoChat/NamePickGui.cs.meta
Normal file
10
Assets/Photon/PhotonChat/Demos/DemoChat/NamePickGui.cs.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 696a5174ff5e707479b3540eb56d14b7
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
7
Assets/Photon/PhotonLibs.meta
Normal file
7
Assets/Photon/PhotonLibs.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee1734b1a7bac244bb5f15ecd778b5f2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
5
Assets/Photon/PhotonLibs/Metro.meta
Normal file
5
Assets/Photon/PhotonLibs/Metro.meta
Normal file
@ -0,0 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 887ac71c799552346b6cf7654fb699cb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
BIN
Assets/Photon/PhotonLibs/Metro/Photon3Unity3D.dll
Normal file
BIN
Assets/Photon/PhotonLibs/Metro/Photon3Unity3D.dll
Normal file
Binary file not shown.
47
Assets/Photon/PhotonLibs/Metro/Photon3Unity3D.dll.meta
Normal file
47
Assets/Photon/PhotonLibs/Metro/Photon3Unity3D.dll.meta
Normal file
@ -0,0 +1,47 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b5a0a7dce46a13459199d174ad3db3f
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
'': WP8
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath: Assets/Photon/PhotonLibs/Photon3Unity3D.dll
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: DotNet
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: false
|
||||
PlaceholderPath: Assets/Photon/PhotonLibs/Photon3Unity3D.dll
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: DotNet
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Photon/PhotonLibs/Metro/Photon3Unity3D.pri
Normal file
BIN
Assets/Photon/PhotonLibs/Metro/Photon3Unity3D.pri
Normal file
Binary file not shown.
8
Assets/Photon/PhotonLibs/Metro/Photon3Unity3D.pri.meta
Normal file
8
Assets/Photon/PhotonLibs/Metro/Photon3Unity3D.pri.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3439a9e4030efca45b6cc06240106c02
|
||||
timeCreated: 1460035811
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Photon/PhotonLibs/Photon3Unity3D.dll
Normal file
BIN
Assets/Photon/PhotonLibs/Photon3Unity3D.dll
Normal file
Binary file not shown.
38
Assets/Photon/PhotonLibs/Photon3Unity3D.dll.meta
Normal file
38
Assets/Photon/PhotonLibs/Photon3Unity3D.dll.meta
Normal file
@ -0,0 +1,38 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aadb37a20a33632429047acaef43658a
|
||||
labels:
|
||||
- ExitGames
|
||||
- PUN
|
||||
- Photon
|
||||
- Networking
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
2766
Assets/Photon/PhotonLibs/Photon3Unity3D.xml
Normal file
2766
Assets/Photon/PhotonLibs/Photon3Unity3D.xml
Normal file
File diff suppressed because it is too large
Load Diff
9
Assets/Photon/PhotonLibs/Photon3Unity3D.xml.meta
Normal file
9
Assets/Photon/PhotonLibs/Photon3Unity3D.xml.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d4f08d435c4b6343969d8af249460ff
|
||||
labels:
|
||||
- ExitGames
|
||||
- PUN
|
||||
- Photon
|
||||
- Networking
|
||||
TextScriptImporter:
|
||||
userData:
|
5
Assets/Photon/PhotonLibs/WebSocket.meta
Normal file
5
Assets/Photon/PhotonLibs/WebSocket.meta
Normal file
@ -0,0 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f243ce0406bd1c40a9ff5fc2d78d905
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
369
Assets/Photon/PhotonLibs/WebSocket/SocketWebTcp.cs
Normal file
369
Assets/Photon/PhotonLibs/WebSocket/SocketWebTcp.cs
Normal file
@ -0,0 +1,369 @@
|
||||
#if UNITY_WEBGL || WEBSOCKET || ((UNITY_XBOXONE || UNITY_GAMECORE) && UNITY_EDITOR)
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="SocketWebTcp.cs" company="Exit Games GmbH">
|
||||
// Copyright (c) Exit Games GmbH. All rights reserved.
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// Internal class to encapsulate the network i/o functionality for the realtime library.
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace ExitGames.Client.Photon
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using SupportClassPun = ExitGames.Client.Photon.SupportClass;
|
||||
|
||||
|
||||
#if !(UNITY_WEBGL || NETFX_CORE)
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Yield Instruction to Wait for real seconds. Very important to keep connection working if Time.TimeScale is altered, we still want accurate network events
|
||||
/// </summary>
|
||||
public sealed class WaitForRealSeconds : CustomYieldInstruction
|
||||
{
|
||||
private readonly float _endTime;
|
||||
|
||||
public override bool keepWaiting
|
||||
{
|
||||
get { return this._endTime > Time.realtimeSinceStartup; }
|
||||
}
|
||||
|
||||
public WaitForRealSeconds(float seconds)
|
||||
{
|
||||
this._endTime = Time.realtimeSinceStartup + seconds;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Internal class to encapsulate the network i/o functionality for the realtime libary.
|
||||
/// </summary>
|
||||
public class SocketWebTcp : IPhotonSocket, IDisposable
|
||||
{
|
||||
private WebSocket sock;
|
||||
|
||||
private readonly object syncer = new object();
|
||||
|
||||
public SocketWebTcp(PeerBase npeer) : base(npeer)
|
||||
{
|
||||
this.ServerAddress = npeer.ServerAddress;
|
||||
if (this.ReportDebugOfLevel(DebugLevel.INFO))
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.INFO, "new SocketWebTcp() for Unity. Server: " + this.ServerAddress);
|
||||
}
|
||||
|
||||
//this.Protocol = ConnectionProtocol.WebSocket;
|
||||
this.PollReceive = false;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.State = PhotonSocketState.Disconnecting;
|
||||
|
||||
if (this.sock != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.sock.Connected) this.sock.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.EnqueueDebugReturn(DebugLevel.INFO, "Exception in Dispose(): " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
this.sock = null;
|
||||
this.State = PhotonSocketState.Disconnected;
|
||||
}
|
||||
|
||||
GameObject websocketConnectionObject;
|
||||
public override bool Connect()
|
||||
{
|
||||
//bool baseOk = base.Connect();
|
||||
//if (!baseOk)
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
|
||||
|
||||
this.State = PhotonSocketState.Connecting;
|
||||
|
||||
if (this.websocketConnectionObject != null)
|
||||
{
|
||||
UnityEngine.Object.Destroy(this.websocketConnectionObject);
|
||||
}
|
||||
|
||||
this.websocketConnectionObject = new GameObject("websocketConnectionObject");
|
||||
MonoBehaviour mb = this.websocketConnectionObject.AddComponent<MonoBehaviourExt>();
|
||||
this.websocketConnectionObject.hideFlags = HideFlags.HideInHierarchy;
|
||||
UnityEngine.Object.DontDestroyOnLoad(this.websocketConnectionObject);
|
||||
|
||||
#if UNITY_WEBGL || NETFX_CORE
|
||||
this.sock = new WebSocket(new Uri(this.ConnectAddress), this.SerializationProtocol);
|
||||
this.sock.Connect();
|
||||
|
||||
mb.StartCoroutine(this.ReceiveLoop());
|
||||
#else
|
||||
|
||||
mb.StartCoroutine(this.DetectIpVersionAndConnect(mb));
|
||||
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#if !(UNITY_WEBGL || NETFX_CORE)
|
||||
private bool ipVersionDetectDone;
|
||||
private IEnumerator DetectIpVersionAndConnect(MonoBehaviour mb)
|
||||
{
|
||||
Uri uri = null;
|
||||
try
|
||||
{
|
||||
uri = new Uri(this.ConnectAddress);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (this.ReportDebugOfLevel(DebugLevel.ERROR))
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.ERROR, "Failed to create a URI from ConnectAddress (" + ConnectAddress + "). Exception: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (uri != null && uri.HostNameType == UriHostNameType.Dns)
|
||||
{
|
||||
ipVersionDetectDone = false;
|
||||
|
||||
ThreadPool.QueueUserWorkItem(this.DetectIpVersion, uri.Host);
|
||||
|
||||
while (!this.ipVersionDetectDone)
|
||||
{
|
||||
yield return new WaitForRealSeconds(0.1f);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.AddressResolvedAsIpv6)
|
||||
{
|
||||
this.ConnectAddress += "&IPv6";
|
||||
}
|
||||
|
||||
if (this.ReportDebugOfLevel(DebugLevel.INFO))
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.INFO, "DetectIpVersionAndConnect() AddressResolvedAsIpv6: " + this.AddressResolvedAsIpv6 + " ConnectAddress: " + ConnectAddress);
|
||||
}
|
||||
|
||||
|
||||
this.sock = new WebSocket(new Uri(this.ConnectAddress), this.SerializationProtocol);
|
||||
this.sock.Connect();
|
||||
|
||||
mb.StartCoroutine(this.ReceiveLoop());
|
||||
}
|
||||
|
||||
// state has to be the hostname string
|
||||
private void DetectIpVersion(object state)
|
||||
{
|
||||
string host = state as string;
|
||||
IPAddress[] ipAddresses;
|
||||
try
|
||||
{
|
||||
ipAddresses = Dns.GetHostAddresses(host);
|
||||
foreach (IPAddress ipAddress in ipAddresses)
|
||||
{
|
||||
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
|
||||
{
|
||||
this.AddressResolvedAsIpv6 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.INFO, "DetectIpVersionAndConnect (uri: " + host + "= thread failed: " + ex);
|
||||
}
|
||||
|
||||
this.ipVersionDetectDone = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
public override bool Disconnect()
|
||||
{
|
||||
if (this.ReportDebugOfLevel(DebugLevel.INFO))
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.INFO, "SocketWebTcp.Disconnect()");
|
||||
}
|
||||
|
||||
this.State = PhotonSocketState.Disconnecting;
|
||||
|
||||
lock (this.syncer)
|
||||
{
|
||||
if (this.sock != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.sock.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.ERROR, "Exception in Disconnect(): " + ex);
|
||||
}
|
||||
this.sock = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.websocketConnectionObject != null)
|
||||
{
|
||||
UnityEngine.Object.Destroy(this.websocketConnectionObject);
|
||||
}
|
||||
|
||||
this.State = PhotonSocketState.Disconnected;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// used by TPeer*
|
||||
/// </summary>
|
||||
public override PhotonSocketError Send(byte[] data, int length)
|
||||
{
|
||||
if (this.State != PhotonSocketState.Connected)
|
||||
{
|
||||
return PhotonSocketError.Skipped;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (data.Length > length)
|
||||
{
|
||||
byte[] trimmedData = new byte[length];
|
||||
Buffer.BlockCopy(data, 0, trimmedData, 0, length);
|
||||
data = trimmedData;
|
||||
}
|
||||
|
||||
if (this.ReportDebugOfLevel(DebugLevel.ALL))
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.ALL, "Sending: " + SupportClassPun.ByteArrayToString(data));
|
||||
}
|
||||
|
||||
if (this.sock != null)
|
||||
{
|
||||
this.sock.Send(data);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.ERROR, "Cannot send to: " + this.ServerAddress + ". " + e.Message);
|
||||
|
||||
this.HandleException(StatusCode.Exception);
|
||||
return PhotonSocketError.Exception;
|
||||
}
|
||||
|
||||
return PhotonSocketError.Success;
|
||||
}
|
||||
|
||||
public override PhotonSocketError Receive(out byte[] data)
|
||||
{
|
||||
data = null;
|
||||
return PhotonSocketError.NoData;
|
||||
}
|
||||
|
||||
|
||||
internal const int ALL_HEADER_BYTES = 9;
|
||||
internal const int TCP_HEADER_BYTES = 7;
|
||||
internal const int MSG_HEADER_BYTES = 2;
|
||||
|
||||
public IEnumerator ReceiveLoop()
|
||||
{
|
||||
//this.Listener.DebugReturn(DebugLevel.INFO, "ReceiveLoop()");
|
||||
if (this.sock != null)
|
||||
{
|
||||
while (this.sock != null && !this.sock.Connected && this.sock.Error == null)
|
||||
{
|
||||
yield return new WaitForRealSeconds(0.1f);
|
||||
}
|
||||
|
||||
|
||||
if (this.sock != null)
|
||||
{
|
||||
if (this.sock.Error != null)
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.ERROR, "Exiting receive thread. Server: " + this.ServerAddress + ":" + this.ServerPort + " Error: " + this.sock.Error);
|
||||
this.HandleException(StatusCode.ExceptionOnConnect);
|
||||
}
|
||||
else
|
||||
{
|
||||
// connected
|
||||
if (this.ReportDebugOfLevel(DebugLevel.ALL))
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.ALL, "Receiving by websocket. this.State: " + this.State);
|
||||
}
|
||||
|
||||
this.State = PhotonSocketState.Connected;
|
||||
this.peerBase.OnConnect();
|
||||
|
||||
while (this.State == PhotonSocketState.Connected)
|
||||
{
|
||||
if (this.sock != null)
|
||||
{
|
||||
if (this.sock.Error != null)
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.ERROR, "Exiting receive thread (inside loop). Server: " + this.ServerAddress + ":" + this.ServerPort + " Error: " + this.sock.Error);
|
||||
this.HandleException(StatusCode.ExceptionOnReceive);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] inBuff = this.sock.Recv();
|
||||
if (inBuff == null || inBuff.Length == 0)
|
||||
{
|
||||
// nothing received. wait a bit, try again
|
||||
yield return new WaitForRealSeconds(0.02f);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.ReportDebugOfLevel(DebugLevel.ALL))
|
||||
{
|
||||
this.Listener.DebugReturn(DebugLevel.ALL, "TCP << " + inBuff.Length + " = " + SupportClassPun.ByteArrayToString(inBuff));
|
||||
}
|
||||
|
||||
if (inBuff.Length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.HandleReceivedDatagram(inBuff, inBuff.Length, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (this.State != PhotonSocketState.Disconnecting && this.State != PhotonSocketState.Disconnected)
|
||||
{
|
||||
if (this.ReportDebugOfLevel(DebugLevel.ERROR))
|
||||
{
|
||||
this.EnqueueDebugReturn(DebugLevel.ERROR, "Receive issue. State: " + this.State + ". Server: '" + this.ServerAddress + "' Exception: " + e);
|
||||
}
|
||||
|
||||
this.HandleException(StatusCode.ExceptionOnReceive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.Disconnect();
|
||||
}
|
||||
|
||||
private class MonoBehaviourExt : MonoBehaviour { }
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
8
Assets/Photon/PhotonLibs/WebSocket/SocketWebTcp.cs.meta
Normal file
8
Assets/Photon/PhotonLibs/WebSocket/SocketWebTcp.cs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac953d6a57a9ea94e96ec689598995d5
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
188
Assets/Photon/PhotonLibs/WebSocket/WebSocket.cs
Normal file
188
Assets/Photon/PhotonLibs/WebSocket/WebSocket.cs
Normal file
@ -0,0 +1,188 @@
|
||||
#if UNITY_WEBGL || WEBSOCKET || ((UNITY_XBOXONE || UNITY_GAMECORE) && UNITY_EDITOR)
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <summary>
|
||||
// Provided originally by Unity to cover WebSocket support in WebGL and the Editor. Modified by Exit Games GmbH.
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace ExitGames.Client.Photon
|
||||
{
|
||||
using System;
|
||||
using System.Text;
|
||||
#if UNITY_WEBGL && !UNITY_EDITOR
|
||||
using System.Runtime.InteropServices;
|
||||
#else
|
||||
using WebSocketSharp;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Authentication;
|
||||
#endif
|
||||
|
||||
|
||||
public class WebSocket
|
||||
{
|
||||
private Uri mUrl;
|
||||
/// <summary>Photon uses this to agree on a serialization protocol. Either: GpBinaryV16 or GpBinaryV18. Based on enum SerializationProtocol.</summary>
|
||||
private string protocols = "GpBinaryV16";
|
||||
|
||||
public WebSocket(Uri url, string serialization = null)
|
||||
{
|
||||
this.mUrl = url;
|
||||
if (serialization != null)
|
||||
{
|
||||
this.protocols = serialization;
|
||||
}
|
||||
|
||||
string protocol = mUrl.Scheme;
|
||||
if (!protocol.Equals("ws") && !protocol.Equals("wss"))
|
||||
throw new ArgumentException("Unsupported protocol: " + protocol);
|
||||
}
|
||||
|
||||
public void SendString(string str)
|
||||
{
|
||||
Send(Encoding.UTF8.GetBytes (str));
|
||||
}
|
||||
|
||||
public string RecvString()
|
||||
{
|
||||
byte[] retval = Recv();
|
||||
if (retval == null)
|
||||
return null;
|
||||
return Encoding.UTF8.GetString (retval);
|
||||
}
|
||||
|
||||
#if UNITY_WEBGL && !UNITY_EDITOR
|
||||
[DllImport("__Internal")]
|
||||
private static extern int SocketCreate (string url, string protocols);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int SocketState (int socketInstance);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void SocketSend (int socketInstance, byte[] ptr, int length);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void SocketRecv (int socketInstance, byte[] ptr, int length);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int SocketRecvLength (int socketInstance);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void SocketClose (int socketInstance);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int SocketError (int socketInstance, byte[] ptr, int length);
|
||||
|
||||
int m_NativeRef = 0;
|
||||
|
||||
public void Send(byte[] buffer)
|
||||
{
|
||||
SocketSend (m_NativeRef, buffer, buffer.Length);
|
||||
}
|
||||
|
||||
public byte[] Recv()
|
||||
{
|
||||
int length = SocketRecvLength (m_NativeRef);
|
||||
if (length == 0)
|
||||
return null;
|
||||
byte[] buffer = new byte[length];
|
||||
SocketRecv (m_NativeRef, buffer, length);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
m_NativeRef = SocketCreate (mUrl.ToString(), this.protocols);
|
||||
|
||||
//while (SocketState(m_NativeRef) == 0)
|
||||
// yield return 0;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
SocketClose(m_NativeRef);
|
||||
}
|
||||
|
||||
public bool Connected
|
||||
{
|
||||
get { return SocketState(m_NativeRef) != 0; }
|
||||
}
|
||||
|
||||
public string Error
|
||||
{
|
||||
get {
|
||||
const int bufsize = 1024;
|
||||
byte[] buffer = new byte[bufsize];
|
||||
int result = SocketError (m_NativeRef, buffer, bufsize);
|
||||
|
||||
if (result == 0)
|
||||
return null;
|
||||
|
||||
return Encoding.UTF8.GetString (buffer);
|
||||
}
|
||||
}
|
||||
#else
|
||||
WebSocketSharp.WebSocket m_Socket;
|
||||
Queue<byte[]> m_Messages = new Queue<byte[]>();
|
||||
bool m_IsConnected = false;
|
||||
string m_Error = null;
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
m_Socket = new WebSocketSharp.WebSocket(mUrl.ToString(), new string[] { this.protocols });
|
||||
m_Socket.SslConfiguration.EnabledSslProtocols = m_Socket.SslConfiguration.EnabledSslProtocols | (SslProtocols)(3072| 768);
|
||||
m_Socket.OnMessage += (sender, e) => m_Messages.Enqueue(e.RawData);
|
||||
m_Socket.OnOpen += (sender, e) => m_IsConnected = true;
|
||||
//this.m_Socket.Log.Level = LogLevel.Debug;
|
||||
//this.m_Socket.Log.Output += Output;
|
||||
this.m_Socket.OnClose += SocketOnClose;
|
||||
m_Socket.OnError += (sender, e) => m_Error = e.Message + (e.Exception == null ? "" : " / " + e.Exception);
|
||||
m_Socket.ConnectAsync();
|
||||
}
|
||||
|
||||
private void SocketOnClose(object sender, CloseEventArgs e)
|
||||
{
|
||||
//UnityEngine.Debug.Log(e.Code.ToString());
|
||||
|
||||
// this code is used for cases when the socket failed to get created (specifically used to detect "blocked by Windows firewall")
|
||||
// for some reason this situation is not calling OnError
|
||||
if (e.Code == 1006)
|
||||
{
|
||||
this.m_Error = e.Reason;
|
||||
this.m_IsConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Connected { get { return m_IsConnected; } }// added by TS
|
||||
|
||||
|
||||
public void Send(byte[] buffer)
|
||||
{
|
||||
m_Socket.Send(buffer);
|
||||
}
|
||||
|
||||
public byte[] Recv()
|
||||
{
|
||||
if (m_Messages.Count == 0)
|
||||
return null;
|
||||
return m_Messages.Dequeue();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
m_Socket.Close();
|
||||
}
|
||||
|
||||
public string Error
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Error;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
8
Assets/Photon/PhotonLibs/WebSocket/WebSocket.cs.meta
Normal file
8
Assets/Photon/PhotonLibs/WebSocket/WebSocket.cs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1bad04f7805f764dba77f0d4518e0f0
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
117
Assets/Photon/PhotonLibs/WebSocket/WebSocket.jslib
Normal file
117
Assets/Photon/PhotonLibs/WebSocket/WebSocket.jslib
Normal file
@ -0,0 +1,117 @@
|
||||
var LibraryWebSockets = {
|
||||
$webSocketInstances: [],
|
||||
|
||||
SocketCreate: function(url, protocols)
|
||||
{
|
||||
var str = UTF8ToString(url);
|
||||
var prot = UTF8ToString(protocols);
|
||||
var socket = {
|
||||
socket: new WebSocket(str, [prot]),
|
||||
buffer: new Uint8Array(0),
|
||||
error: null,
|
||||
messages: []
|
||||
}
|
||||
socket.socket.binaryType = 'arraybuffer';
|
||||
socket.socket.onmessage = function (e) {
|
||||
// if (e.data instanceof Blob)
|
||||
// {
|
||||
// var reader = new FileReader();
|
||||
// reader.addEventListener("loadend", function() {
|
||||
// var array = new Uint8Array(reader.result);
|
||||
// socket.messages.push(array);
|
||||
// });
|
||||
// reader.readAsArrayBuffer(e.data);
|
||||
// }
|
||||
if (e.data instanceof ArrayBuffer)
|
||||
{
|
||||
var array = new Uint8Array(e.data);
|
||||
socket.messages.push(array);
|
||||
}
|
||||
};
|
||||
socket.socket.onclose = function (e) {
|
||||
if (e.code != 1000)
|
||||
{
|
||||
if (e.reason != null && e.reason.length > 0)
|
||||
socket.error = e.reason;
|
||||
else
|
||||
{
|
||||
switch (e.code)
|
||||
{
|
||||
case 1001:
|
||||
socket.error = "Endpoint going away.";
|
||||
break;
|
||||
case 1002:
|
||||
socket.error = "Protocol error.";
|
||||
break;
|
||||
case 1003:
|
||||
socket.error = "Unsupported message.";
|
||||
break;
|
||||
case 1005:
|
||||
socket.error = "No status.";
|
||||
break;
|
||||
case 1006:
|
||||
socket.error = "Abnormal disconnection.";
|
||||
break;
|
||||
case 1009:
|
||||
socket.error = "Data frame too large.";
|
||||
break;
|
||||
default:
|
||||
socket.error = "Error "+e.code;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var instance = webSocketInstances.push(socket) - 1;
|
||||
return instance;
|
||||
},
|
||||
|
||||
SocketState: function (socketInstance)
|
||||
{
|
||||
var socket = webSocketInstances[socketInstance];
|
||||
return socket.socket.readyState;
|
||||
},
|
||||
|
||||
SocketError: function (socketInstance, ptr, bufsize)
|
||||
{
|
||||
var socket = webSocketInstances[socketInstance];
|
||||
if (socket.error == null)
|
||||
return 0;
|
||||
var str = socket.error.slice(0, Math.max(0, bufsize - 1));
|
||||
writeStringToMemory(str, ptr, false);
|
||||
return 1;
|
||||
},
|
||||
|
||||
SocketSend: function (socketInstance, ptr, length)
|
||||
{
|
||||
var socket = webSocketInstances[socketInstance];
|
||||
socket.socket.send (HEAPU8.buffer.slice(ptr, ptr+length));
|
||||
},
|
||||
|
||||
SocketRecvLength: function(socketInstance)
|
||||
{
|
||||
var socket = webSocketInstances[socketInstance];
|
||||
if (socket.messages.length == 0)
|
||||
return 0;
|
||||
return socket.messages[0].length;
|
||||
},
|
||||
|
||||
SocketRecv: function (socketInstance, ptr, length)
|
||||
{
|
||||
var socket = webSocketInstances[socketInstance];
|
||||
if (socket.messages.length == 0)
|
||||
return 0;
|
||||
if (socket.messages[0].length > length)
|
||||
return 0;
|
||||
HEAPU8.set(socket.messages[0], ptr);
|
||||
socket.messages = socket.messages.slice(1);
|
||||
},
|
||||
|
||||
SocketClose: function (socketInstance)
|
||||
{
|
||||
var socket = webSocketInstances[socketInstance];
|
||||
socket.socket.close();
|
||||
}
|
||||
};
|
||||
|
||||
autoAddDeps(LibraryWebSockets, '$webSocketInstances');
|
||||
mergeInto(LibraryManager.library, LibraryWebSockets);
|
21
Assets/Photon/PhotonLibs/WebSocket/WebSocket.jslib.meta
Normal file
21
Assets/Photon/PhotonLibs/WebSocket/WebSocket.jslib.meta
Normal file
@ -0,0 +1,21 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04bb5f307f2e48b4fbaa6da865fd4091
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
platformData:
|
||||
Any:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
Editor:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
WebGL:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,3 @@
|
||||
websocket-sharp.dll built from https://github.com/sta/websocket-sharp.git, commit 869dfb09778de51081b0ae64bd2c3217cffe0699 on Aug 24, 2016.
|
||||
|
||||
websocket-sharp is provided under The MIT License as mentioned here: https://github.com/sta/websocket-sharp#license
|
@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e262c2b04eaa8440987b50a91e86674
|
||||
DefaultImporter:
|
||||
userData:
|
BIN
Assets/Photon/PhotonLibs/WebSocket/websocket-sharp.dll
Normal file
BIN
Assets/Photon/PhotonLibs/WebSocket/websocket-sharp.dll
Normal file
Binary file not shown.
137
Assets/Photon/PhotonLibs/WebSocket/websocket-sharp.dll.meta
Normal file
137
Assets/Photon/PhotonLibs/WebSocket/websocket-sharp.dll.meta
Normal file
@ -0,0 +1,137 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 748eb70bc0d7515498ef73fed155520a
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
- first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 0
|
||||
Exclude Editor: 0
|
||||
Exclude Linux: 0
|
||||
Exclude Linux64: 0
|
||||
Exclude LinuxUniversal: 0
|
||||
Exclude OSXUniversal: 0
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 0
|
||||
Exclude Win64: 0
|
||||
Exclude WindowsStoreApps: 1
|
||||
- first:
|
||||
'': OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
'': OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
'': WP8
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
- first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
- first:
|
||||
XboxOne: XboxOne
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1815
Assets/Photon/PhotonLibs/changes-library.txt
Normal file
1815
Assets/Photon/PhotonLibs/changes-library.txt
Normal file
File diff suppressed because it is too large
Load Diff
8
Assets/Photon/PhotonLibs/changes-library.txt.meta
Normal file
8
Assets/Photon/PhotonLibs/changes-library.txt.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8040d310df77714a90a561261bfb2cb
|
||||
timeCreated: 1557919981
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Photon/PhotonLibs/netstandard2.0.meta
Normal file
8
Assets/Photon/PhotonLibs/netstandard2.0.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: beb9d2a25c882b54ab2fd9adaec2b53c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user