-
Notifications
You must be signed in to change notification settings - Fork 6
Console
-
Add submodule
$ git submodule add git@github.com:chaolunner/UnityFrameworkStreamingAssets.git Assets/StreamingAssets -
Use the
~key switch console system, Use theesckey turn off console system
-
Find the
Plugins/UniEasy/Resources/Kernel/Console.prefaband selectServercomponent -
Set the port on the
Servercomponent (default value is 55055) -
Add the UniEasy.Console.Command attribute to your code
-
Run the game and connect to http://localhost:55055 with your browser
[Command ("Quit", "Quit the application.", "Quit")]
public static string Execute (params string[] args)
{
Application.Quit ();
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#endif
return "Quitting...";
}
Console.RegisterCommand ("Quit", "Quit the application.", "Quit", (args) =>
{
Application.Quit ();
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#endif
return "Quitting...";
});
public class QuitSystem : SystemBehaviour
{
public override void Initialize (IEventSystem eventSystem, IPoolManager poolManager, GroupFactory groupFactory, PrefabFactory prefabFactory)
{
base.Initialize (eventSystem, poolManager, groupFactory, prefabFactory);
UniEasy.Console.Console.RegisterCommand ("Quit", "Quit the application.", "Quit", (args) =>
{
Application.Quit ();
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#endif
return "Quitting...";
}).AddTo (this.Disposer);
}
}
public class ConsoleSystem : SystemBehaviour
{
void Start ()
{
Console.Log ("output");
}
public override void OnEnable ()
{
base.OnEnable ();
Console.RegisterLog (OnLog);
}
public override void OnDisable ()
{
base.OnDisable ();
Console.DeregisterLog (OnLog);
}
void OnLog (string[] args)
{
Debug.Log (args.FirstOrDefault ());
}
}
The console comes with some commands by default
-
HELP- Display the list of available commands or details about a specific command -
LOADSCENE- Load the specified scene by name. Before you load scene you have to add it to thescenes in buildUse File -> Build Settings... in Unity and add the.sceneto thescenes in build -
DEREGISTER- Deregister a specific command. -
CLEAR- Clear console output. -
Debug- Open or Close console by inputdebug onordebug off. -
QUIT- Quit the application.
Shortcut key
-
Tab- Fast completion command -
Arrow Up/Down- Input commands history -
Enter- Execute command -
~- Switch console open or colse -
Esc- Close console -
Click 20 times(Android/iOS)- Open console
using UniEasy.Console;
public class Example : MonoBehaviour
{
void Start ()
{
Debugger.Log ("white context", "Layer 0");
Debugger.LogWarnning ("yellow context", "Layer 1");
Debugger.LogError ("red context", "Layer 2");
}
}
-
Debug System Prefab Path : Assets/UniEasy/Resources/Kernel/...
-
Prefabs under the Kernel folder will auto be create when playing and Add to
DontDestoryOnLoadscene -
Debug Config File Path : Assets/UniEasy/Preferences/
DebugSetting.asset -
Selected
DebugSettingyou can see aIsLogEnabletoggle in Inspector Window, if you selectIsLogEnableforFalse, nothing will output on Console Window -
You can see a
ShowOnUGUItoggle in Inspector Window, It mean if you select it for true, Debug Canvas will turn on -
You can see a
DebugViewList in Inspector Window, It IncludeCollapse,Log,Warning,Errorsame as unity console (click to show/hide corresponding content) -
You can see a
DebugMaskList in Inspector Window, it include all you setted layer name (eg. If setLayer 0for falsewhite contextwill not be output on Console Window) -
The new layer will auto add to
DebugMaskList when you do Debugger.Log (content,layer name) in editor playing -
If you want to open the Debug Canvas in the scene, you just need to press the
~key and inputdebug onordebug truethen press theenterkey