Showing
37 changed files
with
2093 additions
and
133 deletions
... | @@ -18,6 +18,17 @@ | ... | @@ -18,6 +18,17 @@ |
18 | # Visual Studio 2015 cache directory | 18 | # Visual Studio 2015 cache directory |
19 | /Basic Network Library/.vs/ | 19 | /Basic Network Library/.vs/ |
20 | 20 | ||
21 | +/Network Chatting/[Ll]ibrary/ | ||
22 | +/Network Chatting/[Tt]emp/ | ||
23 | +/Network Chatting/[Oo]bj/ | ||
24 | +/Network Chatting/[Bb]uild/ | ||
25 | +/Network Chatting/[Bb]uilds/ | ||
26 | +/Network Chatting/Assets/AssetStoreTools* | ||
27 | + | ||
28 | +# Visual Studio 2015 cache directory | ||
29 | +/Network Chatting/.vs/ | ||
30 | + | ||
31 | + | ||
21 | # Autogenerated VS/MD/Consulo solution and project files | 32 | # Autogenerated VS/MD/Consulo solution and project files |
22 | ExportedObj/ | 33 | ExportedObj/ |
23 | .consulo/ | 34 | .consulo/ | ... | ... |
1 | - | ||
2 | -// TCP로 통신할 때는 정의를 유효하게 하여 주십시오. | ||
3 | -#define USE_TRANSPORT_TCP | ||
4 | - | ||
5 | -using UnityEngine; | ||
6 | -using System.Collections; | ||
7 | -using System.Net; | ||
8 | - | ||
9 | - | ||
10 | -public class LibrarySample : MonoBehaviour { | ||
11 | - | ||
12 | - // 통신 모듈. | ||
13 | - public GameObject transportTcpPrefab; | ||
14 | - public GameObject transportUdpPrefab; | ||
15 | - | ||
16 | - // 통신용 변수. | ||
17 | -#if USE_TRANSPORT_TCP | ||
18 | - TransportTCP m_transport = null; | ||
19 | -#else | ||
20 | - TransportUDP m_transport = null; | ||
21 | -#endif | ||
22 | - | ||
23 | - // 접속할 IP 주소. | ||
24 | - private string m_strings = ""; | ||
25 | - | ||
26 | - // 접속할 포트 번호. | ||
27 | - private const int m_port = 50765; | ||
28 | - | ||
29 | - private const int m_mtu = 1400; | ||
30 | - | ||
31 | - private bool isSelected = false; | ||
32 | - | ||
33 | - | ||
34 | - // Use this for initialization | ||
35 | - void Start () | ||
36 | - { | ||
37 | - // Transport 클래스의 컴포넌트를 가져온다. | ||
38 | -#if USE_TRANSPORT_TCP | ||
39 | - GameObject obj = GameObject.Instantiate(transportTcpPrefab) as GameObject; | ||
40 | - m_transport = obj.GetComponent<TransportTCP>(); | ||
41 | -#else | ||
42 | - GameObject obj = GameObject.Instantiate(transportUdpPrefab) as GameObject; | ||
43 | - m_transport = obj.GetComponent<TransportUDP>(); | ||
44 | -#endif | ||
45 | - | ||
46 | - IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); | ||
47 | - System.Net.IPAddress hostAddress = hostEntry.AddressList[0]; | ||
48 | - Debug.Log(hostEntry.HostName); | ||
49 | - m_strings = hostAddress.ToString(); | ||
50 | - } | ||
51 | - | ||
52 | - // Update is called once per frame | ||
53 | - void Update () | ||
54 | - { | ||
55 | - if (m_transport != null && m_transport.isConnected == true) { | ||
56 | - byte[] buffer = new byte[m_mtu]; | ||
57 | - int recvSize = m_transport.Receive(ref buffer, buffer.Length); | ||
58 | - if (recvSize > 0) { | ||
59 | - string message = System.Text.Encoding.UTF8.GetString(buffer); | ||
60 | - Debug.Log(message); | ||
61 | - } | ||
62 | - } | ||
63 | - } | ||
64 | - | ||
65 | - void OnGUI() | ||
66 | - { | ||
67 | - if (isSelected == false) { | ||
68 | - OnGUISelectHost(); | ||
69 | - } | ||
70 | - else { | ||
71 | - if (m_transport.isServer == true) { | ||
72 | - OnGUIServer(); | ||
73 | - } | ||
74 | - else { | ||
75 | - OnGUIClient(); | ||
76 | - } | ||
77 | - } | ||
78 | - } | ||
79 | - | ||
80 | - void OnGUISelectHost() | ||
81 | - { | ||
82 | -#if USE_TRANSPORT_TCP | ||
83 | - if (GUI.Button (new Rect (20,40, 150,20), "Launch server.")) { | ||
84 | -#else | ||
85 | - if (GUI.Button (new Rect (20,40, 150,20), "Launch Listener.")) { | ||
86 | -#endif | ||
87 | - m_transport.StartServer(m_port, 1); | ||
88 | - isSelected = true; | ||
89 | - } | ||
90 | - | ||
91 | - // 클라이언트를 선택했을 때 접속할 서버 주소를 입력합니다. | ||
92 | - m_strings = GUI.TextField(new Rect(20, 100, 200, 20), m_strings); | ||
93 | -#if USE_TRANSPORT_TCP | ||
94 | - if (GUI.Button (new Rect (20,70,150,20), "Connect to server")) { | ||
95 | -#else | ||
96 | - if (GUI.Button (new Rect (20,70,150,20), "Connect to terminal")) { | ||
97 | -#endif | ||
98 | - m_transport.Connect(m_strings, m_port); | ||
99 | - isSelected = true; | ||
100 | - m_strings = ""; | ||
101 | - } | ||
102 | - } | ||
103 | - | ||
104 | - void OnGUIServer() | ||
105 | - { | ||
106 | -#if USE_TRANSPORT_TCP | ||
107 | - if (GUI.Button (new Rect (20,60, 150,20), "Stop server")) { | ||
108 | -#else | ||
109 | - if (GUI.Button (new Rect (20,60, 150,20), "Stop Listener")) { | ||
110 | -#endif | ||
111 | - m_transport.StopServer(); | ||
112 | - isSelected = false; | ||
113 | - m_strings = ""; | ||
114 | - } | ||
115 | - } | ||
116 | - | ||
117 | - | ||
118 | - void OnGUIClient() | ||
119 | - { | ||
120 | - // 클라이언트를 선택했을 때 접속할 서버의 주소를 입력합니다. | ||
121 | - if (GUI.Button (new Rect (20,70,150,20), "Send message")) { | ||
122 | - byte[] buffer = System.Text.Encoding.UTF8.GetBytes("Hellow, this is client."); | ||
123 | - m_transport.Send(buffer, buffer.Length); | ||
124 | - } | ||
125 | - | ||
126 | - if (GUI.Button (new Rect (20,100, 150,20), "Disconnect")) { | ||
127 | - m_transport.Disconnect(); | ||
128 | - isSelected = false; | ||
129 | - m_strings = ""; | ||
130 | - } | ||
131 | - } | ||
132 | - | ||
133 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
Network Chatting/.vscode/settings.json
0 → 100644
1 | +{ | ||
2 | + "files.exclude": | ||
3 | + { | ||
4 | + "**/.DS_Store":true, | ||
5 | + "**/.git":true, | ||
6 | + "**/.gitignore":true, | ||
7 | + "**/.gitmodules":true, | ||
8 | + "**/*.booproj":true, | ||
9 | + "**/*.pidb":true, | ||
10 | + "**/*.suo":true, | ||
11 | + "**/*.user":true, | ||
12 | + "**/*.userprefs":true, | ||
13 | + "**/*.unityproj":true, | ||
14 | + "**/*.dll":true, | ||
15 | + "**/*.exe":true, | ||
16 | + "**/*.pdf":true, | ||
17 | + "**/*.mid":true, | ||
18 | + "**/*.midi":true, | ||
19 | + "**/*.wav":true, | ||
20 | + "**/*.gif":true, | ||
21 | + "**/*.ico":true, | ||
22 | + "**/*.jpg":true, | ||
23 | + "**/*.jpeg":true, | ||
24 | + "**/*.png":true, | ||
25 | + "**/*.psd":true, | ||
26 | + "**/*.tga":true, | ||
27 | + "**/*.tif":true, | ||
28 | + "**/*.tiff":true, | ||
29 | + "**/*.3ds":true, | ||
30 | + "**/*.3DS":true, | ||
31 | + "**/*.fbx":true, | ||
32 | + "**/*.FBX":true, | ||
33 | + "**/*.lxo":true, | ||
34 | + "**/*.LXO":true, | ||
35 | + "**/*.ma":true, | ||
36 | + "**/*.MA":true, | ||
37 | + "**/*.obj":true, | ||
38 | + "**/*.OBJ":true, | ||
39 | + "**/*.asset":true, | ||
40 | + "**/*.cubemap":true, | ||
41 | + "**/*.flare":true, | ||
42 | + "**/*.mat":true, | ||
43 | + "**/*.meta":true, | ||
44 | + "**/*.prefab":true, | ||
45 | + "**/*.unity":true, | ||
46 | + "build/":true, | ||
47 | + "Build/":true, | ||
48 | + "Library/":true, | ||
49 | + "library/":true, | ||
50 | + "obj/":true, | ||
51 | + "Obj/":true, | ||
52 | + "ProjectSettings/":true, | ||
53 | + "temp/":true, | ||
54 | + "Temp/":true | ||
55 | + } | ||
56 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
Network Chatting/Assets/Comment.prefab
0 → 100644
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!1001 &100100000 | ||
4 | +Prefab: | ||
5 | + m_ObjectHideFlags: 1 | ||
6 | + serializedVersion: 2 | ||
7 | + m_Modification: | ||
8 | + m_TransformParent: {fileID: 0} | ||
9 | + m_Modifications: [] | ||
10 | + m_RemovedComponents: [] | ||
11 | + m_ParentPrefab: {fileID: 0} | ||
12 | + m_RootGameObject: {fileID: 1351082387170804} | ||
13 | + m_IsPrefabParent: 1 | ||
14 | +--- !u!1 &1351082387170804 | ||
15 | +GameObject: | ||
16 | + m_ObjectHideFlags: 0 | ||
17 | + m_PrefabParentObject: {fileID: 0} | ||
18 | + m_PrefabInternal: {fileID: 100100000} | ||
19 | + serializedVersion: 5 | ||
20 | + m_Component: | ||
21 | + - component: {fileID: 224026180460817448} | ||
22 | + - component: {fileID: 222343435350097842} | ||
23 | + - component: {fileID: 114640140560748198} | ||
24 | + - component: {fileID: 114312857566104806} | ||
25 | + m_Layer: 5 | ||
26 | + m_Name: Comment | ||
27 | + m_TagString: Untagged | ||
28 | + m_Icon: {fileID: 0} | ||
29 | + m_NavMeshLayer: 0 | ||
30 | + m_StaticEditorFlags: 0 | ||
31 | + m_IsActive: 1 | ||
32 | +--- !u!1 &1889659296805252 | ||
33 | +GameObject: | ||
34 | + m_ObjectHideFlags: 0 | ||
35 | + m_PrefabParentObject: {fileID: 0} | ||
36 | + m_PrefabInternal: {fileID: 100100000} | ||
37 | + serializedVersion: 5 | ||
38 | + m_Component: | ||
39 | + - component: {fileID: 224999107880086880} | ||
40 | + - component: {fileID: 222081966344987208} | ||
41 | + - component: {fileID: 114206746021236310} | ||
42 | + m_Layer: 5 | ||
43 | + m_Name: Text | ||
44 | + m_TagString: Untagged | ||
45 | + m_Icon: {fileID: 0} | ||
46 | + m_NavMeshLayer: 0 | ||
47 | + m_StaticEditorFlags: 0 | ||
48 | + m_IsActive: 1 | ||
49 | +--- !u!114 &114206746021236310 | ||
50 | +MonoBehaviour: | ||
51 | + m_ObjectHideFlags: 1 | ||
52 | + m_PrefabParentObject: {fileID: 0} | ||
53 | + m_PrefabInternal: {fileID: 100100000} | ||
54 | + m_GameObject: {fileID: 1889659296805252} | ||
55 | + m_Enabled: 1 | ||
56 | + m_EditorHideFlags: 0 | ||
57 | + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} | ||
58 | + m_Name: | ||
59 | + m_EditorClassIdentifier: | ||
60 | + m_Material: {fileID: 0} | ||
61 | + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} | ||
62 | + m_RaycastTarget: 1 | ||
63 | + m_OnCullStateChanged: | ||
64 | + m_PersistentCalls: | ||
65 | + m_Calls: [] | ||
66 | + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, | ||
67 | + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | ||
68 | + m_FontData: | ||
69 | + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} | ||
70 | + m_FontSize: 14 | ||
71 | + m_FontStyle: 0 | ||
72 | + m_BestFit: 0 | ||
73 | + m_MinSize: 10 | ||
74 | + m_MaxSize: 40 | ||
75 | + m_Alignment: 0 | ||
76 | + m_AlignByGeometry: 0 | ||
77 | + m_RichText: 1 | ||
78 | + m_HorizontalOverflow: 0 | ||
79 | + m_VerticalOverflow: 0 | ||
80 | + m_LineSpacing: 1 | ||
81 | + m_Text: Sample Text | ||
82 | +--- !u!114 &114312857566104806 | ||
83 | +MonoBehaviour: | ||
84 | + m_ObjectHideFlags: 1 | ||
85 | + m_PrefabParentObject: {fileID: 0} | ||
86 | + m_PrefabInternal: {fileID: 100100000} | ||
87 | + m_GameObject: {fileID: 1351082387170804} | ||
88 | + m_Enabled: 1 | ||
89 | + m_EditorHideFlags: 0 | ||
90 | + m_Script: {fileID: 11500000, guid: e3c2e0a12ace649978c3c197ab4726a6, type: 3} | ||
91 | + m_Name: | ||
92 | + m_EditorClassIdentifier: | ||
93 | + commentText: {fileID: 114206746021236310} | ||
94 | +--- !u!114 &114640140560748198 | ||
95 | +MonoBehaviour: | ||
96 | + m_ObjectHideFlags: 1 | ||
97 | + m_PrefabParentObject: {fileID: 0} | ||
98 | + m_PrefabInternal: {fileID: 100100000} | ||
99 | + m_GameObject: {fileID: 1351082387170804} | ||
100 | + m_Enabled: 1 | ||
101 | + m_EditorHideFlags: 0 | ||
102 | + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} | ||
103 | + m_Name: | ||
104 | + m_EditorClassIdentifier: | ||
105 | + m_Material: {fileID: 0} | ||
106 | + m_Color: {r: 1, g: 1, b: 1, a: 1} | ||
107 | + m_RaycastTarget: 1 | ||
108 | + m_OnCullStateChanged: | ||
109 | + m_PersistentCalls: | ||
110 | + m_Calls: [] | ||
111 | + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, | ||
112 | + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | ||
113 | + m_Sprite: {fileID: 0} | ||
114 | + m_Type: 0 | ||
115 | + m_PreserveAspect: 0 | ||
116 | + m_FillCenter: 1 | ||
117 | + m_FillMethod: 4 | ||
118 | + m_FillAmount: 1 | ||
119 | + m_FillClockwise: 1 | ||
120 | + m_FillOrigin: 0 | ||
121 | +--- !u!222 &222081966344987208 | ||
122 | +CanvasRenderer: | ||
123 | + m_ObjectHideFlags: 1 | ||
124 | + m_PrefabParentObject: {fileID: 0} | ||
125 | + m_PrefabInternal: {fileID: 100100000} | ||
126 | + m_GameObject: {fileID: 1889659296805252} | ||
127 | +--- !u!222 &222343435350097842 | ||
128 | +CanvasRenderer: | ||
129 | + m_ObjectHideFlags: 1 | ||
130 | + m_PrefabParentObject: {fileID: 0} | ||
131 | + m_PrefabInternal: {fileID: 100100000} | ||
132 | + m_GameObject: {fileID: 1351082387170804} | ||
133 | +--- !u!224 &224026180460817448 | ||
134 | +RectTransform: | ||
135 | + m_ObjectHideFlags: 1 | ||
136 | + m_PrefabParentObject: {fileID: 0} | ||
137 | + m_PrefabInternal: {fileID: 100100000} | ||
138 | + m_GameObject: {fileID: 1351082387170804} | ||
139 | + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||
140 | + m_LocalPosition: {x: 0, y: 0, z: 0} | ||
141 | + m_LocalScale: {x: 1, y: 1, z: 1} | ||
142 | + m_Children: | ||
143 | + - {fileID: 224999107880086880} | ||
144 | + m_Father: {fileID: 0} | ||
145 | + m_RootOrder: 0 | ||
146 | + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||
147 | + m_AnchorMin: {x: 0, y: 0} | ||
148 | + m_AnchorMax: {x: 0, y: 0} | ||
149 | + m_AnchoredPosition: {x: 0, y: 0} | ||
150 | + m_SizeDelta: {x: 200, y: 50} | ||
151 | + m_Pivot: {x: 0.5, y: 0.5} | ||
152 | +--- !u!224 &224999107880086880 | ||
153 | +RectTransform: | ||
154 | + m_ObjectHideFlags: 1 | ||
155 | + m_PrefabParentObject: {fileID: 0} | ||
156 | + m_PrefabInternal: {fileID: 100100000} | ||
157 | + m_GameObject: {fileID: 1889659296805252} | ||
158 | + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||
159 | + m_LocalPosition: {x: 0, y: 0, z: 0} | ||
160 | + m_LocalScale: {x: 1, y: 1, z: 1} | ||
161 | + m_Children: [] | ||
162 | + m_Father: {fileID: 224026180460817448} | ||
163 | + m_RootOrder: 0 | ||
164 | + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||
165 | + m_AnchorMin: {x: 0, y: 0} | ||
166 | + m_AnchorMax: {x: 1, y: 1} | ||
167 | + m_AnchoredPosition: {x: 0, y: 0} | ||
168 | + m_SizeDelta: {x: 0, y: 0} | ||
169 | + m_Pivot: {x: 0.5, y: 0.5} |
Network Chatting/Assets/Comment.prefab.meta
0 → 100644
Network Chatting/Assets/Main.unity
0 → 100644
This diff is collapsed. Click to expand it.
Network Chatting/Assets/Main.unity.meta
0 → 100644
Network Chatting/Assets/Scripts.meta
0 → 100644
Network Chatting/Assets/Scripts/Chat.cs
0 → 100644
1 | +using UnityEngine; | ||
2 | +using System; | ||
3 | +using System.Collections; | ||
4 | +using System.Collections.Generic; | ||
5 | +using System.Net; | ||
6 | + | ||
7 | +public class Chat : MonoBehaviour | ||
8 | +{ | ||
9 | + public TransportTCP m_transport; | ||
10 | + | ||
11 | + public ChatText commentTextPrefab; | ||
12 | + | ||
13 | + public Transform commentHolder; | ||
14 | + | ||
15 | + public string m_hostAddress {get; set;} | ||
16 | + | ||
17 | + private const int m_port = 50765; | ||
18 | + | ||
19 | + private bool m_isServer = false; | ||
20 | + | ||
21 | + | ||
22 | + // Use this for initialization | ||
23 | + void Start() | ||
24 | + { | ||
25 | + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); | ||
26 | + | ||
27 | + System.Net.IPAddress hostAddress = hostEntry.AddressList[0]; | ||
28 | + | ||
29 | + Debug.Log(hostEntry.HostName); | ||
30 | + | ||
31 | + m_hostAddress = hostAddress.ToString (); | ||
32 | + m_transport.onStateChanged += OnEventHandling; | ||
33 | + | ||
34 | + } | ||
35 | + | ||
36 | + | ||
37 | + IEnumerator UpdateChatting() | ||
38 | + { | ||
39 | + while(true) | ||
40 | + { | ||
41 | + byte[] buffer = new byte[1400]; | ||
42 | + | ||
43 | + int recvSize = m_transport.Receive(ref buffer, buffer.Length); | ||
44 | + if (recvSize > 0) { | ||
45 | + string message = System.Text.Encoding.UTF8.GetString(buffer); | ||
46 | + Debug.Log("Recv data:" + message ); | ||
47 | + | ||
48 | + AddComment(message); | ||
49 | + } | ||
50 | + | ||
51 | + yield return null; | ||
52 | + } | ||
53 | + } | ||
54 | + | ||
55 | + | ||
56 | + void Send(string message) | ||
57 | + { | ||
58 | + message = "[" + DateTime.Now.ToString("HH:mm:ss") + "] " + message; | ||
59 | + | ||
60 | + byte[] buffer = System.Text.Encoding.UTF8.GetBytes(message); | ||
61 | + | ||
62 | + m_transport.Send(buffer, buffer.Length); | ||
63 | + | ||
64 | + AddComment(message); | ||
65 | + } | ||
66 | + | ||
67 | + | ||
68 | + void AddComment(string message) | ||
69 | + { | ||
70 | + var newComment = Instantiate(commentTextPrefab,commentHolder); | ||
71 | + newComment.SetUp(message); | ||
72 | + } | ||
73 | + void OnApplicationQuit() { | ||
74 | + if (m_transport != null) { | ||
75 | + if(m_isServer) | ||
76 | + { | ||
77 | + m_transport.StopServer(); | ||
78 | + } | ||
79 | + else | ||
80 | + { | ||
81 | + m_transport.Disconnect(); | ||
82 | + } | ||
83 | + } | ||
84 | + } | ||
85 | + | ||
86 | + public void OnEventHandling(NetEventState state) | ||
87 | + { | ||
88 | + switch (state.type) { | ||
89 | + case NetEventType.Connect: | ||
90 | + AddComment("접속"); | ||
91 | + break; | ||
92 | + | ||
93 | + case NetEventType.Disconnect: | ||
94 | + AddComment("접속 종료"); | ||
95 | + break; | ||
96 | + } | ||
97 | + } | ||
98 | + | ||
99 | + | ||
100 | + public void CreateRoom() | ||
101 | + { | ||
102 | + m_transport.StartServer(m_port, 1); | ||
103 | + m_isServer = true; | ||
104 | + } | ||
105 | + | ||
106 | + public void JoinChatRoom() | ||
107 | + { | ||
108 | + bool ret = m_transport.Connect(m_hostAddress, m_port); | ||
109 | + | ||
110 | + if (ret) { | ||
111 | + StartCoroutine("UpdateChatting"); | ||
112 | + } | ||
113 | + else { | ||
114 | + Debug.LogError("Failed"); | ||
115 | + } | ||
116 | + } | ||
117 | + | ||
118 | + | ||
119 | + public void Leave() | ||
120 | + { | ||
121 | + if (m_isServer == true) { | ||
122 | + m_transport.StopServer(); | ||
123 | + } | ||
124 | + else { | ||
125 | + m_transport.Disconnect(); | ||
126 | + } | ||
127 | + | ||
128 | + StopCoroutine("UpdateChatting"); | ||
129 | + } | ||
130 | + | ||
131 | + | ||
132 | +} |
Network Chatting/Assets/Scripts/Chat.cs.meta
0 → 100644
1 | +fileFormatVersion: 2 | ||
2 | +guid: 7d91d3622aead48008aca0d637d4ad9b | ||
3 | +timeCreated: 1517219122 | ||
4 | +licenseType: Pro | ||
5 | +MonoImporter: | ||
6 | + externalObjects: {} | ||
7 | + serializedVersion: 2 | ||
8 | + defaultReferences: [] | ||
9 | + executionOrder: 0 | ||
10 | + icon: {instanceID: 0} | ||
11 | + userData: | ||
12 | + assetBundleName: | ||
13 | + assetBundleVariant: |
Network Chatting/Assets/Scripts/ChatText.cs
0 → 100644
1 | +fileFormatVersion: 2 | ||
2 | +guid: e3c2e0a12ace649978c3c197ab4726a6 | ||
3 | +timeCreated: 1517221132 | ||
4 | +licenseType: Pro | ||
5 | +MonoImporter: | ||
6 | + externalObjects: {} | ||
7 | + serializedVersion: 2 | ||
8 | + defaultReferences: [] | ||
9 | + executionOrder: 0 | ||
10 | + icon: {instanceID: 0} | ||
11 | + userData: | ||
12 | + assetBundleName: | ||
13 | + assetBundleVariant: |
1 | +// 이벤트 종류 | ||
2 | +public enum NetEventType | ||
3 | +{ | ||
4 | + Connect = 0, // 연결 이벤트 | ||
5 | + Disconnect, // 끊기 이벤트 | ||
6 | + SendError, // 송신 오류 | ||
7 | + ReceiveError, // 수신 오류 | ||
8 | +} | ||
9 | + | ||
10 | +// 이벤트 결과 | ||
11 | +public enum NetEventResult | ||
12 | +{ | ||
13 | + Failure = -1, // 실패 | ||
14 | + Success = 0, // 성공 | ||
15 | +} | ||
16 | + | ||
17 | +// 이벤트 상태 통지용 타입 | ||
18 | +public class NetEventState | ||
19 | +{ | ||
20 | + public NetEventType type; // 이벤트 타입 | ||
21 | + public NetEventResult result; // 이벤트 결과 | ||
22 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +fileFormatVersion: 2 | ||
2 | +guid: 7a68fdeeae9b0445992ea9d05f42454e | ||
3 | +timeCreated: 1517151676 | ||
4 | +licenseType: Pro | ||
5 | +MonoImporter: | ||
6 | + externalObjects: {} | ||
7 | + serializedVersion: 2 | ||
8 | + defaultReferences: [] | ||
9 | + executionOrder: 0 | ||
10 | + icon: {instanceID: 0} | ||
11 | + userData: | ||
12 | + assetBundleName: | ||
13 | + assetBundleVariant: |
1 | +using System; | ||
2 | +using System.Collections; | ||
3 | +using System.Collections.Generic; | ||
4 | +using System.IO; | ||
5 | +using System.Runtime.InteropServices; // https://msdn.microsoft.com/ko-kr/library/system.runtime.interopservices(v=vs.110).aspx | ||
6 | + | ||
7 | +// 이 타입의 목적: 물흐르듯이 패킷을 쌓고 꺼내올수 있는 큐 | ||
8 | +public class PacketQueue | ||
9 | +{ | ||
10 | + // 대응되는 패킷이 정확히 스트림에서 어디 인덱스에 존재하는지 지정 | ||
11 | + struct PacketInfo | ||
12 | + { | ||
13 | + public int offset; // 이 데이터가 기록되기 시작한 지점 | ||
14 | + public int size; // 이 데이터의 사이즈 | ||
15 | + } | ||
16 | + | ||
17 | + // MemoryStream 은 데이터를 연속적으로 쌓고 빼낼수 있는 스트림 버퍼 | ||
18 | + // MemoryStream 은 디스크나 네트워크 연결이 아니라 메모리 상에 데이터를 저장하는 스트림 버퍼 | ||
19 | + // 데이터의 끊김이 없으므로 패킷으로는 다룰수 없다 | ||
20 | + private MemoryStream m_streamBuffer; | ||
21 | + | ||
22 | + | ||
23 | + private List<PacketInfo> m_waitingPackets; // 아직 디큐하지 못하고 쌓인 패킷들 | ||
24 | + | ||
25 | + private int m_cursor = 0; // 버퍼가 채워져 커서가 밀려난 지점, 데이터를 채울때 여기서 부터 채우면 됨 | ||
26 | + | ||
27 | + private Object lockObj = new Object(); // 데드락 방지용 단순 참고자 | ||
28 | + | ||
29 | + // 초기화 | ||
30 | + public PacketQueue() | ||
31 | + { | ||
32 | + m_streamBuffer = new MemoryStream(); | ||
33 | + m_waitingPackets = new List<PacketInfo>(); | ||
34 | + } | ||
35 | + | ||
36 | + // 큐에 바이트 데이터 추가 | ||
37 | + public int Enqueue(byte[] data, int size) | ||
38 | + { | ||
39 | + PacketInfo info = new PacketInfo(); | ||
40 | + | ||
41 | + info.offset = m_cursor; // 스트림내에서 이 데이터를 찾으려면 어디서 부터 읽으면 되는지 기록 | ||
42 | + info.size = size; | ||
43 | + | ||
44 | + lock(lockObj) // 데드락 방지 | ||
45 | + { | ||
46 | + // 패킷 저장 정보를 보존 | ||
47 | + m_waitingPackets.Add(info); | ||
48 | + | ||
49 | + // 패킷 데이터를 추가 | ||
50 | + | ||
51 | + m_streamBuffer.Position = m_cursor; // 스트림의 위치를 마지막으로 갱신한 커서 위치로. | ||
52 | + m_streamBuffer.Write(data,0,size); // 현재 위치에서 사이즈만큼 버퍼를 쌓기 | ||
53 | + m_streamBuffer.Flush(); // 적용 | ||
54 | + | ||
55 | + m_cursor += size; // 커서를 방금 추가한 패킷 만큼 오른쪽으로 이동 | ||
56 | + } | ||
57 | + | ||
58 | + return size; // 추가된 데이터의 사이즈를 리턴 | ||
59 | + } | ||
60 | + | ||
61 | + // 버퍼를 맡기면 채워서 넘겨줌 | ||
62 | + public int Dequeue(ref byte[] buffer, int size) | ||
63 | + { | ||
64 | + // 패킷 리스트에 남아있는게 없다면 종료 | ||
65 | + if(m_waitingPackets.Count <= 0) | ||
66 | + { | ||
67 | + return -1; | ||
68 | + } | ||
69 | + | ||
70 | + int recvSize = 0; | ||
71 | + | ||
72 | + // 데드락 방지 | ||
73 | + lock(lockObj) { | ||
74 | + // 가장 마지막에 추가된 패킷부터 가져온다 | ||
75 | + PacketInfo info = m_waitingPackets[0]; | ||
76 | + | ||
77 | + // 저장된 패킷 이상의 사이즈를 긁어올순 없음 | ||
78 | + int dataSize = Math.Min(size, info.size); | ||
79 | + | ||
80 | + // 읽기 시작할 위치 | ||
81 | + m_streamBuffer.Position = info.offset; | ||
82 | + // 현재 커서 위치에서 dataSize 만큼 오른쪽만큼 이동한 지점까지를 영역으로 | ||
83 | + // 데이터를 긁어와 입력으로 들어온 buffer 를 채움 | ||
84 | + recvSize = m_streamBuffer.Read(buffer, 0, dataSize); | ||
85 | + | ||
86 | + // 패킷을 꺼냈으므로 꺼낸 패킷에 대한 패킷 기록을 리스트에서 삭제 | ||
87 | + if(recvSize > 0) | ||
88 | + { | ||
89 | + m_waitingPackets.RemoveAt(0); | ||
90 | + } | ||
91 | + | ||
92 | + // 모든 큐 데이터를 꺼냈을때는 스트림을 다시 제로포인트로 클리어해서 메모리를 절약 | ||
93 | + if(m_waitingPackets.Count == 0) | ||
94 | + { | ||
95 | + Clear(); | ||
96 | + m_cursor = 0; | ||
97 | + } | ||
98 | + | ||
99 | + } | ||
100 | + return recvSize; | ||
101 | + | ||
102 | + } | ||
103 | + | ||
104 | + // 스트림버퍼의 커서를 초기화. 큐와 메모리 클리어 | ||
105 | + public void Clear() | ||
106 | + { | ||
107 | + // 스트림 버퍼의 남은 데이터를 긁어서 | ||
108 | + byte[] buffer = m_streamBuffer.GetBuffer(); | ||
109 | + // 해당 데이터를 정렬함 | ||
110 | + Array.Clear(buffer,0,buffer.Length); | ||
111 | + | ||
112 | + // 스트림 버퍼의 커서와 길이를 제로로 되돌리기 | ||
113 | + m_streamBuffer.Position = 0; | ||
114 | + m_streamBuffer.SetLength(0); | ||
115 | + } | ||
116 | + | ||
117 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +fileFormatVersion: 2 | ||
2 | +guid: 6f23052345bf649c485f9d14c8d027ae | ||
3 | +timeCreated: 1517148877 | ||
4 | +licenseType: Pro | ||
5 | +MonoImporter: | ||
6 | + externalObjects: {} | ||
7 | + serializedVersion: 2 | ||
8 | + defaultReferences: [] | ||
9 | + executionOrder: 0 | ||
10 | + icon: {instanceID: 0} | ||
11 | + userData: | ||
12 | + assetBundleName: | ||
13 | + assetBundleVariant: |
1 | +using System.Collections; | ||
2 | +using System.Collections.Generic; | ||
3 | +using UnityEngine; | ||
4 | +using System.Net; | ||
5 | +using System.Net.Sockets; | ||
6 | +using System.Threading; | ||
7 | + | ||
8 | +public class TransportTCP : MonoBehaviour | ||
9 | +{ | ||
10 | + | ||
11 | + // 소켓 액세스 포인트들 | ||
12 | + | ||
13 | + // 리스닝 소켓 | ||
14 | + private Socket m_listner = null; | ||
15 | + | ||
16 | + // 클라이언트의 접속을 받을 소켓 | ||
17 | + private Socket m_socket = null; | ||
18 | + | ||
19 | + private PacketQueue m_sendQueue; // 송신 버퍼 | ||
20 | + | ||
21 | + private PacketQueue m_recvQueue; // 수신 버퍼 | ||
22 | + | ||
23 | + public bool isServer { get; private set;} // 서버 플래그 | ||
24 | + | ||
25 | + public bool isConnected {get; private set;} // 접속 플래그 | ||
26 | + | ||
27 | + | ||
28 | + // 이벤트 관련 | ||
29 | + | ||
30 | + // 이벤트 통지 델리게이트 타입 정의 | ||
31 | + public delegate void EventHandler(NetEventState state); | ||
32 | + // 이벤트 핸들러 | ||
33 | + public event EventHandler onStateChanged; | ||
34 | + | ||
35 | + | ||
36 | + // 스레드 관련 멤버 변수 | ||
37 | + | ||
38 | + // 스레드 실행 프래그 | ||
39 | + protected bool m_threadLoop = false; | ||
40 | + protected Thread m_thread = null; | ||
41 | + private static int s_mtu = 1400; // 한번에 읽을 데이터 | ||
42 | + | ||
43 | + | ||
44 | + // 초기화 페이즈: 큐 생성 | ||
45 | + void Awake() | ||
46 | + { | ||
47 | + m_sendQueue = new PacketQueue(); | ||
48 | + m_recvQueue = new PacketQueue(); | ||
49 | + } | ||
50 | + | ||
51 | + // 서버로서 가동 (대기) 시작 | ||
52 | + public bool StartServer(int port, int connectionNum) | ||
53 | + { | ||
54 | + | ||
55 | + Debug.Log("Initiate Server!"); | ||
56 | + | ||
57 | + try | ||
58 | + { | ||
59 | + m_listner = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp); | ||
60 | + | ||
61 | + // 대응 대역폭 지정 | ||
62 | + m_listner.Bind(new IPEndPoint(IPAddress.Any, port)); | ||
63 | + | ||
64 | + m_listner.Listen(connectionNum); | ||
65 | + } | ||
66 | + catch | ||
67 | + { | ||
68 | + Debug.Log("Server Failed!"); | ||
69 | + | ||
70 | + return false; | ||
71 | + } | ||
72 | + | ||
73 | + isServer = true; | ||
74 | + | ||
75 | + bool success = LaunchThread(); | ||
76 | + | ||
77 | + return success; | ||
78 | + } | ||
79 | + | ||
80 | + // 서버로서 대기 종료 | ||
81 | + public void StopServer() | ||
82 | + { | ||
83 | + // 쓰레드 종료 | ||
84 | + m_threadLoop = false; | ||
85 | + | ||
86 | + if (m_thread != null) | ||
87 | + { | ||
88 | + m_thread.Join(); // https://msdn.microsoft.com/ko-kr/library/95hbf2ta(v=vs.110).aspx | ||
89 | + m_thread = null; | ||
90 | + } | ||
91 | + | ||
92 | + // 접속 종료 | ||
93 | + Disconnect(); | ||
94 | + | ||
95 | + if(m_listner != null) | ||
96 | + { | ||
97 | + m_listner.Close(); | ||
98 | + m_listner = null; | ||
99 | + } | ||
100 | + | ||
101 | + isServer = false; | ||
102 | + | ||
103 | + Debug.Log("Server Stopped"); | ||
104 | + } | ||
105 | + | ||
106 | + | ||
107 | + // 접속 | ||
108 | + public bool Connect(string address, int port) | ||
109 | + { | ||
110 | + Debug.Log("TransportTCP Connect Called"); | ||
111 | + | ||
112 | + // 이미 리스너 소켓이 선점되어 있다면 | ||
113 | + if (m_listner != null) { | ||
114 | + return false; | ||
115 | + } | ||
116 | + | ||
117 | + bool ret = false; | ||
118 | + | ||
119 | + try { | ||
120 | + m_socket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp); | ||
121 | + | ||
122 | + m_socket.NoDelay = true; // 소켓 지연시간 없음 | ||
123 | + m_socket.SendBufferSize = 0; | ||
124 | + m_socket.Connect(address,port); // 소켓 연결 시작 | ||
125 | + | ||
126 | + // 커넥션 스레드 시작 | ||
127 | + ret = LaunchThread(); | ||
128 | + } catch { | ||
129 | + // 실패했다면 소켓 파괴 | ||
130 | + m_socket = null; | ||
131 | + } | ||
132 | + | ||
133 | + if(ret == true) | ||
134 | + { | ||
135 | + isConnected = true; | ||
136 | + Debug.Log("Connection Success"); | ||
137 | + } | ||
138 | + else | ||
139 | + { | ||
140 | + isConnected = false; | ||
141 | + Debug.Log("Connection Fail"); | ||
142 | + } | ||
143 | + | ||
144 | + // 리스너가 존재한다면 통지 | ||
145 | + if(onStateChanged != null) { | ||
146 | + NetEventState state = new NetEventState(); | ||
147 | + state.type = NetEventType.Connect; | ||
148 | + state.result = (isConnected == true) ? NetEventResult.Success : NetEventResult.Failure; | ||
149 | + | ||
150 | + Debug.Log("Event Handler Called"); | ||
151 | + } | ||
152 | + | ||
153 | + return isConnected; | ||
154 | + } | ||
155 | + | ||
156 | + // 접속 종료 | ||
157 | + public void Disconnect() | ||
158 | + { | ||
159 | + isConnected = false; | ||
160 | + | ||
161 | + if (m_socket != null) | ||
162 | + { | ||
163 | + m_socket.Shutdown(SocketShutdown.Both); // 쌍방향 소켓 연결 내리기 | ||
164 | + m_socket.Close(); // 소켓 종료 | ||
165 | + m_socket = null; // 소켓 파괴 | ||
166 | + } | ||
167 | + | ||
168 | + // 리스터가 존재한다면 접속 종료를 공지 | ||
169 | + if (onStateChanged != null) | ||
170 | + { | ||
171 | + // 새로운 네트워크 상태 정보 생성후 | ||
172 | + NetEventState state = new NetEventState(); | ||
173 | + state.type = NetEventType.Disconnect; | ||
174 | + state.result = NetEventResult.Success; | ||
175 | + | ||
176 | + // 이벤트로 공지 | ||
177 | + onStateChanged(state); | ||
178 | + } | ||
179 | + } | ||
180 | + | ||
181 | + // 송신 처리 | ||
182 | + // 큐에 데이터를 넣어놓으면 알아서 쓰레드가 빼가서 보내놓을거라능 ㅇㅅㅇ | ||
183 | + public int Send(byte[] data, int size) | ||
184 | + { | ||
185 | + // 세이프티 체크 | ||
186 | + if(m_sendQueue == null) | ||
187 | + { | ||
188 | + return 0; | ||
189 | + } | ||
190 | + | ||
191 | + return m_sendQueue.Enqueue(data,size); | ||
192 | + } | ||
193 | + | ||
194 | + | ||
195 | + // 수신 처리 | ||
196 | + // 큐에 데이터를 넣어놓으면 알아서 쓰레드가 빼가서 보내놓을거라능 ㅇㅅㅇ | ||
197 | + public int Receive(ref byte[] data, int size) | ||
198 | + { | ||
199 | + // 세이프티 체크 | ||
200 | + if(m_recvQueue == null) | ||
201 | + { | ||
202 | + return 0; | ||
203 | + } | ||
204 | + | ||
205 | + return m_recvQueue.Dequeue(ref data,size); | ||
206 | + } | ||
207 | + | ||
208 | + // 스레드 실행 함수. | ||
209 | + // 목적: 돌려 놓으면 알아서 Send Queue 에 쌓아놓은 데이터는 보내주고 | ||
210 | + // 온 데이터는 Recv Queue 에 쌓아놓아줌 | ||
211 | + bool LaunchThread() | ||
212 | + { | ||
213 | + try { | ||
214 | + // Dispatch용 스레드 시작. | ||
215 | + m_threadLoop = true; | ||
216 | + m_thread = new Thread(new ThreadStart(Dispatch)); | ||
217 | + m_thread.Start(); | ||
218 | + } | ||
219 | + catch { | ||
220 | + Debug.Log("Cannot launch thread."); | ||
221 | + return false; | ||
222 | + } | ||
223 | + | ||
224 | + return true; | ||
225 | + } | ||
226 | + | ||
227 | + | ||
228 | + // 스레드를 통해 송수신을 처리해주는 실제 패킷큐 처리부 | ||
229 | + public void Dispatch() | ||
230 | + { | ||
231 | + Debug.Log("Distpach thread started."); | ||
232 | + | ||
233 | + // 스레드 루프가 계속 돌아가는 동안 | ||
234 | + while(m_threadLoop) | ||
235 | + { | ||
236 | + //클라이언트의 접속을 기다림 | ||
237 | + | ||
238 | + AcceptClient(); | ||
239 | + | ||
240 | + | ||
241 | + if(m_socket != null && isConnected == true) | ||
242 | + { | ||
243 | + // 송신 | ||
244 | + DispatchSend(); | ||
245 | + | ||
246 | + // 수신 | ||
247 | + DispatchReceive(); | ||
248 | + } | ||
249 | + | ||
250 | + // 실행 간격 5밀리 세컨드 | ||
251 | + Thread.Sleep(5); | ||
252 | + } | ||
253 | + | ||
254 | + Debug.Log("Dispatch thread ended"); | ||
255 | + } | ||
256 | + | ||
257 | + void AcceptClient() | ||
258 | + { | ||
259 | + // 리스너가 클라이언트를 감지하고 준비됬다면 | ||
260 | + if(m_listner != null && m_listner.Poll(0, SelectMode.SelectRead)) | ||
261 | + { | ||
262 | + // 클라이언트로부터 통신 소켓 지정 | ||
263 | + m_socket = m_listner.Accept(); | ||
264 | + | ||
265 | + isConnected = true; | ||
266 | + Debug.Log("Connected from client"); | ||
267 | + } | ||
268 | + | ||
269 | + } | ||
270 | + | ||
271 | + void DispatchSend() | ||
272 | + { | ||
273 | + try{ | ||
274 | + // 데이터를 보낼 준비가 되있다면 | ||
275 | + if(m_socket.Poll(0,SelectMode.SelectWrite)) | ||
276 | + { | ||
277 | + // 바이트 배열 생성 | ||
278 | + byte[] buffer = new byte[s_mtu]; | ||
279 | + | ||
280 | + // 전송 대기큐로부터 데이터를 빼내어 가져옴 | ||
281 | + int sendSize = m_sendQueue.Dequeue(ref buffer, buffer.Length); | ||
282 | + | ||
283 | + // 보낼 데이터가 있는 동안 계속 송신-데이터 빼오기 반복 | ||
284 | + while(sendSize > 0) { | ||
285 | + m_socket.Send(buffer, sendSize, SocketFlags.None); | ||
286 | + sendSize = m_sendQueue.Dequeue(ref buffer, buffer.Length); | ||
287 | + } | ||
288 | + } | ||
289 | + } catch { | ||
290 | + return; | ||
291 | + } | ||
292 | + } | ||
293 | + | ||
294 | + void DispatchReceive() | ||
295 | + { | ||
296 | + try{ | ||
297 | + // 읽을 데이터가 있으면 | ||
298 | + while(m_socket.Poll(0,SelectMode.SelectRead)) { | ||
299 | + byte[] buffer = new byte[s_mtu]; | ||
300 | + | ||
301 | + int recvSize = m_socket.Receive(buffer,buffer.Length,SocketFlags.None); | ||
302 | + | ||
303 | + if(recvSize == 0) | ||
304 | + { | ||
305 | + // 더이상 가져올 데이터가 없다면 | ||
306 | + | ||
307 | + Debug.Log("Diconnect recv from client."); | ||
308 | + Disconnect(); | ||
309 | + } | ||
310 | + else if (recvSize > 0) { // 데이터를 가져왔다면 리시브 큐에 적재해둠 | ||
311 | + m_recvQueue.Enqueue(buffer,recvSize); | ||
312 | + | ||
313 | + } | ||
314 | + } | ||
315 | + } | ||
316 | + catch { | ||
317 | + return; | ||
318 | + } | ||
319 | + } | ||
320 | +} |
1 | +fileFormatVersion: 2 | ||
2 | +guid: cd5fc2b6c1dde473792533471913965f | ||
3 | +timeCreated: 1517148595 | ||
4 | +licenseType: Pro | ||
5 | +MonoImporter: | ||
6 | + externalObjects: {} | ||
7 | + serializedVersion: 2 | ||
8 | + defaultReferences: [] | ||
9 | + executionOrder: 0 | ||
10 | + icon: {instanceID: 0} | ||
11 | + userData: | ||
12 | + assetBundleName: | ||
13 | + assetBundleVariant: |
1 | +using System.Collections; | ||
2 | +using System.Collections.Generic; | ||
3 | +using UnityEngine; | ||
4 | +using System.Net; | ||
5 | +using System.Net.Sockets; | ||
6 | +using System.Threading; | ||
7 | + | ||
8 | +public class TransportUDP : MonoBehaviour | ||
9 | +{ | ||
10 | + | ||
11 | + // 소켓 액세스 포인트들 | ||
12 | + | ||
13 | + // 클라이언트의 접속을 받을 소켓 | ||
14 | + private Socket m_socket = null; | ||
15 | + | ||
16 | + private PacketQueue m_sendQueue; // 송신 버퍼 | ||
17 | + | ||
18 | + private PacketQueue m_recvQueue; // 수신 버퍼 | ||
19 | + | ||
20 | + public bool isServer { get; private set;} // 서버 플래그 | ||
21 | + | ||
22 | + public bool isConnected {get; private set;} // 접속 플래그 | ||
23 | + | ||
24 | + | ||
25 | + // 이벤트 관련 | ||
26 | + | ||
27 | + // 이벤트 통지 델리게이트 타입 정의 | ||
28 | + public delegate void EventHandler(NetEventState state); | ||
29 | + // 이벤트 핸들러 | ||
30 | + public event EventHandler onStateChanged; | ||
31 | + | ||
32 | + | ||
33 | + // 스레드 관련 멤버 변수 | ||
34 | + | ||
35 | + // 스레드 실행 프래그 | ||
36 | + protected bool m_threadLoop = false; | ||
37 | + protected Thread m_thread = null; | ||
38 | + private static int s_mtu = 1400; // 한번에 읽을 데이터 | ||
39 | + | ||
40 | + | ||
41 | + // 초기화 페이즈: 큐 생성 | ||
42 | + void Awake() | ||
43 | + { | ||
44 | + m_sendQueue = new PacketQueue(); | ||
45 | + m_recvQueue = new PacketQueue(); | ||
46 | + } | ||
47 | + | ||
48 | + // 서버로서 가동 (대기) 시작 | ||
49 | + public bool StartServer(int port, int connectionNum) | ||
50 | + { | ||
51 | + | ||
52 | + Debug.Log("Initiate Server!"); | ||
53 | + | ||
54 | + try | ||
55 | + { | ||
56 | + // 소켓 생성후 | ||
57 | + m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Udp); | ||
58 | + | ||
59 | + // 대응 대역폭 지정 | ||
60 | + m_socket.Bind(new IPEndPoint(IPAddress.Any, port)); | ||
61 | + } | ||
62 | + catch | ||
63 | + { | ||
64 | + Debug.Log("Server Failed!"); | ||
65 | + | ||
66 | + return false; | ||
67 | + } | ||
68 | + | ||
69 | + isServer = true; | ||
70 | + | ||
71 | + bool success = LaunchThread(); | ||
72 | + | ||
73 | + return success; | ||
74 | + } | ||
75 | + | ||
76 | + // 서버로서 대기 종료 | ||
77 | + public void StopServer() | ||
78 | + { | ||
79 | + // 쓰레드 종료 | ||
80 | + m_threadLoop = false; | ||
81 | + | ||
82 | + if (m_thread != null) | ||
83 | + { | ||
84 | + m_thread.Join(); | ||
85 | + m_thread = null; | ||
86 | + } | ||
87 | + | ||
88 | + // 접속 종료 | ||
89 | + Disconnect(); | ||
90 | + | ||
91 | + isServer = false; | ||
92 | + | ||
93 | + Debug.Log("Server Stopped"); | ||
94 | + } | ||
95 | + | ||
96 | + public bool Connect(string address, int port) | ||
97 | + { | ||
98 | + Debug.Log("TransportUDP Connect Called"); | ||
99 | + | ||
100 | + // 이미 통신 소켓이 선점되어 있다면 | ||
101 | + if (m_socket != null) { | ||
102 | + return false; | ||
103 | + } | ||
104 | + | ||
105 | + bool ret = false; | ||
106 | + | ||
107 | + try { | ||
108 | + m_socket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Udp); | ||
109 | + | ||
110 | + m_socket.NoDelay = true; // 소켓 지연시간 없음 | ||
111 | + m_socket.Connect(address,port); // 소켓 연결 시작 | ||
112 | + | ||
113 | + // 커넥션 스레드 시작 | ||
114 | + ret = LaunchThread(); | ||
115 | + } catch { | ||
116 | + // 실패했다면 소켓 파괴 | ||
117 | + m_socket = null; | ||
118 | + } | ||
119 | + | ||
120 | + if(ret == true) | ||
121 | + { | ||
122 | + isConnected = true; | ||
123 | + Debug.Log("Connection Success"); | ||
124 | + } | ||
125 | + else | ||
126 | + { | ||
127 | + isConnected = false; | ||
128 | + Debug.Log("Connection Fail"); | ||
129 | + } | ||
130 | + | ||
131 | + // 리스너가 존재한다면 통지 | ||
132 | + if(onStateChanged != null) { | ||
133 | + NetEventState state = new NetEventState(); | ||
134 | + state.type = NetEventType.Connect; | ||
135 | + state.result = (isConnected == true) ? NetEventResult.Success : NetEventResult.Failure; | ||
136 | + | ||
137 | + Debug.Log("Event Handler Called"); | ||
138 | + } | ||
139 | + | ||
140 | + return isConnected; | ||
141 | + } | ||
142 | + | ||
143 | + // 접속 종료 | ||
144 | + public void Disconnect() | ||
145 | + { | ||
146 | + isConnected = false; | ||
147 | + | ||
148 | + if (m_socket != null) | ||
149 | + { | ||
150 | + m_socket.Shutdown(SocketShutdown.Both); // 쌍방향 소켓 연결 내리기 | ||
151 | + m_socket.Close(); // 소켓 종료 | ||
152 | + m_socket = null; // 소켓 파괴 | ||
153 | + } | ||
154 | + | ||
155 | + // 리스터가 존재한다면 접속 종료를 공지 | ||
156 | + if (onStateChanged != null) | ||
157 | + { | ||
158 | + // 새로운 네트워크 상태 정보 생성후 | ||
159 | + NetEventState state = new NetEventState(); | ||
160 | + state.type = NetEventType.Disconnect; | ||
161 | + state.result = NetEventResult.Success; | ||
162 | + | ||
163 | + // 이벤트로 공지 | ||
164 | + onStateChanged(state); | ||
165 | + } | ||
166 | + } | ||
167 | + | ||
168 | + // 송신 처리 | ||
169 | + // 큐에 데이터를 넣어놓으면 알아서 쓰레드가 빼가서 보내놓을거라능 ㅇㅅㅇ | ||
170 | + public int Send(byte[] data, int size) | ||
171 | + { | ||
172 | + // 세이프티 체크 | ||
173 | + if(m_sendQueue == null) | ||
174 | + { | ||
175 | + return 0; | ||
176 | + } | ||
177 | + | ||
178 | + return m_sendQueue.Enqueue(data,size); | ||
179 | + } | ||
180 | + | ||
181 | + | ||
182 | + // 수신 처리 | ||
183 | + // 큐에 데이터를 넣어놓으면 알아서 쓰레드가 빼가서 보내놓을거라능 ㅇㅅㅇ | ||
184 | + public int Receive(ref byte[] data, int size) | ||
185 | + { | ||
186 | + // 세이프티 체크 | ||
187 | + if(m_recvQueue == null) | ||
188 | + { | ||
189 | + return 0; | ||
190 | + } | ||
191 | + | ||
192 | + return m_recvQueue.Dequeue(ref data,size); | ||
193 | + } | ||
194 | + | ||
195 | + // 스레드 실행 함수. | ||
196 | + // 목적: 돌려 놓으면 알아서 Send Queue 에 쌓아놓은 데이터는 보내주고 | ||
197 | + // 온 데이터는 Recv Queue 에 쌓아놓아줌 | ||
198 | + bool LaunchThread() | ||
199 | + { | ||
200 | + try { | ||
201 | + // Dispatch용 스레드 시작. | ||
202 | + m_threadLoop = true; | ||
203 | + m_thread = new Thread(new ThreadStart(Dispatch)); | ||
204 | + m_thread.Start(); | ||
205 | + } | ||
206 | + catch { | ||
207 | + Debug.Log("Cannot launch thread."); | ||
208 | + return false; | ||
209 | + } | ||
210 | + | ||
211 | + return true; | ||
212 | + } | ||
213 | + | ||
214 | + | ||
215 | + // 스레드를 통해 송수신을 처리해주는 실제 패킷큐 처리부 | ||
216 | + public void Dispatch() | ||
217 | + { | ||
218 | + Debug.Log("Distpach thread started."); | ||
219 | + | ||
220 | + // 스레드 루프가 계속 돌아가는 동안 | ||
221 | + while(m_threadLoop) | ||
222 | + { | ||
223 | + if(m_socket != null && isConnected == true) | ||
224 | + { | ||
225 | + // 송신 | ||
226 | + DispatchSend(); | ||
227 | + | ||
228 | + // 수신 | ||
229 | + DispatchReceive(); | ||
230 | + } | ||
231 | + | ||
232 | + // 실행 간격 5밀리 세컨드 | ||
233 | + Thread.Sleep(5); | ||
234 | + } | ||
235 | + | ||
236 | + Debug.Log("Dispatch thread ended"); | ||
237 | + } | ||
238 | + | ||
239 | + void DispatchSend() | ||
240 | + { | ||
241 | + try{ | ||
242 | + // 데이터를 보낼 준비가 되있다면 | ||
243 | + if(m_socket.Poll(0,SelectMode.SelectWrite)) | ||
244 | + { | ||
245 | + // 바이트 배열 생성 | ||
246 | + byte[] buffer = new byte[s_mtu]; | ||
247 | + | ||
248 | + // 전송 대기큐로부터 데이터를 빼내어 가져옴 | ||
249 | + int sendSize = m_sendQueue.Dequeue(ref buffer, buffer.Length); | ||
250 | + | ||
251 | + // 보낼 데이터가 있는 동안 계속 송신-데이터 빼오기 반복 | ||
252 | + while(sendSize > 0) { | ||
253 | + m_socket.Send(buffer, sendSize, SocketFlags.None); | ||
254 | + sendSize = m_sendQueue.Dequeue(ref buffer, buffer.Length); | ||
255 | + } | ||
256 | + } | ||
257 | + } catch { | ||
258 | + return; | ||
259 | + } | ||
260 | + } | ||
261 | + | ||
262 | + void DispatchReceive() | ||
263 | + { | ||
264 | + try{ | ||
265 | + // 읽을 데이터가 있으면 | ||
266 | + while(m_socket.Poll(0,SelectMode.SelectRead)) { | ||
267 | + byte[] buffer = new byte[s_mtu]; | ||
268 | + | ||
269 | + int recvSize = m_socket.Receive(buffer,buffer.Length,SocketFlags.None); | ||
270 | + | ||
271 | + if(recvSize == 0) | ||
272 | + { | ||
273 | + // 더이상 가져올 데이터가 없다면 | ||
274 | + | ||
275 | + Debug.Log("Diconnect recv from client."); | ||
276 | + Disconnect(); | ||
277 | + } | ||
278 | + else if (recvSize > 0) { // 데이터를 가져왔다면 리시브 큐에 적재해둠 | ||
279 | + m_recvQueue.Enqueue(buffer,recvSize); | ||
280 | + | ||
281 | + } | ||
282 | + } | ||
283 | + } | ||
284 | + catch { | ||
285 | + return; | ||
286 | + } | ||
287 | + } | ||
288 | +} |
1 | +fileFormatVersion: 2 | ||
2 | +guid: a9312813559bd41e9b935e2418917ad0 | ||
3 | +timeCreated: 1517148687 | ||
4 | +licenseType: Pro | ||
5 | +MonoImporter: | ||
6 | + externalObjects: {} | ||
7 | + serializedVersion: 2 | ||
8 | + defaultReferences: [] | ||
9 | + executionOrder: 0 | ||
10 | + icon: {instanceID: 0} | ||
11 | + userData: | ||
12 | + assetBundleName: | ||
13 | + assetBundleVariant: |
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!11 &1 | ||
4 | +AudioManager: | ||
5 | + m_ObjectHideFlags: 0 | ||
6 | + m_Volume: 1 | ||
7 | + Rolloff Scale: 1 | ||
8 | + Doppler Factor: 1 | ||
9 | + Default Speaker Mode: 2 | ||
10 | + m_SampleRate: 0 | ||
11 | + m_DSPBufferSize: 0 | ||
12 | + m_VirtualVoiceCount: 512 | ||
13 | + m_RealVoiceCount: 32 | ||
14 | + m_SpatializerPlugin: | ||
15 | + m_AmbisonicDecoderPlugin: | ||
16 | + m_DisableAudio: 0 | ||
17 | + m_VirtualizeEffects: 1 |
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!55 &1 | ||
4 | +PhysicsManager: | ||
5 | + m_ObjectHideFlags: 0 | ||
6 | + serializedVersion: 7 | ||
7 | + m_Gravity: {x: 0, y: -9.81, z: 0} | ||
8 | + m_DefaultMaterial: {fileID: 0} | ||
9 | + m_BounceThreshold: 2 | ||
10 | + m_SleepThreshold: 0.005 | ||
11 | + m_DefaultContactOffset: 0.01 | ||
12 | + m_DefaultSolverIterations: 6 | ||
13 | + m_DefaultSolverVelocityIterations: 1 | ||
14 | + m_QueriesHitBackfaces: 0 | ||
15 | + m_QueriesHitTriggers: 1 | ||
16 | + m_EnableAdaptiveForce: 0 | ||
17 | + m_ClothInterCollisionDistance: 0 | ||
18 | + m_ClothInterCollisionStiffness: 0 | ||
19 | + m_ContactsGeneration: 1 | ||
20 | + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff | ||
21 | + m_AutoSimulation: 1 | ||
22 | + m_AutoSyncTransforms: 1 | ||
23 | + m_ClothInterCollisionSettingsToggle: 0 | ||
24 | + m_ContactPairsMode: 0 | ||
25 | + m_BroadphaseType: 0 | ||
26 | + m_WorldBounds: | ||
27 | + m_Center: {x: 0, y: 0, z: 0} | ||
28 | + m_Extent: {x: 250, y: 250, z: 250} | ||
29 | + m_WorldSubdivisions: 8 |
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!159 &1 | ||
4 | +EditorSettings: | ||
5 | + m_ObjectHideFlags: 0 | ||
6 | + serializedVersion: 7 | ||
7 | + m_ExternalVersionControlSupport: Hidden Meta Files | ||
8 | + m_SerializationMode: 2 | ||
9 | + m_LineEndingsForNewScripts: 1 | ||
10 | + m_DefaultBehaviorMode: 0 | ||
11 | + m_SpritePackerMode: 0 | ||
12 | + m_SpritePackerPaddingPower: 1 | ||
13 | + m_EtcTextureCompressorBehavior: 1 | ||
14 | + m_EtcTextureFastCompressor: 1 | ||
15 | + m_EtcTextureNormalCompressor: 2 | ||
16 | + m_EtcTextureBestCompressor: 4 | ||
17 | + m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp | ||
18 | + m_ProjectGenerationRootNamespace: | ||
19 | + m_UserGeneratedProjectSuffix: | ||
20 | + m_CollabEditorSettings: | ||
21 | + inProgressEnabled: 1 |
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!30 &1 | ||
4 | +GraphicsSettings: | ||
5 | + m_ObjectHideFlags: 0 | ||
6 | + serializedVersion: 12 | ||
7 | + m_Deferred: | ||
8 | + m_Mode: 1 | ||
9 | + m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} | ||
10 | + m_DeferredReflections: | ||
11 | + m_Mode: 1 | ||
12 | + m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} | ||
13 | + m_ScreenSpaceShadows: | ||
14 | + m_Mode: 1 | ||
15 | + m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} | ||
16 | + m_LegacyDeferred: | ||
17 | + m_Mode: 1 | ||
18 | + m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} | ||
19 | + m_DepthNormals: | ||
20 | + m_Mode: 1 | ||
21 | + m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} | ||
22 | + m_MotionVectors: | ||
23 | + m_Mode: 1 | ||
24 | + m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} | ||
25 | + m_LightHalo: | ||
26 | + m_Mode: 1 | ||
27 | + m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} | ||
28 | + m_LensFlare: | ||
29 | + m_Mode: 1 | ||
30 | + m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} | ||
31 | + m_AlwaysIncludedShaders: | ||
32 | + - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} | ||
33 | + - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} | ||
34 | + - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} | ||
35 | + - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} | ||
36 | + - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} | ||
37 | + - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} | ||
38 | + - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} | ||
39 | + - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} | ||
40 | + - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} | ||
41 | + m_PreloadedShaders: [] | ||
42 | + m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, | ||
43 | + type: 0} | ||
44 | + m_CustomRenderPipeline: {fileID: 0} | ||
45 | + m_TransparencySortMode: 0 | ||
46 | + m_TransparencySortAxis: {x: 0, y: 0, z: 1} | ||
47 | + m_DefaultRenderingPath: 1 | ||
48 | + m_DefaultMobileRenderingPath: 1 | ||
49 | + m_TierSettings: [] | ||
50 | + m_LightmapStripping: 0 | ||
51 | + m_FogStripping: 0 | ||
52 | + m_InstancingStripping: 0 | ||
53 | + m_LightmapKeepPlain: 1 | ||
54 | + m_LightmapKeepDirCombined: 1 | ||
55 | + m_LightmapKeepDynamicPlain: 1 | ||
56 | + m_LightmapKeepDynamicDirCombined: 1 | ||
57 | + m_LightmapKeepShadowMask: 1 | ||
58 | + m_LightmapKeepSubtractive: 1 | ||
59 | + m_FogKeepLinear: 1 | ||
60 | + m_FogKeepExp: 1 | ||
61 | + m_FogKeepExp2: 1 | ||
62 | + m_AlbedoSwatchInfos: [] | ||
63 | + m_LightsUseLinearIntensity: 0 | ||
64 | + m_LightsUseColorTemperature: 0 |
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!13 &1 | ||
4 | +InputManager: | ||
5 | + m_ObjectHideFlags: 0 | ||
6 | + serializedVersion: 2 | ||
7 | + m_Axes: | ||
8 | + - serializedVersion: 3 | ||
9 | + m_Name: Horizontal | ||
10 | + descriptiveName: | ||
11 | + descriptiveNegativeName: | ||
12 | + negativeButton: left | ||
13 | + positiveButton: right | ||
14 | + altNegativeButton: a | ||
15 | + altPositiveButton: d | ||
16 | + gravity: 3 | ||
17 | + dead: 0.001 | ||
18 | + sensitivity: 3 | ||
19 | + snap: 1 | ||
20 | + invert: 0 | ||
21 | + type: 0 | ||
22 | + axis: 0 | ||
23 | + joyNum: 0 | ||
24 | + - serializedVersion: 3 | ||
25 | + m_Name: Vertical | ||
26 | + descriptiveName: | ||
27 | + descriptiveNegativeName: | ||
28 | + negativeButton: down | ||
29 | + positiveButton: up | ||
30 | + altNegativeButton: s | ||
31 | + altPositiveButton: w | ||
32 | + gravity: 3 | ||
33 | + dead: 0.001 | ||
34 | + sensitivity: 3 | ||
35 | + snap: 1 | ||
36 | + invert: 0 | ||
37 | + type: 0 | ||
38 | + axis: 0 | ||
39 | + joyNum: 0 | ||
40 | + - serializedVersion: 3 | ||
41 | + m_Name: Fire1 | ||
42 | + descriptiveName: | ||
43 | + descriptiveNegativeName: | ||
44 | + negativeButton: | ||
45 | + positiveButton: left ctrl | ||
46 | + altNegativeButton: | ||
47 | + altPositiveButton: mouse 0 | ||
48 | + gravity: 1000 | ||
49 | + dead: 0.001 | ||
50 | + sensitivity: 1000 | ||
51 | + snap: 0 | ||
52 | + invert: 0 | ||
53 | + type: 0 | ||
54 | + axis: 0 | ||
55 | + joyNum: 0 | ||
56 | + - serializedVersion: 3 | ||
57 | + m_Name: Fire2 | ||
58 | + descriptiveName: | ||
59 | + descriptiveNegativeName: | ||
60 | + negativeButton: | ||
61 | + positiveButton: left alt | ||
62 | + altNegativeButton: | ||
63 | + altPositiveButton: mouse 1 | ||
64 | + gravity: 1000 | ||
65 | + dead: 0.001 | ||
66 | + sensitivity: 1000 | ||
67 | + snap: 0 | ||
68 | + invert: 0 | ||
69 | + type: 0 | ||
70 | + axis: 0 | ||
71 | + joyNum: 0 | ||
72 | + - serializedVersion: 3 | ||
73 | + m_Name: Fire3 | ||
74 | + descriptiveName: | ||
75 | + descriptiveNegativeName: | ||
76 | + negativeButton: | ||
77 | + positiveButton: left shift | ||
78 | + altNegativeButton: | ||
79 | + altPositiveButton: mouse 2 | ||
80 | + gravity: 1000 | ||
81 | + dead: 0.001 | ||
82 | + sensitivity: 1000 | ||
83 | + snap: 0 | ||
84 | + invert: 0 | ||
85 | + type: 0 | ||
86 | + axis: 0 | ||
87 | + joyNum: 0 | ||
88 | + - serializedVersion: 3 | ||
89 | + m_Name: Jump | ||
90 | + descriptiveName: | ||
91 | + descriptiveNegativeName: | ||
92 | + negativeButton: | ||
93 | + positiveButton: space | ||
94 | + altNegativeButton: | ||
95 | + altPositiveButton: | ||
96 | + gravity: 1000 | ||
97 | + dead: 0.001 | ||
98 | + sensitivity: 1000 | ||
99 | + snap: 0 | ||
100 | + invert: 0 | ||
101 | + type: 0 | ||
102 | + axis: 0 | ||
103 | + joyNum: 0 | ||
104 | + - serializedVersion: 3 | ||
105 | + m_Name: Mouse X | ||
106 | + descriptiveName: | ||
107 | + descriptiveNegativeName: | ||
108 | + negativeButton: | ||
109 | + positiveButton: | ||
110 | + altNegativeButton: | ||
111 | + altPositiveButton: | ||
112 | + gravity: 0 | ||
113 | + dead: 0 | ||
114 | + sensitivity: 0.1 | ||
115 | + snap: 0 | ||
116 | + invert: 0 | ||
117 | + type: 1 | ||
118 | + axis: 0 | ||
119 | + joyNum: 0 | ||
120 | + - serializedVersion: 3 | ||
121 | + m_Name: Mouse Y | ||
122 | + descriptiveName: | ||
123 | + descriptiveNegativeName: | ||
124 | + negativeButton: | ||
125 | + positiveButton: | ||
126 | + altNegativeButton: | ||
127 | + altPositiveButton: | ||
128 | + gravity: 0 | ||
129 | + dead: 0 | ||
130 | + sensitivity: 0.1 | ||
131 | + snap: 0 | ||
132 | + invert: 0 | ||
133 | + type: 1 | ||
134 | + axis: 1 | ||
135 | + joyNum: 0 | ||
136 | + - serializedVersion: 3 | ||
137 | + m_Name: Mouse ScrollWheel | ||
138 | + descriptiveName: | ||
139 | + descriptiveNegativeName: | ||
140 | + negativeButton: | ||
141 | + positiveButton: | ||
142 | + altNegativeButton: | ||
143 | + altPositiveButton: | ||
144 | + gravity: 0 | ||
145 | + dead: 0 | ||
146 | + sensitivity: 0.1 | ||
147 | + snap: 0 | ||
148 | + invert: 0 | ||
149 | + type: 1 | ||
150 | + axis: 2 | ||
151 | + joyNum: 0 | ||
152 | + - serializedVersion: 3 | ||
153 | + m_Name: Horizontal | ||
154 | + descriptiveName: | ||
155 | + descriptiveNegativeName: | ||
156 | + negativeButton: | ||
157 | + positiveButton: | ||
158 | + altNegativeButton: | ||
159 | + altPositiveButton: | ||
160 | + gravity: 0 | ||
161 | + dead: 0.19 | ||
162 | + sensitivity: 1 | ||
163 | + snap: 0 | ||
164 | + invert: 0 | ||
165 | + type: 2 | ||
166 | + axis: 0 | ||
167 | + joyNum: 0 | ||
168 | + - serializedVersion: 3 | ||
169 | + m_Name: Vertical | ||
170 | + descriptiveName: | ||
171 | + descriptiveNegativeName: | ||
172 | + negativeButton: | ||
173 | + positiveButton: | ||
174 | + altNegativeButton: | ||
175 | + altPositiveButton: | ||
176 | + gravity: 0 | ||
177 | + dead: 0.19 | ||
178 | + sensitivity: 1 | ||
179 | + snap: 0 | ||
180 | + invert: 1 | ||
181 | + type: 2 | ||
182 | + axis: 1 | ||
183 | + joyNum: 0 | ||
184 | + - serializedVersion: 3 | ||
185 | + m_Name: Fire1 | ||
186 | + descriptiveName: | ||
187 | + descriptiveNegativeName: | ||
188 | + negativeButton: | ||
189 | + positiveButton: joystick button 0 | ||
190 | + altNegativeButton: | ||
191 | + altPositiveButton: | ||
192 | + gravity: 1000 | ||
193 | + dead: 0.001 | ||
194 | + sensitivity: 1000 | ||
195 | + snap: 0 | ||
196 | + invert: 0 | ||
197 | + type: 0 | ||
198 | + axis: 0 | ||
199 | + joyNum: 0 | ||
200 | + - serializedVersion: 3 | ||
201 | + m_Name: Fire2 | ||
202 | + descriptiveName: | ||
203 | + descriptiveNegativeName: | ||
204 | + negativeButton: | ||
205 | + positiveButton: joystick button 1 | ||
206 | + altNegativeButton: | ||
207 | + altPositiveButton: | ||
208 | + gravity: 1000 | ||
209 | + dead: 0.001 | ||
210 | + sensitivity: 1000 | ||
211 | + snap: 0 | ||
212 | + invert: 0 | ||
213 | + type: 0 | ||
214 | + axis: 0 | ||
215 | + joyNum: 0 | ||
216 | + - serializedVersion: 3 | ||
217 | + m_Name: Fire3 | ||
218 | + descriptiveName: | ||
219 | + descriptiveNegativeName: | ||
220 | + negativeButton: | ||
221 | + positiveButton: joystick button 2 | ||
222 | + altNegativeButton: | ||
223 | + altPositiveButton: | ||
224 | + gravity: 1000 | ||
225 | + dead: 0.001 | ||
226 | + sensitivity: 1000 | ||
227 | + snap: 0 | ||
228 | + invert: 0 | ||
229 | + type: 0 | ||
230 | + axis: 0 | ||
231 | + joyNum: 0 | ||
232 | + - serializedVersion: 3 | ||
233 | + m_Name: Jump | ||
234 | + descriptiveName: | ||
235 | + descriptiveNegativeName: | ||
236 | + negativeButton: | ||
237 | + positiveButton: joystick button 3 | ||
238 | + altNegativeButton: | ||
239 | + altPositiveButton: | ||
240 | + gravity: 1000 | ||
241 | + dead: 0.001 | ||
242 | + sensitivity: 1000 | ||
243 | + snap: 0 | ||
244 | + invert: 0 | ||
245 | + type: 0 | ||
246 | + axis: 0 | ||
247 | + joyNum: 0 | ||
248 | + - serializedVersion: 3 | ||
249 | + m_Name: Submit | ||
250 | + descriptiveName: | ||
251 | + descriptiveNegativeName: | ||
252 | + negativeButton: | ||
253 | + positiveButton: return | ||
254 | + altNegativeButton: | ||
255 | + altPositiveButton: joystick button 0 | ||
256 | + gravity: 1000 | ||
257 | + dead: 0.001 | ||
258 | + sensitivity: 1000 | ||
259 | + snap: 0 | ||
260 | + invert: 0 | ||
261 | + type: 0 | ||
262 | + axis: 0 | ||
263 | + joyNum: 0 | ||
264 | + - serializedVersion: 3 | ||
265 | + m_Name: Submit | ||
266 | + descriptiveName: | ||
267 | + descriptiveNegativeName: | ||
268 | + negativeButton: | ||
269 | + positiveButton: enter | ||
270 | + altNegativeButton: | ||
271 | + altPositiveButton: space | ||
272 | + gravity: 1000 | ||
273 | + dead: 0.001 | ||
274 | + sensitivity: 1000 | ||
275 | + snap: 0 | ||
276 | + invert: 0 | ||
277 | + type: 0 | ||
278 | + axis: 0 | ||
279 | + joyNum: 0 | ||
280 | + - serializedVersion: 3 | ||
281 | + m_Name: Cancel | ||
282 | + descriptiveName: | ||
283 | + descriptiveNegativeName: | ||
284 | + negativeButton: | ||
285 | + positiveButton: escape | ||
286 | + altNegativeButton: | ||
287 | + altPositiveButton: joystick button 1 | ||
288 | + gravity: 1000 | ||
289 | + dead: 0.001 | ||
290 | + sensitivity: 1000 | ||
291 | + snap: 0 | ||
292 | + invert: 0 | ||
293 | + type: 0 | ||
294 | + axis: 0 | ||
295 | + joyNum: 0 |
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!126 &1 | ||
4 | +NavMeshProjectSettings: | ||
5 | + m_ObjectHideFlags: 0 | ||
6 | + serializedVersion: 2 | ||
7 | + areas: | ||
8 | + - name: Walkable | ||
9 | + cost: 1 | ||
10 | + - name: Not Walkable | ||
11 | + cost: 1 | ||
12 | + - name: Jump | ||
13 | + cost: 2 | ||
14 | + - name: | ||
15 | + cost: 1 | ||
16 | + - name: | ||
17 | + cost: 1 | ||
18 | + - name: | ||
19 | + cost: 1 | ||
20 | + - name: | ||
21 | + cost: 1 | ||
22 | + - name: | ||
23 | + cost: 1 | ||
24 | + - name: | ||
25 | + cost: 1 | ||
26 | + - name: | ||
27 | + cost: 1 | ||
28 | + - name: | ||
29 | + cost: 1 | ||
30 | + - name: | ||
31 | + cost: 1 | ||
32 | + - name: | ||
33 | + cost: 1 | ||
34 | + - name: | ||
35 | + cost: 1 | ||
36 | + - name: | ||
37 | + cost: 1 | ||
38 | + - name: | ||
39 | + cost: 1 | ||
40 | + - name: | ||
41 | + cost: 1 | ||
42 | + - name: | ||
43 | + cost: 1 | ||
44 | + - name: | ||
45 | + cost: 1 | ||
46 | + - name: | ||
47 | + cost: 1 | ||
48 | + - name: | ||
49 | + cost: 1 | ||
50 | + - name: | ||
51 | + cost: 1 | ||
52 | + - name: | ||
53 | + cost: 1 | ||
54 | + - name: | ||
55 | + cost: 1 | ||
56 | + - name: | ||
57 | + cost: 1 | ||
58 | + - name: | ||
59 | + cost: 1 | ||
60 | + - name: | ||
61 | + cost: 1 | ||
62 | + - name: | ||
63 | + cost: 1 | ||
64 | + - name: | ||
65 | + cost: 1 | ||
66 | + - name: | ||
67 | + cost: 1 | ||
68 | + - name: | ||
69 | + cost: 1 | ||
70 | + - name: | ||
71 | + cost: 1 | ||
72 | + m_LastAgentTypeID: -887442657 | ||
73 | + m_Settings: | ||
74 | + - serializedVersion: 2 | ||
75 | + agentTypeID: 0 | ||
76 | + agentRadius: 0.5 | ||
77 | + agentHeight: 2 | ||
78 | + agentSlope: 45 | ||
79 | + agentClimb: 0.75 | ||
80 | + ledgeDropHeight: 0 | ||
81 | + maxJumpAcrossDistance: 0 | ||
82 | + minRegionArea: 2 | ||
83 | + manualCellSize: 0 | ||
84 | + cellSize: 0.16666667 | ||
85 | + manualTileSize: 0 | ||
86 | + tileSize: 256 | ||
87 | + accuratePlacement: 0 | ||
88 | + debug: | ||
89 | + m_Flags: 0 | ||
90 | + m_SettingNames: | ||
91 | + - Humanoid |
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!19 &1 | ||
4 | +Physics2DSettings: | ||
5 | + m_ObjectHideFlags: 0 | ||
6 | + serializedVersion: 3 | ||
7 | + m_Gravity: {x: 0, y: -9.81} | ||
8 | + m_DefaultMaterial: {fileID: 0} | ||
9 | + m_VelocityIterations: 8 | ||
10 | + m_PositionIterations: 3 | ||
11 | + m_VelocityThreshold: 1 | ||
12 | + m_MaxLinearCorrection: 0.2 | ||
13 | + m_MaxAngularCorrection: 8 | ||
14 | + m_MaxTranslationSpeed: 100 | ||
15 | + m_MaxRotationSpeed: 360 | ||
16 | + m_BaumgarteScale: 0.2 | ||
17 | + m_BaumgarteTimeOfImpactScale: 0.75 | ||
18 | + m_TimeToSleep: 0.5 | ||
19 | + m_LinearSleepTolerance: 0.01 | ||
20 | + m_AngularSleepTolerance: 2 | ||
21 | + m_DefaultContactOffset: 0.01 | ||
22 | + m_AutoSimulation: 1 | ||
23 | + m_QueriesHitTriggers: 1 | ||
24 | + m_QueriesStartInColliders: 1 | ||
25 | + m_ChangeStopsCallbacks: 0 | ||
26 | + m_CallbacksOnDisable: 1 | ||
27 | + m_AutoSyncTransforms: 1 | ||
28 | + m_AlwaysShowColliders: 0 | ||
29 | + m_ShowColliderSleep: 1 | ||
30 | + m_ShowColliderContacts: 0 | ||
31 | + m_ShowColliderAABB: 0 | ||
32 | + m_ContactArrowScale: 0.2 | ||
33 | + m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} | ||
34 | + m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} | ||
35 | + m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} | ||
36 | + m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} | ||
37 | + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff |
This diff is collapsed. Click to expand it.
1 | +m_EditorVersion: 2017.3.0p3 |
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!47 &1 | ||
4 | +QualitySettings: | ||
5 | + m_ObjectHideFlags: 0 | ||
6 | + serializedVersion: 5 | ||
7 | + m_CurrentQuality: 5 | ||
8 | + m_QualitySettings: | ||
9 | + - serializedVersion: 2 | ||
10 | + name: Very Low | ||
11 | + pixelLightCount: 0 | ||
12 | + shadows: 0 | ||
13 | + shadowResolution: 0 | ||
14 | + shadowProjection: 1 | ||
15 | + shadowCascades: 1 | ||
16 | + shadowDistance: 15 | ||
17 | + shadowNearPlaneOffset: 3 | ||
18 | + shadowCascade2Split: 0.33333334 | ||
19 | + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} | ||
20 | + shadowmaskMode: 0 | ||
21 | + blendWeights: 1 | ||
22 | + textureQuality: 1 | ||
23 | + anisotropicTextures: 0 | ||
24 | + antiAliasing: 0 | ||
25 | + softParticles: 0 | ||
26 | + softVegetation: 0 | ||
27 | + realtimeReflectionProbes: 0 | ||
28 | + billboardsFaceCameraPosition: 0 | ||
29 | + vSyncCount: 0 | ||
30 | + lodBias: 0.3 | ||
31 | + maximumLODLevel: 0 | ||
32 | + particleRaycastBudget: 4 | ||
33 | + asyncUploadTimeSlice: 2 | ||
34 | + asyncUploadBufferSize: 4 | ||
35 | + resolutionScalingFixedDPIFactor: 1 | ||
36 | + excludedTargetPlatforms: [] | ||
37 | + - serializedVersion: 2 | ||
38 | + name: Low | ||
39 | + pixelLightCount: 0 | ||
40 | + shadows: 0 | ||
41 | + shadowResolution: 0 | ||
42 | + shadowProjection: 1 | ||
43 | + shadowCascades: 1 | ||
44 | + shadowDistance: 20 | ||
45 | + shadowNearPlaneOffset: 3 | ||
46 | + shadowCascade2Split: 0.33333334 | ||
47 | + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} | ||
48 | + shadowmaskMode: 0 | ||
49 | + blendWeights: 2 | ||
50 | + textureQuality: 0 | ||
51 | + anisotropicTextures: 0 | ||
52 | + antiAliasing: 0 | ||
53 | + softParticles: 0 | ||
54 | + softVegetation: 0 | ||
55 | + realtimeReflectionProbes: 0 | ||
56 | + billboardsFaceCameraPosition: 0 | ||
57 | + vSyncCount: 0 | ||
58 | + lodBias: 0.4 | ||
59 | + maximumLODLevel: 0 | ||
60 | + particleRaycastBudget: 16 | ||
61 | + asyncUploadTimeSlice: 2 | ||
62 | + asyncUploadBufferSize: 4 | ||
63 | + resolutionScalingFixedDPIFactor: 1 | ||
64 | + excludedTargetPlatforms: [] | ||
65 | + - serializedVersion: 2 | ||
66 | + name: Medium | ||
67 | + pixelLightCount: 1 | ||
68 | + shadows: 1 | ||
69 | + shadowResolution: 0 | ||
70 | + shadowProjection: 1 | ||
71 | + shadowCascades: 1 | ||
72 | + shadowDistance: 20 | ||
73 | + shadowNearPlaneOffset: 3 | ||
74 | + shadowCascade2Split: 0.33333334 | ||
75 | + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} | ||
76 | + shadowmaskMode: 0 | ||
77 | + blendWeights: 2 | ||
78 | + textureQuality: 0 | ||
79 | + anisotropicTextures: 1 | ||
80 | + antiAliasing: 0 | ||
81 | + softParticles: 0 | ||
82 | + softVegetation: 0 | ||
83 | + realtimeReflectionProbes: 0 | ||
84 | + billboardsFaceCameraPosition: 0 | ||
85 | + vSyncCount: 1 | ||
86 | + lodBias: 0.7 | ||
87 | + maximumLODLevel: 0 | ||
88 | + particleRaycastBudget: 64 | ||
89 | + asyncUploadTimeSlice: 2 | ||
90 | + asyncUploadBufferSize: 4 | ||
91 | + resolutionScalingFixedDPIFactor: 1 | ||
92 | + excludedTargetPlatforms: [] | ||
93 | + - serializedVersion: 2 | ||
94 | + name: High | ||
95 | + pixelLightCount: 2 | ||
96 | + shadows: 2 | ||
97 | + shadowResolution: 1 | ||
98 | + shadowProjection: 1 | ||
99 | + shadowCascades: 2 | ||
100 | + shadowDistance: 40 | ||
101 | + shadowNearPlaneOffset: 3 | ||
102 | + shadowCascade2Split: 0.33333334 | ||
103 | + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} | ||
104 | + shadowmaskMode: 1 | ||
105 | + blendWeights: 2 | ||
106 | + textureQuality: 0 | ||
107 | + anisotropicTextures: 1 | ||
108 | + antiAliasing: 0 | ||
109 | + softParticles: 0 | ||
110 | + softVegetation: 1 | ||
111 | + realtimeReflectionProbes: 1 | ||
112 | + billboardsFaceCameraPosition: 1 | ||
113 | + vSyncCount: 1 | ||
114 | + lodBias: 1 | ||
115 | + maximumLODLevel: 0 | ||
116 | + particleRaycastBudget: 256 | ||
117 | + asyncUploadTimeSlice: 2 | ||
118 | + asyncUploadBufferSize: 4 | ||
119 | + resolutionScalingFixedDPIFactor: 1 | ||
120 | + excludedTargetPlatforms: [] | ||
121 | + - serializedVersion: 2 | ||
122 | + name: Very High | ||
123 | + pixelLightCount: 3 | ||
124 | + shadows: 2 | ||
125 | + shadowResolution: 2 | ||
126 | + shadowProjection: 1 | ||
127 | + shadowCascades: 2 | ||
128 | + shadowDistance: 70 | ||
129 | + shadowNearPlaneOffset: 3 | ||
130 | + shadowCascade2Split: 0.33333334 | ||
131 | + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} | ||
132 | + shadowmaskMode: 1 | ||
133 | + blendWeights: 4 | ||
134 | + textureQuality: 0 | ||
135 | + anisotropicTextures: 2 | ||
136 | + antiAliasing: 2 | ||
137 | + softParticles: 1 | ||
138 | + softVegetation: 1 | ||
139 | + realtimeReflectionProbes: 1 | ||
140 | + billboardsFaceCameraPosition: 1 | ||
141 | + vSyncCount: 1 | ||
142 | + lodBias: 1.5 | ||
143 | + maximumLODLevel: 0 | ||
144 | + particleRaycastBudget: 1024 | ||
145 | + asyncUploadTimeSlice: 2 | ||
146 | + asyncUploadBufferSize: 4 | ||
147 | + resolutionScalingFixedDPIFactor: 1 | ||
148 | + excludedTargetPlatforms: [] | ||
149 | + - serializedVersion: 2 | ||
150 | + name: Ultra | ||
151 | + pixelLightCount: 4 | ||
152 | + shadows: 2 | ||
153 | + shadowResolution: 2 | ||
154 | + shadowProjection: 1 | ||
155 | + shadowCascades: 4 | ||
156 | + shadowDistance: 150 | ||
157 | + shadowNearPlaneOffset: 3 | ||
158 | + shadowCascade2Split: 0.33333334 | ||
159 | + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} | ||
160 | + shadowmaskMode: 1 | ||
161 | + blendWeights: 4 | ||
162 | + textureQuality: 0 | ||
163 | + anisotropicTextures: 2 | ||
164 | + antiAliasing: 2 | ||
165 | + softParticles: 1 | ||
166 | + softVegetation: 1 | ||
167 | + realtimeReflectionProbes: 1 | ||
168 | + billboardsFaceCameraPosition: 1 | ||
169 | + vSyncCount: 1 | ||
170 | + lodBias: 2 | ||
171 | + maximumLODLevel: 0 | ||
172 | + particleRaycastBudget: 4096 | ||
173 | + asyncUploadTimeSlice: 2 | ||
174 | + asyncUploadBufferSize: 4 | ||
175 | + resolutionScalingFixedDPIFactor: 1 | ||
176 | + excludedTargetPlatforms: [] | ||
177 | + m_PerPlatformDefaultQuality: | ||
178 | + Android: 2 | ||
179 | + Nintendo 3DS: 5 | ||
180 | + Nintendo Switch: 5 | ||
181 | + PS4: 5 | ||
182 | + PSM: 5 | ||
183 | + PSP2: 2 | ||
184 | + Standalone: 5 | ||
185 | + Tizen: 2 | ||
186 | + WebGL: 3 | ||
187 | + WiiU: 5 | ||
188 | + Windows Store Apps: 5 | ||
189 | + XboxOne: 5 | ||
190 | + iPhone: 2 | ||
191 | + tvOS: 2 |
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!78 &1 | ||
4 | +TagManager: | ||
5 | + serializedVersion: 2 | ||
6 | + tags: [] | ||
7 | + layers: | ||
8 | + - Default | ||
9 | + - TransparentFX | ||
10 | + - Ignore Raycast | ||
11 | + - | ||
12 | + - Water | ||
13 | + - UI | ||
14 | + - | ||
15 | + - | ||
16 | + - | ||
17 | + - | ||
18 | + - | ||
19 | + - | ||
20 | + - | ||
21 | + - | ||
22 | + - | ||
23 | + - | ||
24 | + - | ||
25 | + - | ||
26 | + - | ||
27 | + - | ||
28 | + - | ||
29 | + - | ||
30 | + - | ||
31 | + - | ||
32 | + - | ||
33 | + - | ||
34 | + - | ||
35 | + - | ||
36 | + - | ||
37 | + - | ||
38 | + - | ||
39 | + - | ||
40 | + m_SortingLayers: | ||
41 | + - name: Default | ||
42 | + uniqueID: 0 | ||
43 | + locked: 0 |
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!310 &1 | ||
4 | +UnityConnectSettings: | ||
5 | + m_ObjectHideFlags: 0 | ||
6 | + m_Enabled: 0 | ||
7 | + m_TestMode: 0 | ||
8 | + m_TestEventUrl: | ||
9 | + m_TestConfigUrl: | ||
10 | + m_TestInitMode: 0 | ||
11 | + CrashReportingSettings: | ||
12 | + m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes | ||
13 | + m_NativeEventUrl: https://perf-events.cloud.unity3d.com/symbolicate | ||
14 | + m_Enabled: 0 | ||
15 | + m_CaptureEditorExceptions: 1 | ||
16 | + UnityPurchasingSettings: | ||
17 | + m_Enabled: 0 | ||
18 | + m_TestMode: 0 | ||
19 | + UnityAnalyticsSettings: | ||
20 | + m_Enabled: 0 | ||
21 | + m_InitializeOnStartup: 1 | ||
22 | + m_TestMode: 0 | ||
23 | + m_TestEventUrl: | ||
24 | + m_TestConfigUrl: | ||
25 | + UnityAdsSettings: | ||
26 | + m_Enabled: 0 | ||
27 | + m_InitializeOnStartup: 1 | ||
28 | + m_TestMode: 0 | ||
29 | + m_IosGameId: | ||
30 | + m_AndroidGameId: | ||
31 | + m_GameIds: {} | ||
32 | + m_GameId: | ||
33 | + PerformanceReportingSettings: | ||
34 | + m_Enabled: 0 |
-
Please register or login to post a comment