I_Jemin

Network Chatting Prject

Showing 37 changed files with 2093 additions and 133 deletions
......@@ -18,6 +18,17 @@
# Visual Studio 2015 cache directory
/Basic Network Library/.vs/
/Network Chatting/[Ll]ibrary/
/Network Chatting/[Tt]emp/
/Network Chatting/[Oo]bj/
/Network Chatting/[Bb]uild/
/Network Chatting/[Bb]uilds/
/Network Chatting/Assets/AssetStoreTools*
# Visual Studio 2015 cache directory
/Network Chatting/.vs/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
......

// TCP로 통신할 때는 정의를 유효하게 하여 주십시오.
#define USE_TRANSPORT_TCP
using UnityEngine;
using System.Collections;
using System.Net;
public class LibrarySample : MonoBehaviour {
// 통신 모듈.
public GameObject transportTcpPrefab;
public GameObject transportUdpPrefab;
// 통신용 변수.
#if USE_TRANSPORT_TCP
TransportTCP m_transport = null;
#else
TransportUDP m_transport = null;
#endif
// 접속할 IP 주소.
private string m_strings = "";
// 접속할 포트 번호.
private const int m_port = 50765;
private const int m_mtu = 1400;
private bool isSelected = false;
// Use this for initialization
void Start ()
{
// Transport 클래스의 컴포넌트를 가져온다.
#if USE_TRANSPORT_TCP
GameObject obj = GameObject.Instantiate(transportTcpPrefab) as GameObject;
m_transport = obj.GetComponent<TransportTCP>();
#else
GameObject obj = GameObject.Instantiate(transportUdpPrefab) as GameObject;
m_transport = obj.GetComponent<TransportUDP>();
#endif
IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
System.Net.IPAddress hostAddress = hostEntry.AddressList[0];
Debug.Log(hostEntry.HostName);
m_strings = hostAddress.ToString();
}
// Update is called once per frame
void Update ()
{
if (m_transport != null && m_transport.isConnected == true) {
byte[] buffer = new byte[m_mtu];
int recvSize = m_transport.Receive(ref buffer, buffer.Length);
if (recvSize > 0) {
string message = System.Text.Encoding.UTF8.GetString(buffer);
Debug.Log(message);
}
}
}
void OnGUI()
{
if (isSelected == false) {
OnGUISelectHost();
}
else {
if (m_transport.isServer == true) {
OnGUIServer();
}
else {
OnGUIClient();
}
}
}
void OnGUISelectHost()
{
#if USE_TRANSPORT_TCP
if (GUI.Button (new Rect (20,40, 150,20), "Launch server.")) {
#else
if (GUI.Button (new Rect (20,40, 150,20), "Launch Listener.")) {
#endif
m_transport.StartServer(m_port, 1);
isSelected = true;
}
// 클라이언트를 선택했을 때 접속할 서버 주소를 입력합니다.
m_strings = GUI.TextField(new Rect(20, 100, 200, 20), m_strings);
#if USE_TRANSPORT_TCP
if (GUI.Button (new Rect (20,70,150,20), "Connect to server")) {
#else
if (GUI.Button (new Rect (20,70,150,20), "Connect to terminal")) {
#endif
m_transport.Connect(m_strings, m_port);
isSelected = true;
m_strings = "";
}
}
void OnGUIServer()
{
#if USE_TRANSPORT_TCP
if (GUI.Button (new Rect (20,60, 150,20), "Stop server")) {
#else
if (GUI.Button (new Rect (20,60, 150,20), "Stop Listener")) {
#endif
m_transport.StopServer();
isSelected = false;
m_strings = "";
}
}
void OnGUIClient()
{
// 클라이언트를 선택했을 때 접속할 서버의 주소를 입력합니다.
if (GUI.Button (new Rect (20,70,150,20), "Send message")) {
byte[] buffer = System.Text.Encoding.UTF8.GetBytes("Hellow, this is client.");
m_transport.Send(buffer, buffer.Length);
}
if (GUI.Button (new Rect (20,100, 150,20), "Disconnect")) {
m_transport.Disconnect();
isSelected = false;
m_strings = "";
}
}
}
\ No newline at end of file
{
"files.exclude":
{
"**/.DS_Store":true,
"**/.git":true,
"**/.gitignore":true,
"**/.gitmodules":true,
"**/*.booproj":true,
"**/*.pidb":true,
"**/*.suo":true,
"**/*.user":true,
"**/*.userprefs":true,
"**/*.unityproj":true,
"**/*.dll":true,
"**/*.exe":true,
"**/*.pdf":true,
"**/*.mid":true,
"**/*.midi":true,
"**/*.wav":true,
"**/*.gif":true,
"**/*.ico":true,
"**/*.jpg":true,
"**/*.jpeg":true,
"**/*.png":true,
"**/*.psd":true,
"**/*.tga":true,
"**/*.tif":true,
"**/*.tiff":true,
"**/*.3ds":true,
"**/*.3DS":true,
"**/*.fbx":true,
"**/*.FBX":true,
"**/*.lxo":true,
"**/*.LXO":true,
"**/*.ma":true,
"**/*.MA":true,
"**/*.obj":true,
"**/*.OBJ":true,
"**/*.asset":true,
"**/*.cubemap":true,
"**/*.flare":true,
"**/*.mat":true,
"**/*.meta":true,
"**/*.prefab":true,
"**/*.unity":true,
"build/":true,
"Build/":true,
"Library/":true,
"library/":true,
"obj/":true,
"Obj/":true,
"ProjectSettings/":true,
"temp/":true,
"Temp/":true
}
}
\ No newline at end of file
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1351082387170804}
m_IsPrefabParent: 1
--- !u!1 &1351082387170804
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224026180460817448}
- component: {fileID: 222343435350097842}
- component: {fileID: 114640140560748198}
- component: {fileID: 114312857566104806}
m_Layer: 5
m_Name: Comment
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1889659296805252
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224999107880086880}
- component: {fileID: 222081966344987208}
- component: {fileID: 114206746021236310}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &114206746021236310
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1889659296805252}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Sample Text
--- !u!114 &114312857566104806
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1351082387170804}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e3c2e0a12ace649978c3c197ab4726a6, type: 3}
m_Name:
m_EditorClassIdentifier:
commentText: {fileID: 114206746021236310}
--- !u!114 &114640140560748198
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1351082387170804}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &222081966344987208
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1889659296805252}
--- !u!222 &222343435350097842
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1351082387170804}
--- !u!224 &224026180460817448
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1351082387170804}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 224999107880086880}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224999107880086880
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1889659296805252}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224026180460817448}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
fileFormatVersion: 2
guid: b4721aef43e524b91936d391647d3ae1
timeCreated: 1517239050
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed. Click to expand it.
fileFormatVersion: 2
guid: 0964de8e148954ac9b3ff232fe86b110
timeCreated: 1517148581
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: c9304ab32d5a14ac0bb8f406e2082281
folderAsset: yes
timeCreated: 1517148587
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net;
public class Chat : MonoBehaviour
{
public TransportTCP m_transport;
public ChatText commentTextPrefab;
public Transform commentHolder;
public string m_hostAddress {get; set;}
private const int m_port = 50765;
private bool m_isServer = false;
// Use this for initialization
void Start()
{
IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
System.Net.IPAddress hostAddress = hostEntry.AddressList[0];
Debug.Log(hostEntry.HostName);
m_hostAddress = hostAddress.ToString ();
m_transport.onStateChanged += OnEventHandling;
}
IEnumerator UpdateChatting()
{
while(true)
{
byte[] buffer = new byte[1400];
int recvSize = m_transport.Receive(ref buffer, buffer.Length);
if (recvSize > 0) {
string message = System.Text.Encoding.UTF8.GetString(buffer);
Debug.Log("Recv data:" + message );
AddComment(message);
}
yield return null;
}
}
void Send(string message)
{
message = "[" + DateTime.Now.ToString("HH:mm:ss") + "] " + message;
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(message);
m_transport.Send(buffer, buffer.Length);
AddComment(message);
}
void AddComment(string message)
{
var newComment = Instantiate(commentTextPrefab,commentHolder);
newComment.SetUp(message);
}
void OnApplicationQuit() {
if (m_transport != null) {
if(m_isServer)
{
m_transport.StopServer();
}
else
{
m_transport.Disconnect();
}
}
}
public void OnEventHandling(NetEventState state)
{
switch (state.type) {
case NetEventType.Connect:
AddComment("접속");
break;
case NetEventType.Disconnect:
AddComment("접속 종료");
break;
}
}
public void CreateRoom()
{
m_transport.StartServer(m_port, 1);
m_isServer = true;
}
public void JoinChatRoom()
{
bool ret = m_transport.Connect(m_hostAddress, m_port);
if (ret) {
StartCoroutine("UpdateChatting");
}
else {
Debug.LogError("Failed");
}
}
public void Leave()
{
if (m_isServer == true) {
m_transport.StopServer();
}
else {
m_transport.Disconnect();
}
StopCoroutine("UpdateChatting");
}
}
fileFormatVersion: 2
guid: 7d91d3622aead48008aca0d637d4ad9b
timeCreated: 1517219122
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ChatText : MonoBehaviour {
public Text commentText;
public void SetUp(string message)
{
commentText.text = message;
}
}
fileFormatVersion: 2
guid: e3c2e0a12ace649978c3c197ab4726a6
timeCreated: 1517221132
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
// 이벤트 종류
public enum NetEventType
{
Connect = 0, // 연결 이벤트
Disconnect, // 끊기 이벤트
SendError, // 송신 오류
ReceiveError, // 수신 오류
}
// 이벤트 결과
public enum NetEventResult
{
Failure = -1, // 실패
Success = 0, // 성공
}
// 이벤트 상태 통지용 타입
public class NetEventState
{
public NetEventType type; // 이벤트 타입
public NetEventResult result; // 이벤트 결과
}
\ No newline at end of file
fileFormatVersion: 2
guid: 7a68fdeeae9b0445992ea9d05f42454e
timeCreated: 1517151676
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices; // https://msdn.microsoft.com/ko-kr/library/system.runtime.interopservices(v=vs.110).aspx
// 이 타입의 목적: 물흐르듯이 패킷을 쌓고 꺼내올수 있는 큐
public class PacketQueue
{
// 대응되는 패킷이 정확히 스트림에서 어디 인덱스에 존재하는지 지정
struct PacketInfo
{
public int offset; // 이 데이터가 기록되기 시작한 지점
public int size; // 이 데이터의 사이즈
}
// MemoryStream 은 데이터를 연속적으로 쌓고 빼낼수 있는 스트림 버퍼
// MemoryStream 은 디스크나 네트워크 연결이 아니라 메모리 상에 데이터를 저장하는 스트림 버퍼
// 데이터의 끊김이 없으므로 패킷으로는 다룰수 없다
private MemoryStream m_streamBuffer;
private List<PacketInfo> m_waitingPackets; // 아직 디큐하지 못하고 쌓인 패킷들
private int m_cursor = 0; // 버퍼가 채워져 커서가 밀려난 지점, 데이터를 채울때 여기서 부터 채우면 됨
private Object lockObj = new Object(); // 데드락 방지용 단순 참고자
// 초기화
public PacketQueue()
{
m_streamBuffer = new MemoryStream();
m_waitingPackets = new List<PacketInfo>();
}
// 큐에 바이트 데이터 추가
public int Enqueue(byte[] data, int size)
{
PacketInfo info = new PacketInfo();
info.offset = m_cursor; // 스트림내에서 이 데이터를 찾으려면 어디서 부터 읽으면 되는지 기록
info.size = size;
lock(lockObj) // 데드락 방지
{
// 패킷 저장 정보를 보존
m_waitingPackets.Add(info);
// 패킷 데이터를 추가
m_streamBuffer.Position = m_cursor; // 스트림의 위치를 마지막으로 갱신한 커서 위치로.
m_streamBuffer.Write(data,0,size); // 현재 위치에서 사이즈만큼 버퍼를 쌓기
m_streamBuffer.Flush(); // 적용
m_cursor += size; // 커서를 방금 추가한 패킷 만큼 오른쪽으로 이동
}
return size; // 추가된 데이터의 사이즈를 리턴
}
// 버퍼를 맡기면 채워서 넘겨줌
public int Dequeue(ref byte[] buffer, int size)
{
// 패킷 리스트에 남아있는게 없다면 종료
if(m_waitingPackets.Count <= 0)
{
return -1;
}
int recvSize = 0;
// 데드락 방지
lock(lockObj) {
// 가장 마지막에 추가된 패킷부터 가져온다
PacketInfo info = m_waitingPackets[0];
// 저장된 패킷 이상의 사이즈를 긁어올순 없음
int dataSize = Math.Min(size, info.size);
// 읽기 시작할 위치
m_streamBuffer.Position = info.offset;
// 현재 커서 위치에서 dataSize 만큼 오른쪽만큼 이동한 지점까지를 영역으로
// 데이터를 긁어와 입력으로 들어온 buffer 를 채움
recvSize = m_streamBuffer.Read(buffer, 0, dataSize);
// 패킷을 꺼냈으므로 꺼낸 패킷에 대한 패킷 기록을 리스트에서 삭제
if(recvSize > 0)
{
m_waitingPackets.RemoveAt(0);
}
// 모든 큐 데이터를 꺼냈을때는 스트림을 다시 제로포인트로 클리어해서 메모리를 절약
if(m_waitingPackets.Count == 0)
{
Clear();
m_cursor = 0;
}
}
return recvSize;
}
// 스트림버퍼의 커서를 초기화. 큐와 메모리 클리어
public void Clear()
{
// 스트림 버퍼의 남은 데이터를 긁어서
byte[] buffer = m_streamBuffer.GetBuffer();
// 해당 데이터를 정렬함
Array.Clear(buffer,0,buffer.Length);
// 스트림 버퍼의 커서와 길이를 제로로 되돌리기
m_streamBuffer.Position = 0;
m_streamBuffer.SetLength(0);
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 6f23052345bf649c485f9d14c8d027ae
timeCreated: 1517148877
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Net;
using System.Net.Sockets;
using System.Threading;
public class TransportTCP : MonoBehaviour
{
// 소켓 액세스 포인트들
// 리스닝 소켓
private Socket m_listner = null;
// 클라이언트의 접속을 받을 소켓
private Socket m_socket = null;
private PacketQueue m_sendQueue; // 송신 버퍼
private PacketQueue m_recvQueue; // 수신 버퍼
public bool isServer { get; private set;} // 서버 플래그
public bool isConnected {get; private set;} // 접속 플래그
// 이벤트 관련
// 이벤트 통지 델리게이트 타입 정의
public delegate void EventHandler(NetEventState state);
// 이벤트 핸들러
public event EventHandler onStateChanged;
// 스레드 관련 멤버 변수
// 스레드 실행 프래그
protected bool m_threadLoop = false;
protected Thread m_thread = null;
private static int s_mtu = 1400; // 한번에 읽을 데이터
// 초기화 페이즈: 큐 생성
void Awake()
{
m_sendQueue = new PacketQueue();
m_recvQueue = new PacketQueue();
}
// 서버로서 가동 (대기) 시작
public bool StartServer(int port, int connectionNum)
{
Debug.Log("Initiate Server!");
try
{
m_listner = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
// 대응 대역폭 지정
m_listner.Bind(new IPEndPoint(IPAddress.Any, port));
m_listner.Listen(connectionNum);
}
catch
{
Debug.Log("Server Failed!");
return false;
}
isServer = true;
bool success = LaunchThread();
return success;
}
// 서버로서 대기 종료
public void StopServer()
{
// 쓰레드 종료
m_threadLoop = false;
if (m_thread != null)
{
m_thread.Join(); // https://msdn.microsoft.com/ko-kr/library/95hbf2ta(v=vs.110).aspx
m_thread = null;
}
// 접속 종료
Disconnect();
if(m_listner != null)
{
m_listner.Close();
m_listner = null;
}
isServer = false;
Debug.Log("Server Stopped");
}
// 접속
public bool Connect(string address, int port)
{
Debug.Log("TransportTCP Connect Called");
// 이미 리스너 소켓이 선점되어 있다면
if (m_listner != null) {
return false;
}
bool ret = false;
try {
m_socket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
m_socket.NoDelay = true; // 소켓 지연시간 없음
m_socket.SendBufferSize = 0;
m_socket.Connect(address,port); // 소켓 연결 시작
// 커넥션 스레드 시작
ret = LaunchThread();
} catch {
// 실패했다면 소켓 파괴
m_socket = null;
}
if(ret == true)
{
isConnected = true;
Debug.Log("Connection Success");
}
else
{
isConnected = false;
Debug.Log("Connection Fail");
}
// 리스너가 존재한다면 통지
if(onStateChanged != null) {
NetEventState state = new NetEventState();
state.type = NetEventType.Connect;
state.result = (isConnected == true) ? NetEventResult.Success : NetEventResult.Failure;
Debug.Log("Event Handler Called");
}
return isConnected;
}
// 접속 종료
public void Disconnect()
{
isConnected = false;
if (m_socket != null)
{
m_socket.Shutdown(SocketShutdown.Both); // 쌍방향 소켓 연결 내리기
m_socket.Close(); // 소켓 종료
m_socket = null; // 소켓 파괴
}
// 리스터가 존재한다면 접속 종료를 공지
if (onStateChanged != null)
{
// 새로운 네트워크 상태 정보 생성후
NetEventState state = new NetEventState();
state.type = NetEventType.Disconnect;
state.result = NetEventResult.Success;
// 이벤트로 공지
onStateChanged(state);
}
}
// 송신 처리
// 큐에 데이터를 넣어놓으면 알아서 쓰레드가 빼가서 보내놓을거라능 ㅇㅅㅇ
public int Send(byte[] data, int size)
{
// 세이프티 체크
if(m_sendQueue == null)
{
return 0;
}
return m_sendQueue.Enqueue(data,size);
}
// 수신 처리
// 큐에 데이터를 넣어놓으면 알아서 쓰레드가 빼가서 보내놓을거라능 ㅇㅅㅇ
public int Receive(ref byte[] data, int size)
{
// 세이프티 체크
if(m_recvQueue == null)
{
return 0;
}
return m_recvQueue.Dequeue(ref data,size);
}
// 스레드 실행 함수.
// 목적: 돌려 놓으면 알아서 Send Queue 에 쌓아놓은 데이터는 보내주고
// 온 데이터는 Recv Queue 에 쌓아놓아줌
bool LaunchThread()
{
try {
// Dispatch용 스레드 시작.
m_threadLoop = true;
m_thread = new Thread(new ThreadStart(Dispatch));
m_thread.Start();
}
catch {
Debug.Log("Cannot launch thread.");
return false;
}
return true;
}
// 스레드를 통해 송수신을 처리해주는 실제 패킷큐 처리부
public void Dispatch()
{
Debug.Log("Distpach thread started.");
// 스레드 루프가 계속 돌아가는 동안
while(m_threadLoop)
{
//클라이언트의 접속을 기다림
AcceptClient();
if(m_socket != null && isConnected == true)
{
// 송신
DispatchSend();
// 수신
DispatchReceive();
}
// 실행 간격 5밀리 세컨드
Thread.Sleep(5);
}
Debug.Log("Dispatch thread ended");
}
void AcceptClient()
{
// 리스너가 클라이언트를 감지하고 준비됬다면
if(m_listner != null && m_listner.Poll(0, SelectMode.SelectRead))
{
// 클라이언트로부터 통신 소켓 지정
m_socket = m_listner.Accept();
isConnected = true;
Debug.Log("Connected from client");
}
}
void DispatchSend()
{
try{
// 데이터를 보낼 준비가 되있다면
if(m_socket.Poll(0,SelectMode.SelectWrite))
{
// 바이트 배열 생성
byte[] buffer = new byte[s_mtu];
// 전송 대기큐로부터 데이터를 빼내어 가져옴
int sendSize = m_sendQueue.Dequeue(ref buffer, buffer.Length);
// 보낼 데이터가 있는 동안 계속 송신-데이터 빼오기 반복
while(sendSize > 0) {
m_socket.Send(buffer, sendSize, SocketFlags.None);
sendSize = m_sendQueue.Dequeue(ref buffer, buffer.Length);
}
}
} catch {
return;
}
}
void DispatchReceive()
{
try{
// 읽을 데이터가 있으면
while(m_socket.Poll(0,SelectMode.SelectRead)) {
byte[] buffer = new byte[s_mtu];
int recvSize = m_socket.Receive(buffer,buffer.Length,SocketFlags.None);
if(recvSize == 0)
{
// 더이상 가져올 데이터가 없다면
Debug.Log("Diconnect recv from client.");
Disconnect();
}
else if (recvSize > 0) { // 데이터를 가져왔다면 리시브 큐에 적재해둠
m_recvQueue.Enqueue(buffer,recvSize);
}
}
}
catch {
return;
}
}
}
fileFormatVersion: 2
guid: cd5fc2b6c1dde473792533471913965f
timeCreated: 1517148595
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Net;
using System.Net.Sockets;
using System.Threading;
public class TransportUDP : MonoBehaviour
{
// 소켓 액세스 포인트들
// 클라이언트의 접속을 받을 소켓
private Socket m_socket = null;
private PacketQueue m_sendQueue; // 송신 버퍼
private PacketQueue m_recvQueue; // 수신 버퍼
public bool isServer { get; private set;} // 서버 플래그
public bool isConnected {get; private set;} // 접속 플래그
// 이벤트 관련
// 이벤트 통지 델리게이트 타입 정의
public delegate void EventHandler(NetEventState state);
// 이벤트 핸들러
public event EventHandler onStateChanged;
// 스레드 관련 멤버 변수
// 스레드 실행 프래그
protected bool m_threadLoop = false;
protected Thread m_thread = null;
private static int s_mtu = 1400; // 한번에 읽을 데이터
// 초기화 페이즈: 큐 생성
void Awake()
{
m_sendQueue = new PacketQueue();
m_recvQueue = new PacketQueue();
}
// 서버로서 가동 (대기) 시작
public bool StartServer(int port, int connectionNum)
{
Debug.Log("Initiate Server!");
try
{
// 소켓 생성후
m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Udp);
// 대응 대역폭 지정
m_socket.Bind(new IPEndPoint(IPAddress.Any, port));
}
catch
{
Debug.Log("Server Failed!");
return false;
}
isServer = true;
bool success = LaunchThread();
return success;
}
// 서버로서 대기 종료
public void StopServer()
{
// 쓰레드 종료
m_threadLoop = false;
if (m_thread != null)
{
m_thread.Join();
m_thread = null;
}
// 접속 종료
Disconnect();
isServer = false;
Debug.Log("Server Stopped");
}
public bool Connect(string address, int port)
{
Debug.Log("TransportUDP Connect Called");
// 이미 통신 소켓이 선점되어 있다면
if (m_socket != null) {
return false;
}
bool ret = false;
try {
m_socket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Udp);
m_socket.NoDelay = true; // 소켓 지연시간 없음
m_socket.Connect(address,port); // 소켓 연결 시작
// 커넥션 스레드 시작
ret = LaunchThread();
} catch {
// 실패했다면 소켓 파괴
m_socket = null;
}
if(ret == true)
{
isConnected = true;
Debug.Log("Connection Success");
}
else
{
isConnected = false;
Debug.Log("Connection Fail");
}
// 리스너가 존재한다면 통지
if(onStateChanged != null) {
NetEventState state = new NetEventState();
state.type = NetEventType.Connect;
state.result = (isConnected == true) ? NetEventResult.Success : NetEventResult.Failure;
Debug.Log("Event Handler Called");
}
return isConnected;
}
// 접속 종료
public void Disconnect()
{
isConnected = false;
if (m_socket != null)
{
m_socket.Shutdown(SocketShutdown.Both); // 쌍방향 소켓 연결 내리기
m_socket.Close(); // 소켓 종료
m_socket = null; // 소켓 파괴
}
// 리스터가 존재한다면 접속 종료를 공지
if (onStateChanged != null)
{
// 새로운 네트워크 상태 정보 생성후
NetEventState state = new NetEventState();
state.type = NetEventType.Disconnect;
state.result = NetEventResult.Success;
// 이벤트로 공지
onStateChanged(state);
}
}
// 송신 처리
// 큐에 데이터를 넣어놓으면 알아서 쓰레드가 빼가서 보내놓을거라능 ㅇㅅㅇ
public int Send(byte[] data, int size)
{
// 세이프티 체크
if(m_sendQueue == null)
{
return 0;
}
return m_sendQueue.Enqueue(data,size);
}
// 수신 처리
// 큐에 데이터를 넣어놓으면 알아서 쓰레드가 빼가서 보내놓을거라능 ㅇㅅㅇ
public int Receive(ref byte[] data, int size)
{
// 세이프티 체크
if(m_recvQueue == null)
{
return 0;
}
return m_recvQueue.Dequeue(ref data,size);
}
// 스레드 실행 함수.
// 목적: 돌려 놓으면 알아서 Send Queue 에 쌓아놓은 데이터는 보내주고
// 온 데이터는 Recv Queue 에 쌓아놓아줌
bool LaunchThread()
{
try {
// Dispatch용 스레드 시작.
m_threadLoop = true;
m_thread = new Thread(new ThreadStart(Dispatch));
m_thread.Start();
}
catch {
Debug.Log("Cannot launch thread.");
return false;
}
return true;
}
// 스레드를 통해 송수신을 처리해주는 실제 패킷큐 처리부
public void Dispatch()
{
Debug.Log("Distpach thread started.");
// 스레드 루프가 계속 돌아가는 동안
while(m_threadLoop)
{
if(m_socket != null && isConnected == true)
{
// 송신
DispatchSend();
// 수신
DispatchReceive();
}
// 실행 간격 5밀리 세컨드
Thread.Sleep(5);
}
Debug.Log("Dispatch thread ended");
}
void DispatchSend()
{
try{
// 데이터를 보낼 준비가 되있다면
if(m_socket.Poll(0,SelectMode.SelectWrite))
{
// 바이트 배열 생성
byte[] buffer = new byte[s_mtu];
// 전송 대기큐로부터 데이터를 빼내어 가져옴
int sendSize = m_sendQueue.Dequeue(ref buffer, buffer.Length);
// 보낼 데이터가 있는 동안 계속 송신-데이터 빼오기 반복
while(sendSize > 0) {
m_socket.Send(buffer, sendSize, SocketFlags.None);
sendSize = m_sendQueue.Dequeue(ref buffer, buffer.Length);
}
}
} catch {
return;
}
}
void DispatchReceive()
{
try{
// 읽을 데이터가 있으면
while(m_socket.Poll(0,SelectMode.SelectRead)) {
byte[] buffer = new byte[s_mtu];
int recvSize = m_socket.Receive(buffer,buffer.Length,SocketFlags.None);
if(recvSize == 0)
{
// 더이상 가져올 데이터가 없다면
Debug.Log("Diconnect recv from client.");
Disconnect();
}
else if (recvSize > 0) { // 데이터를 가져왔다면 리시브 큐에 적재해둠
m_recvQueue.Enqueue(buffer,recvSize);
}
}
}
catch {
return;
}
}
}
fileFormatVersion: 2
guid: a9312813559bd41e9b935e2418917ad0
timeCreated: 1517148687
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!11 &1
AudioManager:
m_ObjectHideFlags: 0
m_Volume: 1
Rolloff Scale: 1
Doppler Factor: 1
Default Speaker Mode: 2
m_SampleRate: 0
m_DSPBufferSize: 0
m_VirtualVoiceCount: 512
m_RealVoiceCount: 32
m_SpatializerPlugin:
m_AmbisonicDecoderPlugin:
m_DisableAudio: 0
m_VirtualizeEffects: 1
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!236 &1
ClusterInputManager:
m_ObjectHideFlags: 0
m_Inputs: []
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!55 &1
PhysicsManager:
m_ObjectHideFlags: 0
serializedVersion: 7
m_Gravity: {x: 0, y: -9.81, z: 0}
m_DefaultMaterial: {fileID: 0}
m_BounceThreshold: 2
m_SleepThreshold: 0.005
m_DefaultContactOffset: 0.01
m_DefaultSolverIterations: 6
m_DefaultSolverVelocityIterations: 1
m_QueriesHitBackfaces: 0
m_QueriesHitTriggers: 1
m_EnableAdaptiveForce: 0
m_ClothInterCollisionDistance: 0
m_ClothInterCollisionStiffness: 0
m_ContactsGeneration: 1
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
m_AutoSimulation: 1
m_AutoSyncTransforms: 1
m_ClothInterCollisionSettingsToggle: 0
m_ContactPairsMode: 0
m_BroadphaseType: 0
m_WorldBounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 250, y: 250, z: 250}
m_WorldSubdivisions: 8
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1045 &1
EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes: []
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!159 &1
EditorSettings:
m_ObjectHideFlags: 0
serializedVersion: 7
m_ExternalVersionControlSupport: Hidden Meta Files
m_SerializationMode: 2
m_LineEndingsForNewScripts: 1
m_DefaultBehaviorMode: 0
m_SpritePackerMode: 0
m_SpritePackerPaddingPower: 1
m_EtcTextureCompressorBehavior: 1
m_EtcTextureFastCompressor: 1
m_EtcTextureNormalCompressor: 2
m_EtcTextureBestCompressor: 4
m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp
m_ProjectGenerationRootNamespace:
m_UserGeneratedProjectSuffix:
m_CollabEditorSettings:
inProgressEnabled: 1
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!30 &1
GraphicsSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_Deferred:
m_Mode: 1
m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
m_DeferredReflections:
m_Mode: 1
m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0}
m_ScreenSpaceShadows:
m_Mode: 1
m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0}
m_LegacyDeferred:
m_Mode: 1
m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0}
m_DepthNormals:
m_Mode: 1
m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0}
m_MotionVectors:
m_Mode: 1
m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0}
m_LightHalo:
m_Mode: 1
m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0}
m_LensFlare:
m_Mode: 1
m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0}
m_AlwaysIncludedShaders:
- {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}
m_CustomRenderPipeline: {fileID: 0}
m_TransparencySortMode: 0
m_TransparencySortAxis: {x: 0, y: 0, z: 1}
m_DefaultRenderingPath: 1
m_DefaultMobileRenderingPath: 1
m_TierSettings: []
m_LightmapStripping: 0
m_FogStripping: 0
m_InstancingStripping: 0
m_LightmapKeepPlain: 1
m_LightmapKeepDirCombined: 1
m_LightmapKeepDynamicPlain: 1
m_LightmapKeepDynamicDirCombined: 1
m_LightmapKeepShadowMask: 1
m_LightmapKeepSubtractive: 1
m_FogKeepLinear: 1
m_FogKeepExp: 1
m_FogKeepExp2: 1
m_AlbedoSwatchInfos: []
m_LightsUseLinearIntensity: 0
m_LightsUseColorTemperature: 0
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!13 &1
InputManager:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Axes:
- serializedVersion: 3
m_Name: Horizontal
descriptiveName:
descriptiveNegativeName:
negativeButton: left
positiveButton: right
altNegativeButton: a
altPositiveButton: d
gravity: 3
dead: 0.001
sensitivity: 3
snap: 1
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Vertical
descriptiveName:
descriptiveNegativeName:
negativeButton: down
positiveButton: up
altNegativeButton: s
altPositiveButton: w
gravity: 3
dead: 0.001
sensitivity: 3
snap: 1
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire1
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left ctrl
altNegativeButton:
altPositiveButton: mouse 0
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire2
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left alt
altNegativeButton:
altPositiveButton: mouse 1
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire3
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left shift
altNegativeButton:
altPositiveButton: mouse 2
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Jump
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: space
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Mouse X
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0
sensitivity: 0.1
snap: 0
invert: 0
type: 1
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Mouse Y
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0
sensitivity: 0.1
snap: 0
invert: 0
type: 1
axis: 1
joyNum: 0
- serializedVersion: 3
m_Name: Mouse ScrollWheel
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0
sensitivity: 0.1
snap: 0
invert: 0
type: 1
axis: 2
joyNum: 0
- serializedVersion: 3
m_Name: Horizontal
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0.19
sensitivity: 1
snap: 0
invert: 0
type: 2
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Vertical
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0.19
sensitivity: 1
snap: 0
invert: 1
type: 2
axis: 1
joyNum: 0
- serializedVersion: 3
m_Name: Fire1
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: joystick button 0
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire2
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: joystick button 1
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire3
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: joystick button 2
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Jump
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: joystick button 3
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Submit
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: return
altNegativeButton:
altPositiveButton: joystick button 0
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Submit
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: enter
altNegativeButton:
altPositiveButton: space
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Cancel
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: escape
altNegativeButton:
altPositiveButton: joystick button 1
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!126 &1
NavMeshProjectSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
areas:
- name: Walkable
cost: 1
- name: Not Walkable
cost: 1
- name: Jump
cost: 2
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
- name:
cost: 1
m_LastAgentTypeID: -887442657
m_Settings:
- serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.75
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_SettingNames:
- Humanoid
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!149 &1
NetworkManager:
m_ObjectHideFlags: 0
m_DebugLevel: 0
m_Sendrate: 15
m_AssetToPrefab: {}
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!19 &1
Physics2DSettings:
m_ObjectHideFlags: 0
serializedVersion: 3
m_Gravity: {x: 0, y: -9.81}
m_DefaultMaterial: {fileID: 0}
m_VelocityIterations: 8
m_PositionIterations: 3
m_VelocityThreshold: 1
m_MaxLinearCorrection: 0.2
m_MaxAngularCorrection: 8
m_MaxTranslationSpeed: 100
m_MaxRotationSpeed: 360
m_BaumgarteScale: 0.2
m_BaumgarteTimeOfImpactScale: 0.75
m_TimeToSleep: 0.5
m_LinearSleepTolerance: 0.01
m_AngularSleepTolerance: 2
m_DefaultContactOffset: 0.01
m_AutoSimulation: 1
m_QueriesHitTriggers: 1
m_QueriesStartInColliders: 1
m_ChangeStopsCallbacks: 0
m_CallbacksOnDisable: 1
m_AutoSyncTransforms: 1
m_AlwaysShowColliders: 0
m_ShowColliderSleep: 1
m_ShowColliderContacts: 0
m_ShowColliderAABB: 0
m_ContactArrowScale: 0.2
m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412}
m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432}
m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745}
m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804}
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
This diff is collapsed. Click to expand it.
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!47 &1
QualitySettings:
m_ObjectHideFlags: 0
serializedVersion: 5
m_CurrentQuality: 5
m_QualitySettings:
- serializedVersion: 2
name: Very Low
pixelLightCount: 0
shadows: 0
shadowResolution: 0
shadowProjection: 1
shadowCascades: 1
shadowDistance: 15
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 0
blendWeights: 1
textureQuality: 1
anisotropicTextures: 0
antiAliasing: 0
softParticles: 0
softVegetation: 0
realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 0
vSyncCount: 0
lodBias: 0.3
maximumLODLevel: 0
particleRaycastBudget: 4
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 4
resolutionScalingFixedDPIFactor: 1
excludedTargetPlatforms: []
- serializedVersion: 2
name: Low
pixelLightCount: 0
shadows: 0
shadowResolution: 0
shadowProjection: 1
shadowCascades: 1
shadowDistance: 20
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 0
blendWeights: 2
textureQuality: 0
anisotropicTextures: 0
antiAliasing: 0
softParticles: 0
softVegetation: 0
realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 0
vSyncCount: 0
lodBias: 0.4
maximumLODLevel: 0
particleRaycastBudget: 16
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 4
resolutionScalingFixedDPIFactor: 1
excludedTargetPlatforms: []
- serializedVersion: 2
name: Medium
pixelLightCount: 1
shadows: 1
shadowResolution: 0
shadowProjection: 1
shadowCascades: 1
shadowDistance: 20
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 0
blendWeights: 2
textureQuality: 0
anisotropicTextures: 1
antiAliasing: 0
softParticles: 0
softVegetation: 0
realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 0
vSyncCount: 1
lodBias: 0.7
maximumLODLevel: 0
particleRaycastBudget: 64
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 4
resolutionScalingFixedDPIFactor: 1
excludedTargetPlatforms: []
- serializedVersion: 2
name: High
pixelLightCount: 2
shadows: 2
shadowResolution: 1
shadowProjection: 1
shadowCascades: 2
shadowDistance: 40
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
blendWeights: 2
textureQuality: 0
anisotropicTextures: 1
antiAliasing: 0
softParticles: 0
softVegetation: 1
realtimeReflectionProbes: 1
billboardsFaceCameraPosition: 1
vSyncCount: 1
lodBias: 1
maximumLODLevel: 0
particleRaycastBudget: 256
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 4
resolutionScalingFixedDPIFactor: 1
excludedTargetPlatforms: []
- serializedVersion: 2
name: Very High
pixelLightCount: 3
shadows: 2
shadowResolution: 2
shadowProjection: 1
shadowCascades: 2
shadowDistance: 70
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
blendWeights: 4
textureQuality: 0
anisotropicTextures: 2
antiAliasing: 2
softParticles: 1
softVegetation: 1
realtimeReflectionProbes: 1
billboardsFaceCameraPosition: 1
vSyncCount: 1
lodBias: 1.5
maximumLODLevel: 0
particleRaycastBudget: 1024
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 4
resolutionScalingFixedDPIFactor: 1
excludedTargetPlatforms: []
- serializedVersion: 2
name: Ultra
pixelLightCount: 4
shadows: 2
shadowResolution: 2
shadowProjection: 1
shadowCascades: 4
shadowDistance: 150
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
blendWeights: 4
textureQuality: 0
anisotropicTextures: 2
antiAliasing: 2
softParticles: 1
softVegetation: 1
realtimeReflectionProbes: 1
billboardsFaceCameraPosition: 1
vSyncCount: 1
lodBias: 2
maximumLODLevel: 0
particleRaycastBudget: 4096
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 4
resolutionScalingFixedDPIFactor: 1
excludedTargetPlatforms: []
m_PerPlatformDefaultQuality:
Android: 2
Nintendo 3DS: 5
Nintendo Switch: 5
PS4: 5
PSM: 5
PSP2: 2
Standalone: 5
Tizen: 2
WebGL: 3
WiiU: 5
Windows Store Apps: 5
XboxOne: 5
iPhone: 2
tvOS: 2
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!78 &1
TagManager:
serializedVersion: 2
tags: []
layers:
- Default
- TransparentFX
- Ignore Raycast
-
- Water
- UI
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
m_SortingLayers:
- name: Default
uniqueID: 0
locked: 0
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!5 &1
TimeManager:
m_ObjectHideFlags: 0
Fixed Timestep: 0.02
Maximum Allowed Timestep: 0.33333334
m_TimeScale: 1
Maximum Particle Timestep: 0.03
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!310 &1
UnityConnectSettings:
m_ObjectHideFlags: 0
m_Enabled: 0
m_TestMode: 0
m_TestEventUrl:
m_TestConfigUrl:
m_TestInitMode: 0
CrashReportingSettings:
m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes
m_NativeEventUrl: https://perf-events.cloud.unity3d.com/symbolicate
m_Enabled: 0
m_CaptureEditorExceptions: 1
UnityPurchasingSettings:
m_Enabled: 0
m_TestMode: 0
UnityAnalyticsSettings:
m_Enabled: 0
m_InitializeOnStartup: 1
m_TestMode: 0
m_TestEventUrl:
m_TestConfigUrl:
UnityAdsSettings:
m_Enabled: 0
m_InitializeOnStartup: 1
m_TestMode: 0
m_IosGameId:
m_AndroidGameId:
m_GameIds: {}
m_GameId:
PerformanceReportingSettings:
m_Enabled: 0