Category: Tutorial

Unity 2019 – How to copy a string to Clipboard

In Unity there is a cross-platform way to copy a string to Clipboard. Using the TextEditor class I’m going to show you how to copy a string into the user’s Clipboard. This should also work in Unity 2018.

By using the TextEditor class, from UnityEngine, we can fit any C# object with a ToString() function into the Clipboard!

Clipboard Extension

To make it easily accessible I made the function as a string extension. By doing it this way we can use the function on any string anywhere in the code.

using UnityEngine;

public static class ClipboardExtension
    /// <summary>
    /// Puts the string into the Clipboard.
    /// </summary>
    /// <param name="str"></param>
    public static void CopyToClipboard(this string str)
        GUIUtility.systemCopyBuffer = str;


Here is an example on how to copy different elements into the Clipboard using the ClipboardExtension:

public string GetSomeString()
    return "This is a string coming from a function!";

public void TestCopyToClipboard()
    // + Using a standard string
    string testString = "Am I in the Clipboard?";
    // The content of test1 is in the Clipboard now!

    // + Using a method to get a string
    // The content returned by GetSomeString() is in the Clipboard now!

    // + Using a C# object with a ToString() method
    Color colorTest =;
    // The string version of the object colorTest is in the clipboard now!

You can try out this code for yourself! Run it, then try pasting your Clipboard into a notepad. It has been tested and works on PC, WebGL and mobile!

Continue reading ...

Fixing Violation of Usage of Android Advertising ID policy

If you recently tried to publish a game made with Unity you might have received an e-mail from Google Play saying that your app got removed. In this post I will show you an easy way to get back on the Store by fixing the Violation of Usage of Android Advertising ID policy.

The mail that you received should be looking like this:

Hi developers at <your company>,

After review, <your game>, com.YourCompany.YourGame, has been removed from Google Play due to a policy violation. This app won’t be available to users until you submit a compliant update.

Issue: Violation of Usage of Android Advertising ID policy and section 4.8 of the Developer Distribution Agreement

Google Play requires developers to provide a valid privacy policy when the app requests or handles sensitive user or device information. We’ve identified that your app collects and transmits the Android advertising identifier, which is subject to a privacy policy requirement. If your app collects the Android advertising ID, you must provide a valid privacy policy in both the designated field in the Play Console, and from within the app.

Next steps: Submit your app for another review

  1. Read through the Usage of Android Advertising ID and User Data policies, as well as the Developer Distribution Agreement, and make appropriate changes to your app. If you decide to collect sensitive user information, be sure to abide by the above policies, and include a link to a valid privacy policy on your app’s store listing page and within your app.
  2. Make sure that your app is compliant with all other Developer Program Policies. Additional enforcement could occur if there are further policy violations.
  3. Sign in to your Play Console and submit the update to your app.

Alternatively, you may opt-out of this requirement by removing any requests for sensitive permissions or user data.

If approved, your app will again be available with all installs, ratings, and reviews intact.

If you’ve reviewed the policy and feel this removal may have been in error, please reach out to our policy support team. One of my colleagues will get back to you within 2 business days.

Thanks for helping us provide a clear and transparent experience for Google Play users.



The Google Play Team

Please help!

If your game is not using Unity Ads or any ad network you can fix your app in no time! Simply head over to the Package Manager.

Unity Package Manager

Then, from here remove the Advertisement package.

Unity Package Panager - Unity Ads

And that’s it! You can finally build your game and submit it.

If you still get rejected, you can also remove the In App Purchasing package and the Analytics Library package.

Unity Package Panager - Unity IAP

What if I am using Unity Ads?

If your game is using Unity Ads (or another ad network, or Unity IAP and previous section didn’t help) then you have to do as Google said. Provide them a valid privacy policy.
If you need to publish as fast as possible you can quickly create a privacy policy using this generator for example:

Continue reading ...

Unity 2018 – How to get local IP address

In Unity 2018 getting the player local IP address has changed. Previously we could use the UnityEngine.Network class, but it has become obsolete.

string ipAddress = UnityEngine.Network.player.ipaddress; // obsolete

After doing some research I found the C# way of getting the local IP address of the user:

public static class IPManager
    public static string GetLocalIPAddress()
        var host = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());
        foreach (var ip in host.AddressList)
            if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                return ip.ToString();

        throw new System.Exception("No network adapters with an IPv4 address in the system!");

This can be used to start a local server or direct connect to one.

Before trying to get the IP, you can also check if you are connected with the following line:




Thanks to Mrchief:

Continue reading ...