I_Jemin

Refactoring Chat App

...@@ -256,11 +256,11 @@ MonoBehaviour: ...@@ -256,11 +256,11 @@ MonoBehaviour:
256 m_GameObject: {fileID: 1740271} 256 m_GameObject: {fileID: 1740271}
257 m_Enabled: 1 257 m_Enabled: 1
258 m_EditorHideFlags: 0 258 m_EditorHideFlags: 0
259 - m_Script: {fileID: 11500000, guid: d74e03325f4c74af5986ac0df47e31a3, type: 3} 259 + m_Script: {fileID: 11500000, guid: 98c5561a51b8e0142ab376064462bf54, type: 3}
260 m_Name: 260 m_Name:
261 m_EditorClassIdentifier: 261 m_EditorClassIdentifier:
262 - chat: {fileID: 2036355376}
263 inputField: {fileID: 1740273} 262 inputField: {fileID: 1740273}
263 + chatManager: {fileID: 2036355376}
264 --- !u!1 &257132851 264 --- !u!1 &257132851
265 GameObject: 265 GameObject:
266 m_ObjectHideFlags: 0 266 m_ObjectHideFlags: 0
...@@ -628,7 +628,7 @@ MonoBehaviour: ...@@ -628,7 +628,7 @@ MonoBehaviour:
628 m_PersistentCalls: 628 m_PersistentCalls:
629 m_Calls: 629 m_Calls:
630 - m_Target: {fileID: 2036355376} 630 - m_Target: {fileID: 2036355376}
631 - m_MethodName: JoinChatRoom 631 + m_MethodName: JoinRoom
632 m_Mode: 1 632 m_Mode: 1
633 m_Arguments: 633 m_Arguments:
634 m_ObjectArgument: {fileID: 0} 634 m_ObjectArgument: {fileID: 0}
...@@ -673,6 +673,151 @@ CanvasRenderer: ...@@ -673,6 +673,151 @@ CanvasRenderer:
673 m_PrefabParentObject: {fileID: 0} 673 m_PrefabParentObject: {fileID: 0}
674 m_PrefabInternal: {fileID: 0} 674 m_PrefabInternal: {fileID: 0}
675 m_GameObject: {fileID: 650336557} 675 m_GameObject: {fileID: 650336557}
676 +--- !u!1 &691573676
677 +GameObject:
678 + m_ObjectHideFlags: 0
679 + m_PrefabParentObject: {fileID: 0}
680 + m_PrefabInternal: {fileID: 0}
681 + serializedVersion: 5
682 + m_Component:
683 + - component: {fileID: 691573677}
684 + - component: {fileID: 691573680}
685 + - component: {fileID: 691573679}
686 + - component: {fileID: 691573678}
687 + m_Layer: 5
688 + m_Name: InputField
689 + m_TagString: Untagged
690 + m_Icon: {fileID: 0}
691 + m_NavMeshLayer: 0
692 + m_StaticEditorFlags: 0
693 + m_IsActive: 1
694 +--- !u!224 &691573677
695 +RectTransform:
696 + m_ObjectHideFlags: 0
697 + m_PrefabParentObject: {fileID: 0}
698 + m_PrefabInternal: {fileID: 0}
699 + m_GameObject: {fileID: 691573676}
700 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
701 + m_LocalPosition: {x: 0, y: 0, z: 0}
702 + m_LocalScale: {x: 1, y: 1, z: 1}
703 + m_Children:
704 + - {fileID: 2073465268}
705 + - {fileID: 1399557666}
706 + m_Father: {fileID: 1372740361}
707 + m_RootOrder: 3
708 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
709 + m_AnchorMin: {x: 0, y: 0}
710 + m_AnchorMax: {x: 0, y: 0}
711 + m_AnchoredPosition: {x: 0, y: 0}
712 + m_SizeDelta: {x: 0, y: 0}
713 + m_Pivot: {x: 0.5, y: 0.5}
714 +--- !u!114 &691573678
715 +MonoBehaviour:
716 + m_ObjectHideFlags: 0
717 + m_PrefabParentObject: {fileID: 0}
718 + m_PrefabInternal: {fileID: 0}
719 + m_GameObject: {fileID: 691573676}
720 + m_Enabled: 1
721 + m_EditorHideFlags: 0
722 + m_Script: {fileID: 575553740, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
723 + m_Name:
724 + m_EditorClassIdentifier:
725 + m_Navigation:
726 + m_Mode: 3
727 + m_SelectOnUp: {fileID: 0}
728 + m_SelectOnDown: {fileID: 0}
729 + m_SelectOnLeft: {fileID: 0}
730 + m_SelectOnRight: {fileID: 0}
731 + m_Transition: 1
732 + m_Colors:
733 + m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
734 + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
735 + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
736 + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
737 + m_ColorMultiplier: 1
738 + m_FadeDuration: 0.1
739 + m_SpriteState:
740 + m_HighlightedSprite: {fileID: 0}
741 + m_PressedSprite: {fileID: 0}
742 + m_DisabledSprite: {fileID: 0}
743 + m_AnimationTriggers:
744 + m_NormalTrigger: Normal
745 + m_HighlightedTrigger: Highlighted
746 + m_PressedTrigger: Pressed
747 + m_DisabledTrigger: Disabled
748 + m_Interactable: 1
749 + m_TargetGraphic: {fileID: 691573679}
750 + m_TextComponent: {fileID: 1399557667}
751 + m_Placeholder: {fileID: 2073465269}
752 + m_ContentType: 0
753 + m_InputType: 0
754 + m_AsteriskChar: 42
755 + m_KeyboardType: 0
756 + m_LineType: 0
757 + m_HideMobileInput: 0
758 + m_CharacterValidation: 0
759 + m_CharacterLimit: 0
760 + m_OnEndEdit:
761 + m_PersistentCalls:
762 + m_Calls: []
763 + m_TypeName: UnityEngine.UI.InputField+SubmitEvent, UnityEngine.UI, Version=1.0.0.0,
764 + Culture=neutral, PublicKeyToken=null
765 + m_OnValueChanged:
766 + m_PersistentCalls:
767 + m_Calls:
768 + - m_Target: {fileID: 2036355376}
769 + m_MethodName: UpdateHostAddress
770 + m_Mode: 0
771 + m_Arguments:
772 + m_ObjectArgument: {fileID: 0}
773 + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
774 + m_IntArgument: 0
775 + m_FloatArgument: 0
776 + m_StringArgument:
777 + m_BoolArgument: 0
778 + m_CallState: 2
779 + m_TypeName: UnityEngine.UI.InputField+OnChangeEvent, UnityEngine.UI, Version=1.0.0.0,
780 + Culture=neutral, PublicKeyToken=null
781 + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
782 + m_CustomCaretColor: 0
783 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412}
784 + m_Text: 127.0.0.1
785 + m_CaretBlinkRate: 0.85
786 + m_CaretWidth: 1
787 + m_ReadOnly: 0
788 +--- !u!114 &691573679
789 +MonoBehaviour:
790 + m_ObjectHideFlags: 0
791 + m_PrefabParentObject: {fileID: 0}
792 + m_PrefabInternal: {fileID: 0}
793 + m_GameObject: {fileID: 691573676}
794 + m_Enabled: 1
795 + m_EditorHideFlags: 0
796 + m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
797 + m_Name:
798 + m_EditorClassIdentifier:
799 + m_Material: {fileID: 0}
800 + m_Color: {r: 1, g: 1, b: 1, a: 1}
801 + m_RaycastTarget: 1
802 + m_OnCullStateChanged:
803 + m_PersistentCalls:
804 + m_Calls: []
805 + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
806 + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
807 + m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0}
808 + m_Type: 1
809 + m_PreserveAspect: 0
810 + m_FillCenter: 1
811 + m_FillMethod: 4
812 + m_FillAmount: 1
813 + m_FillClockwise: 1
814 + m_FillOrigin: 0
815 +--- !u!222 &691573680
816 +CanvasRenderer:
817 + m_ObjectHideFlags: 0
818 + m_PrefabParentObject: {fileID: 0}
819 + m_PrefabInternal: {fileID: 0}
820 + m_GameObject: {fileID: 691573676}
676 --- !u!1 &1003989031 821 --- !u!1 &1003989031
677 GameObject: 822 GameObject:
678 m_ObjectHideFlags: 0 823 m_ObjectHideFlags: 0
...@@ -985,13 +1130,14 @@ RectTransform: ...@@ -985,13 +1130,14 @@ RectTransform:
985 - {fileID: 1763030733} 1130 - {fileID: 1763030733}
986 - {fileID: 650336558} 1131 - {fileID: 650336558}
987 - {fileID: 257132852} 1132 - {fileID: 257132852}
1133 + - {fileID: 691573677}
988 m_Father: {fileID: 1310784055} 1134 m_Father: {fileID: 1310784055}
989 m_RootOrder: 1 1135 m_RootOrder: 1
990 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 1136 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
991 m_AnchorMin: {x: 1, y: 0} 1137 m_AnchorMin: {x: 1, y: 0}
992 m_AnchorMax: {x: 1, y: 1} 1138 m_AnchorMax: {x: 1, y: 1}
993 m_AnchoredPosition: {x: 0, y: 0} 1139 m_AnchoredPosition: {x: 0, y: 0}
994 - m_SizeDelta: {x: 150, y: 0} 1140 + m_SizeDelta: {x: 210.9, y: 0}
995 m_Pivot: {x: 1, y: 0.5} 1141 m_Pivot: {x: 1, y: 0.5}
996 --- !u!114 &1372740362 1142 --- !u!114 &1372740362
997 MonoBehaviour: 1143 MonoBehaviour:
...@@ -1067,6 +1213,80 @@ MonoBehaviour: ...@@ -1067,6 +1213,80 @@ MonoBehaviour:
1067 m_FlexibleWidth: -1 1213 m_FlexibleWidth: -1
1068 m_FlexibleHeight: -1 1214 m_FlexibleHeight: -1
1069 m_LayoutPriority: 1 1215 m_LayoutPriority: 1
1216 +--- !u!1 &1399557665
1217 +GameObject:
1218 + m_ObjectHideFlags: 0
1219 + m_PrefabParentObject: {fileID: 0}
1220 + m_PrefabInternal: {fileID: 0}
1221 + serializedVersion: 5
1222 + m_Component:
1223 + - component: {fileID: 1399557666}
1224 + - component: {fileID: 1399557668}
1225 + - component: {fileID: 1399557667}
1226 + m_Layer: 5
1227 + m_Name: Text
1228 + m_TagString: Untagged
1229 + m_Icon: {fileID: 0}
1230 + m_NavMeshLayer: 0
1231 + m_StaticEditorFlags: 0
1232 + m_IsActive: 1
1233 +--- !u!224 &1399557666
1234 +RectTransform:
1235 + m_ObjectHideFlags: 0
1236 + m_PrefabParentObject: {fileID: 0}
1237 + m_PrefabInternal: {fileID: 0}
1238 + m_GameObject: {fileID: 1399557665}
1239 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
1240 + m_LocalPosition: {x: 0, y: 0, z: 0}
1241 + m_LocalScale: {x: 1, y: 1, z: 1}
1242 + m_Children: []
1243 + m_Father: {fileID: 691573677}
1244 + m_RootOrder: 1
1245 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
1246 + m_AnchorMin: {x: 0, y: 0}
1247 + m_AnchorMax: {x: 1, y: 1}
1248 + m_AnchoredPosition: {x: 0, y: -0.5}
1249 + m_SizeDelta: {x: -20, y: -13}
1250 + m_Pivot: {x: 0.5, y: 0.5}
1251 +--- !u!114 &1399557667
1252 +MonoBehaviour:
1253 + m_ObjectHideFlags: 0
1254 + m_PrefabParentObject: {fileID: 0}
1255 + m_PrefabInternal: {fileID: 0}
1256 + m_GameObject: {fileID: 1399557665}
1257 + m_Enabled: 1
1258 + m_EditorHideFlags: 0
1259 + m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
1260 + m_Name:
1261 + m_EditorClassIdentifier:
1262 + m_Material: {fileID: 0}
1263 + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
1264 + m_RaycastTarget: 1
1265 + m_OnCullStateChanged:
1266 + m_PersistentCalls:
1267 + m_Calls: []
1268 + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
1269 + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
1270 + m_FontData:
1271 + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
1272 + m_FontSize: 25
1273 + m_FontStyle: 0
1274 + m_BestFit: 0
1275 + m_MinSize: 10
1276 + m_MaxSize: 40
1277 + m_Alignment: 0
1278 + m_AlignByGeometry: 0
1279 + m_RichText: 0
1280 + m_HorizontalOverflow: 1
1281 + m_VerticalOverflow: 0
1282 + m_LineSpacing: 1
1283 + m_Text: 127.0.0.1
1284 +--- !u!222 &1399557668
1285 +CanvasRenderer:
1286 + m_ObjectHideFlags: 0
1287 + m_PrefabParentObject: {fileID: 0}
1288 + m_PrefabInternal: {fileID: 0}
1289 + m_GameObject: {fileID: 1399557665}
1070 --- !u!1 &1443135692 1290 --- !u!1 &1443135692
1071 GameObject: 1291 GameObject:
1072 m_ObjectHideFlags: 0 1292 m_ObjectHideFlags: 0
...@@ -1121,9 +1341,9 @@ MonoBehaviour: ...@@ -1121,9 +1341,9 @@ MonoBehaviour:
1121 m_Bottom: 0 1341 m_Bottom: 0
1122 m_ChildAlignment: 0 1342 m_ChildAlignment: 0
1123 m_Spacing: 0 1343 m_Spacing: 0
1124 - m_ChildForceExpandWidth: 0 1344 + m_ChildForceExpandWidth: 1
1125 m_ChildForceExpandHeight: 0 1345 m_ChildForceExpandHeight: 0
1126 - m_ChildControlWidth: 0 1346 + m_ChildControlWidth: 1
1127 m_ChildControlHeight: 0 1347 m_ChildControlHeight: 0
1128 --- !u!114 &1443135695 1348 --- !u!114 &1443135695
1129 MonoBehaviour: 1349 MonoBehaviour:
...@@ -1266,8 +1486,8 @@ RectTransform: ...@@ -1266,8 +1486,8 @@ RectTransform:
1266 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 1486 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
1267 m_AnchorMin: {x: 0, y: 0} 1487 m_AnchorMin: {x: 0, y: 0}
1268 m_AnchorMax: {x: 1, y: 1} 1488 m_AnchorMax: {x: 1, y: 1}
1269 - m_AnchoredPosition: {x: -75, y: 0} 1489 + m_AnchoredPosition: {x: -105.45, y: 0}
1270 - m_SizeDelta: {x: -150, y: 0} 1490 + m_SizeDelta: {x: -210.9, y: 0}
1271 m_Pivot: {x: 0.5, y: 0.5} 1491 m_Pivot: {x: 0.5, y: 0.5}
1272 --- !u!114 &1573133660 1492 --- !u!114 &1573133660
1273 MonoBehaviour: 1493 MonoBehaviour:
...@@ -1587,8 +1807,8 @@ GameObject: ...@@ -1587,8 +1807,8 @@ GameObject:
1587 serializedVersion: 5 1807 serializedVersion: 5
1588 m_Component: 1808 m_Component:
1589 - component: {fileID: 2036355377} 1809 - component: {fileID: 2036355377}
1590 - - component: {fileID: 2036355376}
1591 - component: {fileID: 2036355375} 1810 - component: {fileID: 2036355375}
1811 + - component: {fileID: 2036355376}
1592 m_Layer: 0 1812 m_Layer: 0
1593 m_Name: Chat Manager 1813 m_Name: Chat Manager
1594 m_TagString: Untagged 1814 m_TagString: Untagged
...@@ -1615,15 +1835,15 @@ MonoBehaviour: ...@@ -1615,15 +1835,15 @@ MonoBehaviour:
1615 m_GameObject: {fileID: 2036355374} 1835 m_GameObject: {fileID: 2036355374}
1616 m_Enabled: 1 1836 m_Enabled: 1
1617 m_EditorHideFlags: 0 1837 m_EditorHideFlags: 0
1618 - m_Script: {fileID: 11500000, guid: 7d91d3622aead48008aca0d637d4ad9b, type: 3} 1838 + m_Script: {fileID: 11500000, guid: 8240f60e023c1a0419f8a05cf380e33a, type: 3}
1619 m_Name: 1839 m_Name:
1620 m_EditorClassIdentifier: 1840 m_EditorClassIdentifier:
1621 m_transport: {fileID: 2036355375} 1841 m_transport: {fileID: 2036355375}
1622 - commentTextPrefab: {fileID: 114312857566104806, guid: b4721aef43e524b91936d391647d3ae1, 1842 + m_messageTextPrafab: {fileID: 114555819942375258, guid: b4721aef43e524b91936d391647d3ae1,
1623 type: 2} 1843 type: 2}
1624 - commentHolder: {fileID: 1443135693} 1844 + m_messageHolder: {fileID: 1443135693}
1625 m_hostAddress: 127.0.0.1 1845 m_hostAddress: 127.0.0.1
1626 - m_port: 50763 1846 + m_port: 50666
1627 --- !u!4 &2036355377 1847 --- !u!4 &2036355377
1628 Transform: 1848 Transform:
1629 m_ObjectHideFlags: 0 1849 m_ObjectHideFlags: 0
...@@ -1637,3 +1857,77 @@ Transform: ...@@ -1637,3 +1857,77 @@ Transform:
1637 m_Father: {fileID: 0} 1857 m_Father: {fileID: 0}
1638 m_RootOrder: 3 1858 m_RootOrder: 3
1639 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 1859 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
1860 +--- !u!1 &2073465267
1861 +GameObject:
1862 + m_ObjectHideFlags: 0
1863 + m_PrefabParentObject: {fileID: 0}
1864 + m_PrefabInternal: {fileID: 0}
1865 + serializedVersion: 5
1866 + m_Component:
1867 + - component: {fileID: 2073465268}
1868 + - component: {fileID: 2073465270}
1869 + - component: {fileID: 2073465269}
1870 + m_Layer: 5
1871 + m_Name: Placeholder
1872 + m_TagString: Untagged
1873 + m_Icon: {fileID: 0}
1874 + m_NavMeshLayer: 0
1875 + m_StaticEditorFlags: 0
1876 + m_IsActive: 1
1877 +--- !u!224 &2073465268
1878 +RectTransform:
1879 + m_ObjectHideFlags: 0
1880 + m_PrefabParentObject: {fileID: 0}
1881 + m_PrefabInternal: {fileID: 0}
1882 + m_GameObject: {fileID: 2073465267}
1883 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
1884 + m_LocalPosition: {x: 0, y: 0, z: 0}
1885 + m_LocalScale: {x: 1, y: 1, z: 1}
1886 + m_Children: []
1887 + m_Father: {fileID: 691573677}
1888 + m_RootOrder: 0
1889 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
1890 + m_AnchorMin: {x: 0, y: 0}
1891 + m_AnchorMax: {x: 1, y: 1}
1892 + m_AnchoredPosition: {x: 0, y: -0.5}
1893 + m_SizeDelta: {x: -20, y: -13}
1894 + m_Pivot: {x: 0.5, y: 0.5}
1895 +--- !u!114 &2073465269
1896 +MonoBehaviour:
1897 + m_ObjectHideFlags: 0
1898 + m_PrefabParentObject: {fileID: 0}
1899 + m_PrefabInternal: {fileID: 0}
1900 + m_GameObject: {fileID: 2073465267}
1901 + m_Enabled: 0
1902 + m_EditorHideFlags: 0
1903 + m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
1904 + m_Name:
1905 + m_EditorClassIdentifier:
1906 + m_Material: {fileID: 0}
1907 + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5}
1908 + m_RaycastTarget: 1
1909 + m_OnCullStateChanged:
1910 + m_PersistentCalls:
1911 + m_Calls: []
1912 + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
1913 + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
1914 + m_FontData:
1915 + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
1916 + m_FontSize: 25
1917 + m_FontStyle: 2
1918 + m_BestFit: 0
1919 + m_MinSize: 10
1920 + m_MaxSize: 40
1921 + m_Alignment: 0
1922 + m_AlignByGeometry: 0
1923 + m_RichText: 1
1924 + m_HorizontalOverflow: 0
1925 + m_VerticalOverflow: 0
1926 + m_LineSpacing: 1
1927 + m_Text: Enter IP Address
1928 +--- !u!222 &2073465270
1929 +CanvasRenderer:
1930 + m_ObjectHideFlags: 0
1931 + m_PrefabParentObject: {fileID: 0}
1932 + m_PrefabInternal: {fileID: 0}
1933 + m_GameObject: {fileID: 2073465267}
......
...@@ -21,9 +21,9 @@ GameObject: ...@@ -21,9 +21,9 @@ GameObject:
21 - component: {fileID: 224026180460817448} 21 - component: {fileID: 224026180460817448}
22 - component: {fileID: 222343435350097842} 22 - component: {fileID: 222343435350097842}
23 - component: {fileID: 114640140560748198} 23 - component: {fileID: 114640140560748198}
24 - - component: {fileID: 114312857566104806} 24 + - component: {fileID: 114555819942375258}
25 m_Layer: 5 25 m_Layer: 5
26 - m_Name: Comment 26 + m_Name: Message Text
27 m_TagString: Untagged 27 m_TagString: Untagged
28 m_Icon: {fileID: 0} 28 m_Icon: {fileID: 0}
29 m_NavMeshLayer: 0 29 m_NavMeshLayer: 0
...@@ -79,7 +79,7 @@ MonoBehaviour: ...@@ -79,7 +79,7 @@ MonoBehaviour:
79 m_VerticalOverflow: 0 79 m_VerticalOverflow: 0
80 m_LineSpacing: 1 80 m_LineSpacing: 1
81 m_Text: Sample Text 81 m_Text: Sample Text
82 ---- !u!114 &114312857566104806 82 +--- !u!114 &114555819942375258
83 MonoBehaviour: 83 MonoBehaviour:
84 m_ObjectHideFlags: 1 84 m_ObjectHideFlags: 1
85 m_PrefabParentObject: {fileID: 0} 85 m_PrefabParentObject: {fileID: 0}
...@@ -87,10 +87,10 @@ MonoBehaviour: ...@@ -87,10 +87,10 @@ MonoBehaviour:
87 m_GameObject: {fileID: 1351082387170804} 87 m_GameObject: {fileID: 1351082387170804}
88 m_Enabled: 1 88 m_Enabled: 1
89 m_EditorHideFlags: 0 89 m_EditorHideFlags: 0
90 - m_Script: {fileID: 11500000, guid: e3c2e0a12ace649978c3c197ab4726a6, type: 3} 90 + m_Script: {fileID: 11500000, guid: f76bbd8dd17bc35488b1ca48227bbca3, type: 3}
91 m_Name: 91 m_Name:
92 m_EditorClassIdentifier: 92 m_EditorClassIdentifier:
93 - commentText: {fileID: 114206746021236310} 93 + messageText: {fileID: 114206746021236310}
94 --- !u!114 &114640140560748198 94 --- !u!114 &114640140560748198
95 MonoBehaviour: 95 MonoBehaviour:
96 m_ObjectHideFlags: 1 96 m_ObjectHideFlags: 1
...@@ -147,7 +147,7 @@ RectTransform: ...@@ -147,7 +147,7 @@ RectTransform:
147 m_AnchorMin: {x: 0, y: 0} 147 m_AnchorMin: {x: 0, y: 0}
148 m_AnchorMax: {x: 0, y: 0} 148 m_AnchorMax: {x: 0, y: 0}
149 m_AnchoredPosition: {x: 0, y: 0} 149 m_AnchoredPosition: {x: 0, y: 0}
150 - m_SizeDelta: {x: 200, y: 50} 150 + m_SizeDelta: {x: 0, y: 50}
151 m_Pivot: {x: 0.5, y: 0.5} 151 m_Pivot: {x: 0.5, y: 0.5}
152 --- !u!224 &224999107880086880 152 --- !u!224 &224999107880086880
153 RectTransform: 153 RectTransform:
......
...@@ -3,16 +3,18 @@ using System.Collections.Generic; ...@@ -3,16 +3,18 @@ using System.Collections.Generic;
3 using UnityEngine; 3 using UnityEngine;
4 using UnityEngine.UI; 4 using UnityEngine.UI;
5 5
6 -public class MessageInputField : MonoBehaviour { 6 +public class ChatInputField : MonoBehaviour {
7 7
8 - public Chat chat;
9 public InputField inputField; 8 public InputField inputField;
9 + public ChatManager chatManager;
10 10
11 - void Update () { 11 + void Update()
12 + {
12 if(Input.GetKeyDown(KeyCode.Return) && !string.IsNullOrEmpty(inputField.text)) 13 if(Input.GetKeyDown(KeyCode.Return) && !string.IsNullOrEmpty(inputField.text))
13 { 14 {
14 - chat.Send(inputField.text); 15 + chatManager.Send(inputField.text);
15 inputField.text = string.Empty; 16 inputField.text = string.Empty;
16 } 17 }
17 } 18 }
19 +
18 } 20 }
......
1 fileFormatVersion: 2 1 fileFormatVersion: 2
2 -guid: 7d91d3622aead48008aca0d637d4ad9b 2 +guid: 98c5561a51b8e0142ab376064462bf54
3 -timeCreated: 1517219122 3 +timeCreated: 1517460942
4 -licenseType: Pro 4 +licenseType: Free
5 MonoImporter: 5 MonoImporter:
6 externalObjects: {} 6 externalObjects: {}
7 serializedVersion: 2 7 serializedVersion: 2
......
1 -using UnityEngine; 1 +using System.Collections;
2 -using System;
3 -using System.Collections;
4 using System.Collections.Generic; 2 using System.Collections.Generic;
3 +using UnityEngine;
5 using System.Net; 4 using System.Net;
5 +using System;
6 6
7 -public class Chat : MonoBehaviour 7 +public class ChatManager : MonoBehaviour {
8 -{ 8 +
9 - public TransportTCP m_transport; 9 + List<GameObject> messages = new List<GameObject>();
10 - 10 +
11 - public ChatText commentTextPrefab; 11 + public TransportTCP m_transport; // 네트워크 연결을 담당
12 - 12 +
13 - public Transform commentHolder; 13 + public MessageText m_messageTextPrafab; // 말풍선
14 - 14 +
15 - public string m_hostAddress = "127.0.0.1"; 15 + public Transform m_messageHolder; // 말풍선을 붙일곳
16 - 16 +
17 - public int m_port = 50763; 17 + public string m_hostAddress = "127.0.0.1";
18 - 18 +
19 - private bool m_isServer = false; 19 + public int m_port = 50666;
20 - 20 +
21 - // Use this for initialization 21 + private bool m_isHost; // 방장(서버)
22 - void Start() 22 +
23 - { 23 + public void UpdateHostAddress(string newAddress)
24 - m_transport.onStateChanged += OnEventHandling; 24 + {
25 - } 25 + m_hostAddress = newAddress;
26 - 26 + }
27 - 27 +
28 - IEnumerator UpdateChatting() 28 + // 매프레임마다 패킷큐를 긁어와서 새로운 메시지를 추가
29 - { 29 + IEnumerator UpdateMessage()
30 - while (true) 30 + {
31 - { 31 + while(true)
32 - byte[] buffer = new byte[1400]; 32 + {
33 - 33 + byte[] buffer = new byte[1400];
34 - int recvSize = m_transport.Receive(ref buffer, buffer.Length); 34 +
35 - if (recvSize > 0) 35 + int recvSize = m_transport.Receive(ref buffer,buffer.Length);
36 - { 36 +
37 - string message = System.Text.Encoding.UTF8.GetString(buffer); 37 + if(recvSize > 0)
38 - Debug.Log("Recv data:" + message); 38 + {
39 - 39 + string message = System.Text.Encoding.UTF8.GetString(buffer);
40 - AddComment(message); 40 + Debug.Log("Receive: " + message);
41 - } 41 + AddMessageText(message);
42 - 42 + }
43 - yield return null; 43 + yield return null;
44 - } 44 + }
45 - } 45 + }
46 - 46 +
47 - 47 + // 텍스트를 넘겨주면 프리팹을 찍어내서 말풍선을 추가
48 - public void Send(string message) 48 + void AddMessageText(string message)
49 - { 49 + {
50 - message = "[" + DateTime.Now.ToString("HH:mm:ss") + "] " + message; 50 + MessageText instance = Instantiate(m_messageTextPrafab,m_messageHolder);
51 - 51 +
52 - byte[] buffer = System.Text.Encoding.UTF8.GetBytes(message); 52 + messages.Add(instance.gameObject);
53 - 53 + instance.SetUp(message);
54 - m_transport.Send(buffer, buffer.Length); 54 + }
55 - 55 +
56 - AddComment(message); 56 +
57 - } 57 + // 방 만들기 (서버 역할하기)
58 - 58 + public void CreateRoom()
59 - 59 + {
60 - void AddComment(string message) 60 + if(m_transport.StartServer(m_port,1))
61 - { 61 + {
62 - var newComment = Instantiate(commentTextPrefab, commentHolder); 62 + m_isHost = true;
63 - newComment.SetUp(message); 63 + StartCoroutine("UpdateMessage");
64 - } 64 + }
65 - void OnApplicationQuit() 65 + else
66 - { 66 + {
67 - if (m_transport != null) 67 + Debug.LogError("Create a Room Failed");
68 - { 68 + }
69 - if (m_isServer) 69 + }
70 - { 70 +
71 - m_transport.StopServer(); 71 + // 클라이언트가 미리 만들어진 방에 가는것
72 - } 72 + public void JoinRoom()
73 - else 73 + {
74 - { 74 + if(m_transport.Connect(m_hostAddress,m_port))
75 - m_transport.Disconnect(); 75 + {
76 - } 76 + m_isHost = false;
77 - } 77 + StartCoroutine("UpdateMessage");
78 - } 78 + }
79 - 79 + else
80 - public void OnEventHandling(NetEventState state) 80 + {
81 - { 81 + Debug.LogError("Join Room Failed");
82 - switch (state.type) 82 + }
83 - { 83 + }
84 - case NetEventType.Connect: 84 +
85 - AddComment("접속"); 85 + public void Leave()
86 - Debug.Log("접속"); 86 + {
87 - break; 87 + while(messages.Count > 0)
88 - 88 + {
89 - case NetEventType.Disconnect: 89 + var instance = messages[0];
90 - Debug.Log("접속 종료"); 90 + messages.RemoveAt(0);
91 - AddComment("접속 종료"); 91 + Destroy(instance);
92 - break; 92 + }
93 - } 93 +
94 - } 94 + if(m_isHost)
95 - 95 + {
96 - 96 + m_transport.StopServer();
97 - public void CreateRoom() 97 + }
98 - { 98 + else
99 - m_transport.StartServer(m_port, 1); 99 + {
100 - m_isServer = true; 100 + m_transport.Disconnect();
101 - StartCoroutine("UpdateChatting"); 101 + }
102 - } 102 +
103 - 103 + StopCoroutine("UpdateMessage");
104 - public void JoinChatRoom() 104 + }
105 - { 105 +
106 - bool ret = m_transport.Connect(m_hostAddress, m_port); 106 + void OnApplicationQuit()
107 - 107 + {
108 - if (ret) 108 + Leave();
109 - { 109 + }
110 - StartCoroutine("UpdateChatting"); 110 +
111 - } 111 + public void Send(string message)
112 - else 112 + {
113 - { 113 + message = "[" + DateTime.Now.ToString("HH:mm:ss") + "] " + message;
114 - Debug.LogError("Failed"); 114 +
115 - } 115 + byte[] buffer = System.Text.Encoding.UTF8.GetBytes(message);
116 - } 116 +
117 - 117 + m_transport.Send(buffer,buffer.Length);
118 - 118 +
119 - public void Leave() 119 + AddMessageText(message);
120 - { 120 + }
121 - if (m_isServer == true)
122 - {
123 - m_transport.StopServer();
124 - }
125 - else
126 - {
127 - m_transport.Disconnect();
128 - }
129 -
130 - StopCoroutine("UpdateChatting");
131 - }
132 -
133 121
134 } 122 }
......
1 fileFormatVersion: 2 1 fileFormatVersion: 2
2 -guid: e3c2e0a12ace649978c3c197ab4726a6 2 +guid: 8240f60e023c1a0419f8a05cf380e33a
3 -timeCreated: 1517221132 3 +timeCreated: 1517461505
4 -licenseType: Pro 4 +licenseType: Free
5 MonoImporter: 5 MonoImporter:
6 externalObjects: {} 6 externalObjects: {}
7 serializedVersion: 2 7 serializedVersion: 2
......
...@@ -3,12 +3,13 @@ using System.Collections.Generic; ...@@ -3,12 +3,13 @@ using System.Collections.Generic;
3 using UnityEngine; 3 using UnityEngine;
4 using UnityEngine.UI; 4 using UnityEngine.UI;
5 5
6 -public class ChatText : MonoBehaviour { 6 +public class MessageText : MonoBehaviour {
7 +
8 + public Text messageText;
7 9
8 - public Text commentText;
9 public void SetUp(string message) 10 public void SetUp(string message)
10 { 11 {
11 - commentText.text = message; 12 + messageText.text = message;
12 } 13 }
13 14
14 } 15 }
......
1 fileFormatVersion: 2 1 fileFormatVersion: 2
2 -guid: d74e03325f4c74af5986ac0df47e31a3 2 +guid: f76bbd8dd17bc35488b1ca48227bbca3
3 -timeCreated: 1517244266 3 +timeCreated: 1517460675
4 -licenseType: Pro 4 +licenseType: Free
5 MonoImporter: 5 MonoImporter:
6 externalObjects: {} 6 externalObjects: {}
7 serializedVersion: 2 7 serializedVersion: 2
......
...@@ -147,6 +147,7 @@ public class TransportTCP : MonoBehaviour ...@@ -147,6 +147,7 @@ public class TransportTCP : MonoBehaviour
147 state.type = NetEventType.Connect; 147 state.type = NetEventType.Connect;
148 state.result = (isConnected == true) ? NetEventResult.Success : NetEventResult.Failure; 148 state.result = (isConnected == true) ? NetEventResult.Success : NetEventResult.Failure;
149 149
150 + onStateChanged(state);
150 Debug.Log("Event Handler Called"); 151 Debug.Log("Event Handler Called");
151 } 152 }
152 153
......