-
Notifications
You must be signed in to change notification settings - Fork 34
Implement WebGL console command support #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is converted into javascript and placed on browser side.
| return text; | ||
| } | ||
|
|
||
| document.onclick = function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.