For some reason Unity decided not to support copy and paste in WebGL. Here is an attempt to add it back in. No promises that it's perfect 😅
At the moment there is only support for InputField
and
TMPro.TMP_InputField
-
Download and add in this unity package into your project.
-
If you are using
TMPro.TMP_InputField
then editAssets/WebGLCopyAndPaste/Scripts/WebGLCopyAndPaste.cs
and uncomment this line
// #define WEBGL_COPY_AND_PASTE_SUPPORT_TEXTMESH_PRO
This might be better?
https://github.com/kou-yeung/WebGLInput
The plugin has been tested an confirmed working on:
- Edge 120.0.2210.61 (Chromium) on Windows 10, Unity 2022.3.10, 2021.3.25 and 2020.3.18.
- Firefox 120.0.1 on Windows 10, Unity 2022.3.10, 2021.3.25 and 2020.3.18.
- Safari 16.6 on macOS Ventura 13.6, Unity 2022.3.10.
- Chrome 118.0.5993.70 on macOS Ventura 13.6, Unity 2022.3.10.
- Firefox 120.0.1 on macOS Ventura 13.6, Unity 2022.3.10.
-
Non Alphabetic characters
See this thread. You apparently need to include the fonts in your Unity project.
-
Ctrl-A/⌘-A selects other HTML on the page
-
Make your own WebGL template that doesn't have anything to select. Maybe this one though I didn't try it.
-
Make your own WebGL template and use
user-select: none;
in your CSS to make whatever parts of the page you want to prevent from being selected.
-
-
0.3.0
- Added
Preserve
attribute toWebGLCopyAndPasteAPI
class, andAlwaysLinkAssembly
to the assembly, so Unity doesn't strip the code if the plugin is moved to a package
- Added
-
0.2.1
-
Fixed paste not working on some browsers
-
Fixed labels not being visually updated on some browsers
-
Fixed potential null reference exception when
EventSystem.current
is null -
Substituted deprecated JavaScript
Window.event
-
-
0.2.0
- Fixes for Unity 2021.2
-
0.1.0
-
Removed the need for MonoBehaviours
-
Replaced messages with proper callbacks
-
Fixed data storing in
window
-
-
0.0.2
-
Support cut
-
Support Safari
-
-
0.0.1
- Initial Release