Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Calling "Windows.UI" namespace from Unity / create windows plugin

Discussion in 'Windows' started by MohHeader, Jul 28, 2020.

  1. MohHeader

    MohHeader

    Joined:
    Aug 12, 2015
    Posts:
    41
    Hi all,

    My experience is in the mobile field, so not sure how to create a plugin for windows.

    the functionality I need to achieve: [Disable taking screenshots] same as in Android apps.

    I found that I can do that if I called the following function:
    Code (CSharp):
    1. Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().IsScreenCaptureEnabled = false;
    as I am using a Mac device, I only have the option to create a standalone version for windows, not UWP

    not sure if it is an easy task, and it is just me that don't know how, or it is harder than I can expect

    Thanks in advance
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,507
    That API will not work for non-UWP applications. ApplicationView.GetForCurrentView() will just return null.
     
  3. MohHeader

    MohHeader

    Joined:
    Aug 12, 2015
    Posts:
    41
    so if I am building for UWP version, I will be able to do that call true ?

    Great,, Thanks for telling me that, will try it on a windows Machine ASAP
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,507
    Yes, that will work on UWP apps. You just need to surround it in an #ifdef:

    Code (csharp):
    1. #if ENABLE_WINMD_SUPPORT && UNITY_WSA
    2. Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().IsScreenCaptureEnabled = false;
    3. #endif