Search code examples
c#unity-game-enginecopy-paste

Unity Copy to clipboard on Android


Can someone please help me with this? I saw some codes and they are really hard to understand also I am quite a beginner in Unity and C#. How to copy to clipboard text? Are there any assets maybe out there which could help?


Solution

  • I am not really familliar with Android, but copying text in Unity is done like that:

    private void CopyText(string textToCopy)
    {
        TextEditor editor = new TextEditor
        {
            text = textToCopy
        };
        editor.SelectAll();
        editor.Copy();
    }
    

    Just call that function from whereever and you have the text in your clipboard.

    But a piece of advice: maybe you want to try and get a hang of the basics in C#/Unity before you dive head first into mobile development. It's not really beginner-friendly imho.

    Good luck!