Implement WebGL console command support#29
Implement WebGL console command support#29ShinodaNaoki wants to merge 5 commits intoproletariatgames:masterfrom
Conversation
I made command support on WebGL build. Ctrl+Alt+Click anywhere blank to open prompt and Input command. Then the result will be shown in browser console.
| /* Execute a command */ | ||
| public static void Run(string str) { | ||
| #if UNITY_WEBGL && !UNITY_EDITOR | ||
| Instance.m_output.Clear(); |
There was a problem hiding this comment.
In WebGL mode, reset m_output for each command.
|
|
||
| private static void LogCore(string str) | ||
| { | ||
| #if !UNITY_WEBGL || UNITY_EDITOR |
There was a problem hiding this comment.
In WebGL mode, debug logs are already shown in browser console.
So I disable log callback to avoid duplicate output.
| mainThread = Thread.CurrentThread; | ||
| fileRoot = Path.Combine(Application.streamingAssetsPath, "CUDLR"); | ||
|
|
||
| #if !UNITY_WEBGL || UNITY_EDITOR |
There was a problem hiding this comment.
I disabled them because we cant use socket in WebGL mode.
|
|
||
| public static void Log(string text) | ||
| { | ||
| #if UNITY_WEBGL && !UNITY_EDITOR |
There was a problem hiding this comment.
this method can show text on browser console, without using debug logger.
| @@ -0,0 +1,37 @@ | |||
| var CUDLR_Relay = { | |||
There was a problem hiding this comment.
This is converted into javascript and placed on browser side.
| return text; | ||
| } | ||
|
|
||
| document.onclick = function(){ |
There was a problem hiding this comment.
click on document with Shift and Alt key to open prompt.
| SetCudlrCallbackAndCreateInput: function(callbackPtr){ | ||
| cr_callback = callbackPtr; | ||
|
|
||
| window.cc = function(command) { |
There was a problem hiding this comment.
This method invoke CUDLR.Console.Run() and output result on browser console.
You can also type like cc("object list") in the broser console command line to Run it.
I made command support on WebGL build.
Ctrl+Alt+Click anywhere blank to open prompt and Input command. Then the result will be shown in browser console.
Thanks.