Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mergeInto(LibraryManager.library, {
PasteFromClipboard: function () {
navigator.clipboard.readText().then(
clipText => {
web3UnityInstance.SendMessage('Web3AuthWalletGUI(Clone)', 'OnPasteWebGL', clipText);
web3UnityInstance.SendMessage('WebGLClipboardManager', 'OnPaste', clipText);
}
).catch(err => {
console.error('Failed to read clipboard contents: ', err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4931,7 +4931,6 @@ GameObject:
- component: {fileID: 4029780974178710413}
- component: {fileID: 7234845548737740600}
- component: {fileID: 804371200852392299}
- component: {fileID: 6274013656548490657}
m_Layer: 0
m_Name: Web3AuthWalletGUI
m_TagString: Untagged
Expand Down Expand Up @@ -5112,18 +5111,6 @@ MonoBehaviour:
holdToRevealPrivateKeyButton: {fileID: 198969248047024504}
circleLoadingImage: {fileID: 1647118626164522998}
holdDuration: 2
--- !u!114 &6274013656548490657
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2911816339710442984}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 15ddd9b23c8d92f4db529a02cc14ecab, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &2991694514551052582
GameObject:
m_ObjectHideFlags: 0
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ private void CheckWalletToggleKeyInput()
/// </summary>
private void CopyWalletAddress()
{
Web3AuthWalletGUIClipboardManager.CopyText(walletAddressText.text);
#if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
ClipboardManager.CopyText(walletAddressText.text);
#else
GUIUtility.systemCopyBuffer = walletAddressText.text;
#endif
}

/// <summary>
Expand Down Expand Up @@ -205,7 +209,11 @@ private void SetPrivateKey()
/// </summary>
private void CopyPrivateKey()
{
Web3AuthWalletGUIClipboardManager.CopyText(privateKeyText.text);
#if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
ClipboardManager.CopyToClipboard(privateKeyText.text);
#else
GUIUtility.systemCopyBuffer = privateKeyText.text;
#endif
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;

namespace ChainSafe.Gaming
{
#if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
public class ClipboardManager : MonoBehaviour
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
public static void CreateGameObject()
{
var go = new GameObject("WebGLClipboardManager", typeof(ClipboardManager));
DontDestroyOnLoad(go);
}

[DllImport("__Internal")]
private static extern void CopyToClipboard(string text);

[DllImport("__Internal")]
private static extern string PasteFromClipboard();


public void Update()
{
if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.V))
{
#if UNITY_IOS
string text = PasteFromClipboard();
OnPaste(text);
#else
PasteFromClipboard();
#endif
}
}

public void OnPaste(string text)
{
var currentGo = EventSystem.current.currentSelectedGameObject;
if (currentGo != null && currentGo.TryGetComponent<TMP_InputField>(out var inputField))
{
inputField.text = text;
}
}
}
#endif
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading