public void NativeSetTest()
 {
     using NativeSet <int> set = new NativeSet <int>(4);
     Assert.IsTrue(set.IsEmpty);
     Assert.IsTrue(set.IsValid);
     Assert.AreEqual(0, set.Length);
     Assert.AreEqual(4, set.Capacity);
 }
Esempio n. 2
0
        public static void Set(string imgPath, Style?style = null)
        {
            if (imgPath == null)
            {
                throw new ArgumentException("Cowardly refusing to set desktop background to null");
            }
            if (!System.IO.Path.IsPathRooted(imgPath))
            {
                imgPath = UnityEngine.Application.streamingAssetsPath + System.IO.Path.DirectorySeparatorChar + imgPath;
            }

            var key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);

            switch (style)
            {
            case Style.Tiled:
                key.SetValue(@"WallpaperStyle", 1.ToString());
                key.SetValue(@"TileWallpaper", 1.ToString());
                break;

            case Style.Centered:
                key.SetValue(@"WallpaperStyle", 1.ToString());
                key.SetValue(@"TileWallpaper", 0.ToString());
                break;

            case Style.Stretched:
                key.SetValue(@"WallpaperStyle", 2.ToString());
                key.SetValue(@"TileWallpaper", 0.ToString());
                break;

            default:
                break;
            }

            NativeSet.SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, imgPath, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
            Debug.Log($"Wallpaper set to {imgPath}");
        }