├── .gitattributes ├── .gitignore ├── Assets ├── CommandDemo.unity ├── CommandDemo.unity.meta ├── Editor.meta ├── Editor │ ├── UpgradeVSProject.cs │ └── UpgradeVSProject.cs.meta ├── Scripts.meta ├── Scripts │ ├── ConsoleInput.cs │ ├── ConsoleInput.cs.meta │ ├── ConsoleWindow.cs │ ├── ConsoleWindow.cs.meta │ ├── EventSys.meta │ ├── EventSys │ │ ├── NotificationManager.cs │ │ ├── NotificationManager.cs.meta │ │ ├── NotificationType.cs │ │ ├── NotificationType.cs.meta │ │ ├── SingletonProvider.cs │ │ ├── SingletonProvider.cs.meta │ │ ├── main.cs │ │ └── main.cs.meta │ ├── ScriptDemo.meta │ ├── ScriptDemo │ │ ├── ControlMove.cs │ │ ├── ControlMove.cs.meta │ │ ├── PrintOnConsole.cs │ │ └── PrintOnConsole.cs.meta │ ├── ServerConsole.cs │ ├── ServerConsole.cs.meta │ ├── Tes.cs │ └── Tes.cs.meta ├── TestDemo.unity ├── TestDemo.unity.meta ├── UnityVS.meta └── UnityVS │ ├── Editor.meta │ └── Editor │ ├── SyntaxTree.VisualStudio.Unity.Bridge.dll │ ├── SyntaxTree.VisualStudio.Unity.Bridge.dll.meta │ ├── SyntaxTree.VisualStudio.Unity.Messaging.dll │ ├── SyntaxTree.VisualStudio.Unity.Messaging.dll.meta │ ├── UnityVS.VersionSpecific.dll │ └── UnityVS.VersionSpecific.dll.meta ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityAdsSettings.asset └── UnityConnectSettings.asset ├── README.md ├── TagforGithub ├── github添加标签.png ├── 弹出信息.png ├── 当前版本添加.png ├── 显示所有tag.png └── 显示旧提交信息.png ├── UnityVS.TestConsole1113.CSharp.Editor.csproj ├── UnityVS.TestConsole1113.CSharp.csproj ├── UnityVS.TestConsole1113.sln ├── image ├── 0.png ├── 1.png └── 2.png └── versionpath └── unityConsole添加按键命令.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | 8 | # Autogenerated VS/MD/Consulo solution and project files 9 | ExportedObj/ 10 | .consulo/ 11 | *.csproj 12 | *.unityproj 13 | *.sln 14 | *.suo 15 | *.tmp 16 | *.user 17 | *.userprefs 18 | *.pidb 19 | *.booproj 20 | *.svd 21 | 22 | 23 | # Unity3D generated meta files 24 | *.pidb.meta 25 | 26 | # Unity3D Generated File On Crash Reports 27 | sysinfo.txt 28 | 29 | # Builds 30 | *.apk 31 | *.unitypackage -------------------------------------------------------------------------------- /Assets/CommandDemo.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/Assets/CommandDemo.unity -------------------------------------------------------------------------------- /Assets/CommandDemo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68b89d27a0ebadb489be774db15335a7 3 | timeCreated: 1487124312 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 424e444ae0e082d4daadf8056800a517 3 | folderAsset: yes 4 | timeCreated: 1447403598 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Editor/UpgradeVSProject.cs: -------------------------------------------------------------------------------- 1 | //#define USE_UPGRADEVS 2 | using UnityEngine; 3 | using System.Collections; 4 | using UnityEditor; 5 | using System.IO; 6 | using System.Text.RegularExpressions; 7 | 8 | class UpgradeVSProject : AssetPostprocessor 9 | { 10 | #if USE_UPGRADEVS 11 | private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) 12 | { 13 | string currentDir = Directory.GetCurrentDirectory(); 14 | string[] slnFile = Directory.GetFiles(currentDir, "*.sln"); 15 | string[] csprojFile = Directory.GetFiles(currentDir, "*.csproj"); 16 | 17 | bool hasChanged = false; 18 | if (slnFile != null) 19 | { 20 | for (int i = 0; i < slnFile.Length; i++) 21 | { 22 | if (ReplaceInFile(slnFile[i], "Format Version 10.00", "Format Version 11.00")) 23 | hasChanged = true; 24 | } 25 | } 26 | 27 | if (csprojFile != null) 28 | { 29 | for (int i = 0; i < csprojFile.Length; i++) 30 | { 31 | if (ReplaceInFile(csprojFile[i], "ToolsVersion=\"3.5\"", "ToolsVersion=\"4.0\"")) 32 | hasChanged = true; 33 | 34 | if (ReplaceInFile(csprojFile[i], "v3.5", "v4.0")) 35 | hasChanged = true; 36 | } 37 | } 38 | 39 | if (hasChanged) 40 | { 41 | Debug.LogWarning("Project is now upgraded to Visual Studio 2010 Solution!"); 42 | } 43 | else 44 | { 45 | Debug.Log("Project-version has not changed..."); 46 | } 47 | } 48 | 49 | static private bool ReplaceInFile(string filePath, string searchText, string replaceText) 50 | { 51 | StreamReader reader = new StreamReader(filePath); 52 | string content = reader.ReadToEnd(); 53 | reader.Close(); 54 | 55 | if (content.IndexOf(searchText) != -1) 56 | { 57 | content = Regex.Replace(content, searchText, replaceText); 58 | StreamWriter writer = new StreamWriter(filePath); 59 | writer.Write(content); 60 | writer.Close(); 61 | 62 | return true; 63 | } 64 | 65 | return false; 66 | } 67 | #endif 68 | } 69 | -------------------------------------------------------------------------------- /Assets/Editor/UpgradeVSProject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1091865404c063e4ca89e1a787f41456 3 | timeCreated: 1447403619 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 051bb2ec35337e84eb65f5cfd783cd5e 3 | folderAsset: yes 4 | timeCreated: 1447383309 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scripts/ConsoleInput.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections; 4 | using System.Runtime.InteropServices; 5 | using System.IO; 6 | 7 | namespace ConsoleTestWindows 8 | { 9 | public class ConsoleInput 10 | { 11 | //public delegate void InputText( string strInput ); 12 | public event System.Action OnInputText; 13 | public string inputString; 14 | 15 | public void ClearLine() 16 | { 17 | //System.Text.Encoding test = Console.InputEncoding; 18 | Console.CursorLeft = 0; 19 | Console.Write( new String( ' ', Console.BufferWidth ) ); 20 | Console.CursorTop--; 21 | Console.CursorLeft = 0; 22 | } 23 | 24 | public void RedrawInputLine() 25 | { 26 | if ( Console.CursorLeft > 0 ) 27 | ClearLine(); 28 | if ( inputString.Length == 0 ) return; 29 | 30 | System.Console.ForegroundColor = ConsoleColor.Green; 31 | try 32 | { 33 | System.Console.Write(inputString); 34 | } 35 | catch (System.Exception ex) 36 | { 37 | //System.Console.WriteLine("Error: " + ex.Message); 38 | } 39 | } 40 | 41 | internal void OnBackspace() 42 | { 43 | int inputLength = inputString.Length; 44 | if (inputLength <= 0 ) return; 45 | if (inputLength == 1) 46 | { 47 | inputString = ""; 48 | } 49 | else 50 | { 51 | inputString = inputString.Substring(0, inputLength - 1); 52 | } 53 | RedrawInputLine(); 54 | } 55 | 56 | internal void OnEscape() 57 | { 58 | ClearLine(); 59 | inputString = ""; 60 | } 61 | 62 | internal void OnEnter() 63 | { 64 | ClearLine(); 65 | DefaultCommand(inputString); 66 | System.Console.ForegroundColor = ConsoleColor.Green; 67 | try 68 | { 69 | System.Console.WriteLine("> " + inputString); 70 | } 71 | catch (System.Exception ex) 72 | { 73 | //Console.WriteLine(ex.Message); 74 | } 75 | 76 | var strtext = inputString; 77 | inputString = ""; 78 | 79 | if ( OnInputText != null ) 80 | { 81 | OnInputText( strtext ); 82 | } 83 | } 84 | 85 | public void Update() 86 | { 87 | if ( !Console.KeyAvailable ) return; 88 | var key = Console.ReadKey(); 89 | 90 | if ( key.Key == ConsoleKey.Enter ) 91 | { 92 | OnEnter(); 93 | return; 94 | } 95 | 96 | if ( key.Key == ConsoleKey.Backspace ) 97 | { 98 | OnBackspace(); 99 | return; 100 | } 101 | 102 | if ( key.Key == ConsoleKey.Escape ) 103 | { 104 | OnEscape(); 105 | return; 106 | } 107 | 108 | if ( key.KeyChar != '\u0000' ) 109 | { 110 | inputString += key.KeyChar; 111 | RedrawInputLine(); 112 | return; 113 | } 114 | } 115 | 116 | /// 117 | /// add command line 118 | /// 119 | /// 120 | internal void DefaultCommand(string inputStr) 121 | { 122 | if (inputStr.Length == 0) return; 123 | 124 | switch (inputStr.ToLower()) 125 | { 126 | case "clear": 127 | System.Console.Clear(); 128 | break; 129 | case "exit": 130 | ServerConsole.SetIshowWindow(false); 131 | break; 132 | default: 133 | break; 134 | } 135 | 136 | } 137 | } 138 | } -------------------------------------------------------------------------------- /Assets/Scripts/ConsoleInput.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fdbdd9439ddd94c4090460783581c1d3 3 | timeCreated: 1447383230 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/ConsoleWindow.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections; 4 | using System.Runtime.InteropServices; 5 | using System.IO; 6 | 7 | namespace ConsoleTestWindows 8 | { 9 | /// 10 | /// Creates a console window that actually works in Unity 11 | /// You should add a script that redirects output using Console.Write to write to it. 12 | /// 13 | public class ConsoleWindow 14 | { 15 | TextWriter oldOutput; 16 | 17 | public void Initialize() 18 | { 19 | // 20 | // Attach to any existing consoles we have 21 | // failing that, create a new one. 22 | // 23 | if ( !AttachConsole( 0x0ffffffff ) ) 24 | { 25 | AllocConsole(); 26 | } 27 | 28 | oldOutput = Console.Out; 29 | 30 | try 31 | { 32 | IntPtr stdHandle = GetStdHandle( STD_OUTPUT_HANDLE ); 33 | Microsoft.Win32.SafeHandles.SafeFileHandle safeFileHandle = new Microsoft.Win32.SafeHandles.SafeFileHandle( stdHandle, true ); 34 | FileStream fileStream = new FileStream(safeFileHandle, FileAccess.Write); 35 | System.Text.Encoding encoding = System.Text.Encoding.ASCII; 36 | StreamWriter standardOutput = new StreamWriter( fileStream, encoding ); 37 | standardOutput.AutoFlush = true; 38 | Console.SetOut( standardOutput ); 39 | } 40 | catch ( System.Exception e ) 41 | { 42 | Debug.Log( "Couldn't redirect output: " + e.Message ); 43 | } 44 | } 45 | 46 | public void Shutdown() 47 | { 48 | Console.SetOut( oldOutput ); 49 | FreeConsole(); 50 | } 51 | 52 | public void SetTitle( string strName ) 53 | { 54 | SetConsoleTitle( strName ); 55 | } 56 | 57 | private const int STD_OUTPUT_HANDLE = -11; 58 | 59 | [DllImport( "kernel32.dll", SetLastError = true )] 60 | static extern bool AttachConsole( uint dwProcessId ); 61 | 62 | [DllImport( "kernel32.dll", SetLastError = true )] 63 | static extern bool AllocConsole(); 64 | 65 | [DllImport( "kernel32.dll", SetLastError = true )] 66 | static extern bool FreeConsole(); 67 | 68 | [DllImport( "kernel32.dll", EntryPoint = "GetStdHandle", SetLastError = true, CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall )] 69 | private static extern IntPtr GetStdHandle( int nStdHandle ); 70 | 71 | [DllImport( "kernel32.dll" )] 72 | static extern bool SetConsoleTitle( string lpConsoleTitle ); 73 | } 74 | } -------------------------------------------------------------------------------- /Assets/Scripts/ConsoleWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d5810f9c677bd6745bfa7bbc3412ec08 3 | timeCreated: 1447383229 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/EventSys.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2dd7fa4572a48ed438faf2828d5e8771 3 | folderAsset: yes 4 | timeCreated: 1487130201 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scripts/EventSys/NotificationManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace SLQJ 6 | { 7 | /// 8 | /// 消息分发,解耦 9 | /// 10 | public class NotificationManager 11 | { 12 | public static NotificationManager Instance { get { return SingletonProvider.Instance; } } 13 | 14 | public delegate void MsgCallback(MessageObject eb); 15 | /// 16 | /// 回调队列 17 | /// 18 | private Dictionary> registedCallbacks = new Dictionary>(); 19 | /// 20 | /// 延迟消息队列 21 | /// 22 | private readonly List delayedNotifyMsgs = new List(); 23 | /// 24 | /// 主消息队列 25 | /// 26 | private readonly List realCallbacks = new List(); 27 | private static bool isInCalling = false; 28 | 29 | public void Init() 30 | { 31 | 32 | } 33 | 34 | public void Update() 35 | { 36 | lock (this) 37 | { 38 | if (realCallbacks.Count == 0) 39 | { 40 | //主消息隊列處理完時,加入延時消息到主消息列表 41 | foreach (MessageObject eb in delayedNotifyMsgs) 42 | { 43 | realCallbacks.Add(eb); 44 | } 45 | delayedNotifyMsgs.Clear(); 46 | return; 47 | } 48 | //調用主消息處理隊列 49 | isInCalling = true; 50 | foreach (MessageObject eb in realCallbacks) 51 | { 52 | if (registedCallbacks.ContainsKey(eb.MsgName)) 53 | { 54 | for (int i = 0; i < registedCallbacks[eb.MsgName].Count; i++) 55 | { 56 | MsgCallback ecb = registedCallbacks[eb.MsgName][i]; 57 | if (ecb == null) 58 | { 59 | continue; 60 | } 61 | #if UNITY_EDITOR 62 | ecb(eb); 63 | #else 64 | try 65 | { 66 | ecb(eb); 67 | } 68 | catch (Exception e) 69 | { 70 | Debug.LogError("CallbackError:" + eb.MsgName + " : " + e.ToString()); 71 | } 72 | #endif 73 | } 74 | } 75 | else 76 | { 77 | Debug.Log("MSG_ALREADY_DELETED:" + eb.MsgName); 78 | } 79 | 80 | } 81 | realCallbacks.Clear(); 82 | } 83 | isInCalling = false; 84 | } 85 | 86 | public void Reset() 87 | { 88 | Dictionary> systemMsg = new Dictionary>(); 89 | foreach (KeyValuePair> item in this.registedCallbacks) 90 | { 91 | if (item.Key.StartsWith("_")) 92 | { 93 | systemMsg.Add(item.Key, item.Value); 94 | } 95 | } 96 | this.registedCallbacks = systemMsg; 97 | } 98 | 99 | public void Destroy() 100 | { 101 | Reset(); 102 | } 103 | 104 | /// 105 | /// 订阅消息 106 | /// 107 | /// 108 | /// 109 | public void Subscribe(string msgName, MsgCallback msgCallback) 110 | { 111 | lock (this) 112 | { 113 | if (!registedCallbacks.ContainsKey(msgName)) 114 | { 115 | registedCallbacks.Add(msgName, new List()); 116 | } 117 | { 118 | //防止重复订阅消息回调 119 | List list = registedCallbacks[msgName]; 120 | for (int i = 0; i < list.Count; i++) 121 | { 122 | if (list[i].Equals(msgCallback)) 123 | { 124 | return; 125 | } 126 | } 127 | list.Add(msgCallback); 128 | } 129 | 130 | } 131 | } 132 | /// 133 | /// 取消订阅 134 | /// 135 | /// 136 | /// 137 | public void UnSubscribe(string msgName, MsgCallback msgCallback) 138 | { 139 | lock (this) 140 | { 141 | if (!registedCallbacks.ContainsKey(msgName)) 142 | { 143 | return; 144 | } 145 | //Debug.Log(msgName + ":-s-" + registedCallbacks[msgName].Count); 146 | registedCallbacks[msgName].Remove(msgCallback); 147 | //Debug.Log(msgName + ":-e-" + registedCallbacks[msgName].Count); 148 | } 149 | } 150 | 151 | public void PrintMsg() 152 | { 153 | string content = ""; 154 | foreach (KeyValuePair> registedCallback in registedCallbacks) 155 | { 156 | int total = registedCallback.Value.Count; 157 | if (total > 0) 158 | { 159 | content += registedCallback.Key + ":" + total + "\n"; 160 | for (int i = 0; i < total; i++) 161 | { 162 | content += "\t" + registedCallback.Value[i].Method.Name + "--" + registedCallback.Value[i].Target + "\n"; 163 | } 164 | } 165 | } 166 | } 167 | 168 | /// 169 | /// 派发消息 170 | /// 171 | /// 172 | /// 173 | public void Notify(string MsgName, params object[] MsgParam) 174 | { 175 | 176 | object msgValueParam = null; 177 | if (MsgParam != null) 178 | { 179 | if (MsgParam.Length == 1) 180 | { 181 | msgValueParam = MsgParam[0]; 182 | } 183 | else 184 | { 185 | msgValueParam = MsgParam; 186 | } 187 | } 188 | 189 | 190 | lock (this) 191 | { 192 | if (!registedCallbacks.ContainsKey(MsgName)) 193 | { 194 | return; 195 | } 196 | if (isInCalling) 197 | { 198 | delayedNotifyMsgs.Add(new MessageObject(MsgName, msgValueParam)); 199 | } 200 | else 201 | { 202 | realCallbacks.Add(new MessageObject(MsgName, msgValueParam)); 203 | } 204 | } 205 | } 206 | } 207 | 208 | public class MessageObject 209 | { 210 | public object MsgValue; 211 | public string MsgName; 212 | 213 | public MessageObject() 214 | { 215 | MsgName = this.GetType().FullName; 216 | } 217 | 218 | public MessageObject(string msgName, object ev) 219 | { 220 | MsgValue = ev; 221 | MsgName = msgName; 222 | } 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /Assets/Scripts/EventSys/NotificationManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca883b35cbdb5c84db2368d5bb651ce3 3 | timeCreated: 1482482070 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/EventSys/NotificationType.cs: -------------------------------------------------------------------------------- 1 | namespace SLQJ 2 | { 3 | //消息常量 4 | public enum NotificationType 5 | { 6 | Gun_Fire, // 开枪 7 | Gun_KeyUp, // 抬起 8 | Throw_Bomb, // 扔雷 9 | Gathering_Stength, // 蓄力 10 | Controller_Change, // 手柄左右交換 11 | SetGesture_RecongizeState, 12 | Gesture_Recongnize, 13 | Gesture_Recongnize_Result, 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /Assets/Scripts/EventSys/NotificationType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e664e96df5629684489f5a84e1a91797 3 | timeCreated: 1482482070 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/EventSys/SingletonProvider.cs: -------------------------------------------------------------------------------- 1 | /// 2 | /// 生成单例 3 | /// 4 | /// 5 | public class SingletonProvider where T : class, new() 6 | { 7 | SingletonProvider() 8 | { 9 | } 10 | 11 | public static T Instance 12 | { 13 | get 14 | { 15 | if (SingletonCreator.Instance == null) 16 | { 17 | SingletonCreator.Instance = new T(); 18 | } 19 | return SingletonCreator.Instance; 20 | } 21 | } 22 | 23 | public static void Clear() 24 | { 25 | SingletonCreator.Instance = null; 26 | } 27 | 28 | class SingletonCreator 29 | { 30 | static SingletonCreator() 31 | { 32 | } 33 | 34 | internal static T Instance = new T(); 35 | } 36 | } -------------------------------------------------------------------------------- /Assets/Scripts/EventSys/SingletonProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec0d38b58935beb4cbbdcffd1addd85d 3 | timeCreated: 1482482637 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/EventSys/main.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using SLQJ; 4 | 5 | public class main : MonoBehaviour { 6 | 7 | // Use this for initialization 8 | void Awake () 9 | { 10 | NotificationManager.Instance.Init(); 11 | } 12 | 13 | // Update is called once per frame 14 | void Update () 15 | { 16 | NotificationManager.Instance.Update(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Assets/Scripts/EventSys/main.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4efde760c958c8848aafcf518cc492a9 3 | timeCreated: 1482482830 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/ScriptDemo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8542c32b94edc7e43828bbdd07731bca 3 | folderAsset: yes 4 | timeCreated: 1487130201 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scripts/ScriptDemo/ControlMove.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using SLQJ; 4 | 5 | public partial class ControlMove : MonoBehaviour 6 | { 7 | public float movespeed = 10f; 8 | 9 | private Transform transf; 10 | private float horizontalDirection; 11 | private float verticalDirection; 12 | 13 | // Use this for initialization 14 | void Start () 15 | { 16 | transf = this.transform; 17 | string messName = GETNAME(new { this.movespeed }); 18 | NotificationManager.Instance.Subscribe(messName, changeVarible); 19 | } 20 | 21 | // Update is called once per frame 22 | void Update () 23 | { 24 | horizontalDirection = 0; 25 | verticalDirection = 0; 26 | if (Input.GetKey(KeyCode.A)) 27 | { 28 | horizontalDirection = -1; 29 | } 30 | 31 | if (Input.GetKey(KeyCode.D)) 32 | { 33 | horizontalDirection = 1; 34 | } 35 | 36 | if (Input.GetKey(KeyCode.S)) 37 | { 38 | verticalDirection = -1; 39 | } 40 | 41 | if (Input.GetKey(KeyCode.W)) 42 | { 43 | verticalDirection = 1; 44 | } 45 | 46 | transf.position += transf.right * Time.deltaTime * movespeed * horizontalDirection; 47 | transf.position += transf.up * Time.deltaTime * movespeed * verticalDirection; 48 | } 49 | } 50 | 51 | public partial class ControlMove 52 | { 53 | void changeVarible(MessageObject ojb) 54 | { 55 | float speed = (float)ojb.MsgValue; 56 | movespeed = speed; 57 | } 58 | 59 | public static string GETNAME(T myInput) where T : class 60 | { 61 | if (myInput == null) 62 | return string.Empty; 63 | 64 | return typeof(T).GetProperties()[0].Name; 65 | } 66 | } -------------------------------------------------------------------------------- /Assets/Scripts/ScriptDemo/ControlMove.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f86547755f4b62e40bb46c9d76817635 3 | timeCreated: 1487124986 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/ScriptDemo/PrintOnConsole.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class PrintOnConsole : MonoBehaviour { 5 | 6 | // Use this for initialization 7 | void Start () { 8 | 9 | } 10 | 11 | // Update is called once per frame 12 | void Update () 13 | { 14 | if (Input.GetKeyDown(KeyCode.P)) 15 | { 16 | this.ConsolePrint("this is print test,not use Debug.Log()"); 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Assets/Scripts/ScriptDemo/PrintOnConsole.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b383f84d4da67db4c9ef5f6fc218ac8c 3 | timeCreated: 1487142857 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/ServerConsole.cs: -------------------------------------------------------------------------------- 1 | #define UNITY_EDITOR_WIN 2 | #define UNITY_STANDALONE_WIN 3 | using UnityEngine; 4 | using System.Collections; 5 | using SLQJ; 6 | 7 | public class ServerConsole : MonoBehaviour 8 | { 9 | #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN 10 | 11 | private ConsoleTestWindows.ConsoleWindow console = new ConsoleTestWindows.ConsoleWindow(); 12 | private ConsoleTestWindows.ConsoleInput input = new ConsoleTestWindows.ConsoleInput(); 13 | 14 | private static bool ishowWindow = false; 15 | private bool oldWindowState = false; 16 | // 17 | // Create console window, register callbacks 18 | // 19 | void Awake() 20 | { 21 | DontDestroyOnLoad( gameObject ); 22 | Debug.Log( "Console Started" ); 23 | } 24 | 25 | // 26 | // Text has been entered into the console 27 | // Run it as a console command 28 | // 29 | void OnInputText( string obj ) 30 | { 31 | this.ConsolePrint(obj); 32 | int subLen = obj.IndexOf(' '); 33 | if (subLen < 0) return; 34 | if (obj.Substring(0, subLen) == "movespeed") 35 | { 36 | string getvaluve = obj.Substring(obj.LastIndexOf(' ')); 37 | float speed = -1; 38 | float.TryParse(getvaluve, out speed); 39 | NotificationManager.Instance.Notify("movespeed", speed); 40 | } 41 | } 42 | 43 | // 44 | // Debug.Log* callback 45 | // 46 | void HandleLog( string message, string stackTrace, LogType type ) 47 | { 48 | if (type == LogType.Warning) 49 | System.Console.ForegroundColor = System.ConsoleColor.Yellow; 50 | else if (type == LogType.Error) 51 | System.Console.ForegroundColor = System.ConsoleColor.Red; 52 | else 53 | System.Console.ForegroundColor = System.ConsoleColor.White; 54 | 55 | // We're half way through typing something, so clear this line .. 56 | if (System.Console.CursorLeft != 0) 57 | input.ClearLine(); 58 | 59 | System.Console.WriteLine( message ); 60 | 61 | // If we were typing something re-add it. 62 | input.RedrawInputLine(); 63 | } 64 | 65 | // 66 | // Update the input every frame 67 | // This gets new key input and calls the OnInputText callback 68 | // 69 | void Update() 70 | { 71 | if (Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.BackQuote)) 72 | { 73 | ishowWindow = !ishowWindow; 74 | if (ishowWindow) 75 | { 76 | console = new ConsoleTestWindows.ConsoleWindow(); 77 | input = new ConsoleTestWindows.ConsoleInput(); 78 | console.Initialize(); 79 | console.SetTitle("Test command"); 80 | input.OnInputText += OnInputText; 81 | Application.logMessageReceived += HandleLog; 82 | } 83 | else 84 | { 85 | CloseConsoleWindow(); 86 | } 87 | oldWindowState = ishowWindow; 88 | } 89 | // input update 90 | if (ishowWindow && null != input) 91 | { 92 | input.Update(); 93 | } 94 | 95 | if (ishowWindow != oldWindowState && !ishowWindow) 96 | { 97 | CloseConsoleWindow(); 98 | } 99 | oldWindowState = ishowWindow; 100 | } 101 | 102 | // 103 | // It's important to call console.ShutDown in OnDestroy 104 | // because compiling will error out in the editor if you don't 105 | // because we redirected output. This sets it back to normal. 106 | // 107 | void OnDestroy() 108 | { 109 | CloseConsoleWindow(); 110 | } 111 | 112 | void CloseConsoleWindow() 113 | { 114 | if (console != null) 115 | { 116 | console.Shutdown(); 117 | console = null; 118 | input = null; 119 | } 120 | } 121 | // control by other . 122 | public static void SetIshowWindow(bool flag) 123 | { 124 | ishowWindow = flag; 125 | } 126 | 127 | #endif 128 | } 129 | 130 | public static class ExtendDebugClass 131 | { 132 | public static void ConsolePrint(this MonoBehaviour mono, string message) 133 | { 134 | if (message.Length < 0) return; 135 | System.Console.WriteLine(message); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /Assets/Scripts/ServerConsole.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c034e085af3ffae49bfc129378896bd8 3 | timeCreated: 1447383229 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/Tes.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Tes : MonoBehaviour { 5 | 6 | // Use this for initialization 7 | void Start () { 8 | 9 | } 10 | 11 | // Update is called once per frame 12 | void Update () 13 | { 14 | if (Input.GetKeyDown(KeyCode.Comma)) 15 | { 16 | Debug.Log("this is debug log"); 17 | this.ConsolePrint("this is system console write line"); 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Assets/Scripts/Tes.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b5c34fc26ce89e47bb97eb4ea17cc0f 3 | timeCreated: 1447385457 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/TestDemo.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/Assets/TestDemo.unity -------------------------------------------------------------------------------- /Assets/TestDemo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f2c26b181346ca41b5320e8fc4bdab0 3 | timeCreated: 1447383379 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityVS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02fe78e962405814a83b8ba6c9471d32 3 | folderAsset: yes 4 | timeCreated: 1447383373 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityVS/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e71a3e2fb5854e43823a9da25b68e21 3 | folderAsset: yes 4 | timeCreated: 1447383373 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll.meta: -------------------------------------------------------------------------------- 1 | guid: 38d405c119fcc7c4e83d4a478a40ff2f 2 | -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Messaging.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Messaging.dll -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Messaging.dll.meta: -------------------------------------------------------------------------------- 1 | guid: 4ad02dc83da735c4e8d945332b9202f6 2 | -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/UnityVS.VersionSpecific.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/Assets/UnityVS/Editor/UnityVS.VersionSpecific.dll -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/UnityVS.VersionSpecific.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df5d8966726fbe943b5a5a59cdaa7daa 3 | timeCreated: 1447383408 4 | licenseType: Free 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | platformData: 11 | Any: 12 | enabled: 0 13 | settings: {} 14 | Editor: 15 | enabled: 1 16 | settings: 17 | DefaultValueInitialized: true 18 | userData: 19 | assetBundleName: 20 | assetBundleVariant: 21 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.4.0f3 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UnityConsoleWindow 2 | 3 | 2017-02-16 4 | 5 | 本次修改主要是根据之前使用的体验做了修改。 6 | 7 | 2017年之前版本,只是在游戏开始时候会自动开启控制台窗口,然后在里面可以输入或代码里调用输出。 8 | 9 | 2017年2月16号现在版本,通过tab按键或~按键来调用和关闭控制台窗口。 10 | 当然主要功能还是没有改变,就是可以输入和输出信息。 11 | 命令行窗口上添加了两个命令,一个clear的清屏命令,一个是exit的退出命令行窗口命令。 12 | 13 | 14 | ----------------------- 15 | This is test console window for unity 5 and my unity version is 5.1.1f. 16 | 17 | And most function is done by garry. 18 | Here is where i found it.http://garry.tv/2014/04/23/unity-batchmode-console/ 19 | 20 | And this test project is very simple ,put button A down ,you can show the test word. 21 | But more than that ,it can change the freamwork for you ,because in the ConsoleInput.cs, 22 | Console itself use most of function in Framework 4.0, and the unity 5 just support 3.5 when you change the compile option in 23 | .Net 2.0。 24 | 25 | So what i have done for u ,is simple for everyone to use the console window and input function. 26 | 27 | here is the test blog:http://blog.csdn.net/cartzhang/article/details/49884507 28 | 29 | thanks to you all. 30 | -------------------------------------------------------------------------------- /TagforGithub/github添加标签.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/TagforGithub/github添加标签.png -------------------------------------------------------------------------------- /TagforGithub/弹出信息.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/TagforGithub/弹出信息.png -------------------------------------------------------------------------------- /TagforGithub/当前版本添加.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/TagforGithub/当前版本添加.png -------------------------------------------------------------------------------- /TagforGithub/显示所有tag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/TagforGithub/显示所有tag.png -------------------------------------------------------------------------------- /TagforGithub/显示旧提交信息.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/TagforGithub/显示旧提交信息.png -------------------------------------------------------------------------------- /UnityVS.TestConsole1113.CSharp.Editor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 10.0.20506 7 | 2.0 8 | {FF9B2732-293D-082C-CBDE-7B7C0F138C87} 9 | Library 10 | 11 | Assembly-CSharp-Editor 12 | 512 13 | {E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | .NETFramework 15 | v3.5 16 | Unity Full v3.5 17 | 18 | Editor:5 19 | StandaloneWindows:5 20 | 5.1.1f1 21 | 22 | 23 | pdbonly 24 | false 25 | Temp\UnityVS_bin\Debug\ 26 | prompt 27 | 4 28 | DEBUG;TRACE;UNITY_5_1_1;UNITY_5_1;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_2D_PHYSICS;ENABLE_4_6_FEATURES;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PHYSICS_PHYSX3;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_LICENSE;ENABLE_AUDIOMIXER_SUSPEND;ENABLE_EDITOR_METRICS;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN 29 | false 30 | 31 | 32 | pdbonly 33 | false 34 | Temp\UnityVS_bin\Release\ 35 | prompt 36 | 4 37 | TRACE;UNITY_5_1_1;UNITY_5_1;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_2D_PHYSICS;ENABLE_4_6_FEATURES;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PHYSICS_PHYSX3;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_LICENSE;ENABLE_AUDIOMIXER_SUSPEND;ENABLE_EDITOR_METRICS;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN 38 | false 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Library\UnityAssemblies\UnityEngine.dll 49 | 50 | 51 | Library\UnityAssemblies\UnityEditor.dll 52 | 53 | 54 | 55 | Library\UnityAssemblies\UnityEngine.UI.dll 56 | 57 | 58 | Library\UnityAssemblies\UnityEditor.UI.dll 59 | 60 | 61 | Library\UnityAssemblies\UnityEngine.Networking.dll 62 | 63 | 64 | Library\UnityAssemblies\UnityEditor.Networking.dll 65 | 66 | 67 | Library\UnityAssemblies\UnityEngine.Analytics.dll 68 | 69 | 70 | Library\UnityAssemblies\UnityEditor.Graphs.dll 71 | 72 | 73 | Library\UnityAssemblies\UnityEditor.Android.Extensions.dll 74 | 75 | 76 | Library\UnityAssemblies\UnityEditor.iOS.Extensions.dll 77 | 78 | 79 | Library\UnityAssemblies\UnityEditor.WP8.Extensions.dll 80 | 81 | 82 | Library\UnityAssemblies\UnityEditor.Metro.Extensions.dll 83 | 84 | 85 | Library\UnityAssemblies\UnityEditor.BB10.Extensions.dll 86 | 87 | 88 | Library\UnityAssemblies\UnityEditor.SamsungTV.Extensions.dll 89 | 90 | 91 | Library\UnityAssemblies\UnityEditor.WebGL.Extensions.dll 92 | 93 | 94 | Library\UnityAssemblies\UnityEditor.LinuxStandalone.Extensions.dll 95 | 96 | 97 | Library\UnityAssemblies\UnityEditor.WindowsStandalone.Extensions.dll 98 | 99 | 100 | Library\UnityAssemblies\UnityEditor.OSXStandalone.Extensions.dll 101 | 102 | 103 | Library\UnityAssemblies\UnityEditor.iOS.Extensions.Xcode.dll 104 | 105 | 106 | Assets\UnityVS\Editor\SyntaxTree.VisualStudio.Unity.Bridge.dll 107 | 108 | 109 | Assets\UnityVS\Editor\SyntaxTree.VisualStudio.Unity.Messaging.dll 110 | 111 | 112 | Assets\UnityVS\Editor\UnityVS.VersionSpecific.dll 113 | 114 | 115 | 116 | 117 | {A84133BD-6226-4410-28B1-292FC657206C} 118 | UnityVS.TestConsole1113.CSharp 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /UnityVS.TestConsole1113.CSharp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 10.0.20506 7 | 2.0 8 | {A84133BD-6226-4410-28B1-292FC657206C} 9 | Library 10 | 11 | Assembly-CSharp 12 | 512 13 | {E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | .NETFramework 15 | v3.5 16 | Unity Full v3.5 17 | 18 | Game:1 19 | StandaloneWindows:5 20 | 5.1.1f1 21 | 22 | 23 | pdbonly 24 | false 25 | Temp\UnityVS_bin\Debug\ 26 | prompt 27 | 4 28 | DEBUG;TRACE;UNITY_5_1_1;UNITY_5_1;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_2D_PHYSICS;ENABLE_4_6_FEATURES;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PHYSICS_PHYSX3;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_LICENSE;ENABLE_AUDIOMIXER_SUSPEND;ENABLE_EDITOR_METRICS;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN 29 | false 30 | 31 | 32 | pdbonly 33 | false 34 | Temp\UnityVS_bin\Release\ 35 | prompt 36 | 4 37 | TRACE;UNITY_5_1_1;UNITY_5_1;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_2D_PHYSICS;ENABLE_4_6_FEATURES;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PHYSICS_PHYSX3;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_LICENSE;ENABLE_AUDIOMIXER_SUSPEND;ENABLE_EDITOR_METRICS;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN 38 | false 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Library\UnityAssemblies\UnityEngine.dll 49 | 50 | 51 | Library\UnityAssemblies\UnityEditor.dll 52 | 53 | 54 | 55 | Library\UnityAssemblies\UnityEngine.UI.dll 56 | 57 | 58 | Library\UnityAssemblies\UnityEngine.Networking.dll 59 | 60 | 61 | Library\UnityAssemblies\UnityEngine.Analytics.dll 62 | 63 | 64 | Library\UnityAssemblies\UnityEditor.iOS.Extensions.Xcode.dll 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /UnityVS.TestConsole1113.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityVS.TestConsole1113.CSharp", "UnityVS.TestConsole1113.CSharp.csproj", "{A84133BD-6226-4410-28B1-292FC657206C}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityVS.TestConsole1113.CSharp.Editor", "UnityVS.TestConsole1113.CSharp.Editor.csproj", "{FF9B2732-293D-082C-CBDE-7B7C0F138C87}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {A84133BD-6226-4410-28B1-292FC657206C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {A84133BD-6226-4410-28B1-292FC657206C}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {A84133BD-6226-4410-28B1-292FC657206C}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {A84133BD-6226-4410-28B1-292FC657206C}.Release|Any CPU.Build.0 = Release|Any CPU 18 | {FF9B2732-293D-082C-CBDE-7B7C0F138C87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {FF9B2732-293D-082C-CBDE-7B7C0F138C87}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {FF9B2732-293D-082C-CBDE-7B7C0F138C87}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {FF9B2732-293D-082C-CBDE-7B7C0F138C87}.Release|Any CPU.Build.0 = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /image/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/image/0.png -------------------------------------------------------------------------------- /image/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/image/1.png -------------------------------------------------------------------------------- /image/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartzhang/UnityConsoleWindow/00a0c954bfdb39288d4d77ef43bf751fec708bd1/image/2.png -------------------------------------------------------------------------------- /versionpath/unityConsole添加按键命令.md: -------------------------------------------------------------------------------- 1 | 2017-02-16 2 | ## 修改说明: 3 | 4 | 本次修改主要是根据之前使用的体验做了修改。 5 | 6 | 2017年之前版本,只是在游戏开始时候会自动开启控制台窗口,然后在里面可以输入或代码里调用输出。 7 | 8 | 2017年2月16号现在版本,通过tab按键或~按键来调用和关闭控制台窗口。 9 | 当然主要功能还是没有改变,就是可以输入和输出信息。 10 | 命令行窗口上添加了两个命令,一个clear的清屏命令,一个是exit的退出命令行窗口命令。 11 | 12 | ![0](https://github.com/cartzhang/UnityConsoleWindow/blob/master/image/0.png) 13 | 14 | ![1](https://github.com/cartzhang/UnityConsoleWindow/blob/master/image/1.png) 15 | 16 | ## 使用方法 17 | 18 | 使用方法可以参考CommandDemo场景中的Demo样例。 19 | 20 | ![2](https://github.com/cartzhang/UnityConsoleWindow/blob/master/image/2.png) 21 | 22 | 在场景中挂载serverConsole.cs代码,在其他地方要使用log输出或打印的时候,调用 23 | 24 | `this.ConsolePrint("this is print test,not use Debug.Log()");` 25 | 26 | 就可以了。 27 | 28 | 参考PrintOnConsole.cs中代码: 29 | 30 | ` 31 | using UnityEngine; 32 | using System.Collections; 33 | 34 | public class PrintOnConsole : MonoBehaviour { 35 | 36 | // Use this for initialization 37 | void Start () { 38 | 39 | } 40 | 41 | // Update is called once per frame 42 | void Update () 43 | { 44 | if (Input.GetKeyDown(KeyCode.P)) 45 | { 46 | this.ConsolePrint("this is print test,not use Debug.Log()"); 47 | } 48 | 49 | } 50 | } 51 | ` 52 | 53 | 为什么可以这么写呢?很简单,因为把monoBehaviour类添加了扩展方法。 54 | 55 | 具体代码: 56 | ` 57 | public static class ExtendDebugClass 58 | { 59 | public static void ConsolePrint(this MonoBehaviour mono, string message) 60 | { 61 | if (message.Length < 0) return; 62 | System.Console.ForegroundColor = System.ConsoleColor.Magenta; 63 | System.Console.WriteLine(message); 64 | } 65 | } 66 | ` 67 | 68 | 暂时就这么多。 69 | 70 | ## 关于下一步想法 71 | 72 | 其实,还有,就是想把这个控制台窗口也做了一个类似修改器,可以修改一些代码里或游戏里的参数。显示里面实现了一个简单的 73 | 就是在控制台窗口中输入movespeed 10,输入参数就可以调整里面物体小方块的在按下WASD键时候运行速度了。 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | --------------------------------------------------------------------------------