資源簡介
Unity Editor Console Pro 擴展點擊定位到外部工程

代碼片段和文件信息
using?UnityEngine;
using?System;
using?System.Net;
using?System.Collections.Generic;
namespace?FlyingWormConsole3
{
public?class?ConsoleProRemoteServer?:?MonoBehaviour
{
#if?!NETFX_CORE?&&?!UNITY_WEBPlayer?&&?!UNITY_WP8?&&?!UNITY_METRO
public?class?HTTPContext
{
public?HttpListenerContext?context;
public?string?path;
public?string?Command
{
get
{
return?WWW.UnEscapeURL(context.Request.Url.AbsolutePath);
}
}
public?HttpListenerRequest?Request
{
get
{
return?context.Request;
}
}
public?HttpListenerResponse?Response
{
get
{
return?context.Response;
}
}
public?HTTPContext(HttpListenerContext?inContext)
{
context?=?inContext;
}
public?void?RespondWithString(string?inString)
{
Response.StatusDescription?=?“OK“;
Response.StatusCode?=?(int)HttpStatusCode.OK;
if?(!string.IsNullOrEmpty(inString))
{
Response.ContentType?=?“text/plain“;
byte[]?buffer?=?System.Text.Encoding.UTF8.GetBytes(inString);
Response.ContentLength64?=?buffer.Length;
Response.OutputStream.Write(buffer0buffer.Length);
}
}
}
[System.SerializableAttribute]
public?class?QueuedLog
{
public?string?message;
public?string?stackTrace;
public?LogType?type;
}
public?int?port?=?51000;
private?static?HttpListener?listener?=?new?HttpListener();
[NonSerializedAttribute]
public?List?logs?=?new?List();
void?Awake()
{
DontDestroyonload(gameobject);
Debug.Log(“Starting?Console?Pro?Server?on?port?:?“?+?port);
listener.Prefixes.Add(“http://*:“+port+“/“);
listener.Start();
listener.BeginGetContext(ListenerCallback?null);
}
#if?UNITY_4_0?||?UNITY_4_0_1?||?UNITY_4_1?||?UNITY_4_2?||?UNITY_4_3?||?UNITY_4_5?||?UNITY_4_6
void?OnEnable()
{
Application.RegisterLogCallback(LogCallback);
}
void?Update()
{
Application.RegisterLogCallback(LogCallback);
}
void?LateUpdate()
{
Application.RegisterLogCallback(LogCallback);
}
void?OnDisable()
{
Application.RegisterLogCallback(null);
}
#else
void?OnEnable()
{
Application.logMessageReceived?+=?LogCallback;
}
void?OnDisable()
{
Application.logMessageReceived?-=?LogCallback;
}
#endif
public?void?LogCallback(string?logString?string?stackTrace?LogType?type)
{
if(!logString.StartsWith(“CPIGNORE“))
{
QueueLog(logString?stackTrace?type);
}
}
void?QueueLog(string?logString?string?stackTrace?LogType?type)
{
logs.Add(new?QueuedLog()?{?message?=?logString?stackTrace?=?stackTrace?type?=?type?}?);
}
void?ListenerCallback(IAsyncResult?result)
{
HTTPContext?context?=?new?HTTPContext(listener.EndGetContext(result));
HandleRequest(context);
listener.BeginGetContext(new?AsyncCallback(ListenerCallback)?null);
}
void?HandleRequest(HTTPContext?context)
{
//?Debug.LogError(“HANDLE?“?+?context.Request.HttpMethod);
//?Debug.LogError(“HANDLE?“?+?context.path);
bool?foundCommand?=?false;
switch(context.Command)
{
case?“/NewLogs
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3703??2015-07-28?04:44??ConsolePro\ConsoleProRemoteServer.cs
?????文件????????264??2015-07-28?04:44??ConsolePro\ConsoleProRemoteServer.cs.me
?????文件?????182784??2016-11-19?17:22??ConsolePro\Editor\ConsolePro.Editor.dll
?????文件????????467??2016-11-15?20:23??ConsolePro\Editor\ConsolePro.Editor.dll.me
?????文件????????191??2016-11-12?11:26??ConsolePro\Editor.me
?????文件???????2954??2015-07-28?04:44??ConsolePro\Readme.txt
?????文件????????179??2015-07-28?04:44??ConsolePro\Readme.txt.me
?????目錄??????????0??2016-11-19?17:22??ConsolePro\Editor
?????目錄??????????0??2016-11-12?11:26??ConsolePro
-----------?---------??----------?-----??----
???????????????190542????????????????????9
評論
共有 條評論