UnityEngine.Sprite.Create(UnityEngine.Texture2D, UnityEngine.Rect, UnityEngine.Vector2, float)

Here are the examples of the csharp api UnityEngine.Sprite.Create(UnityEngine.Texture2D, UnityEngine.Rect, UnityEngine.Vector2, float) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

19 View Source File : FileManager.cs
License : MIT License
Project Creator : EtiamNullam

public static Sprite LoadSpriteFromFile(string path, int width, int height)
        {
            byte[] bytes = File.ReadAllBytes(path);
            var texture = new Texture2D(width, height, TextureFormat.RGB24, false);

            texture.filterMode = FilterMode.Trilinear;
            texture.LoadImage(bytes);

            return Sprite.Create(texture, new Rect(0, 0, width, height), new Vector2(0.5f, 0.0f), 1.0f);
        }

19 View Source File : NFTTokenData.cs
License : MIT License
Project Creator : WalletConnect

public IEnumerator DownloadImageSprite()
        {
            UnityWebRequest www = UnityWebRequestTexture.GetTexture(image);

            yield return www.SendWebRequest();

            if (www.isNetworkError)
            {
                throw new IOException(www.error);
            }
            else
            {
                Texture2D imageTexture = DownloadHandlerTexture.GetContent(www);

                Rect rect = new Rect(0, 0, imageTexture.width, imageTexture.height);
                Sprite imageSprite = Sprite.Create(imageTexture, rect, new Vector2(0.5f, 0.5f), 100);

                _cache = imageSprite;
            }
        }

19 View Source File : WalletConnectQRImage.cs
License : MIT License
Project Creator : WalletConnect

private void WalletConnectOnConnectionStarted(object sender, EventArgs e)
    {
        var url = walletConnect.Session.URI;
        
        Debug.Log(url);
        
        QRCodeGenerator qrGenerator = new QRCodeGenerator();
        QRCodeData qrCodeData = qrGenerator.CreateQrCode(url, QRCodeGenerator.ECCLevel.Q);
        UnityQRCode qrCode = new UnityQRCode(qrCodeData);
        Texture2D qrCodeAsTexture2D = qrCode.GetGraphic(20);

        var qrCodeSprite = Sprite.Create(qrCodeAsTexture2D, new Rect(0, 0, qrCodeAsTexture2D.width, qrCodeAsTexture2D.height),
            new Vector2(0.5f, 0.5f), 100f);

        _image.sprite = qrCodeSprite;
    }

19 View Source File : UnityEngine_SpriteWrap.cs
License : MIT License
Project Creator : XINCGer

[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int Create(IntPtr L)
	{
		try
		{
			int count = LuaDLL.lua_gettop(L);

			if (count == 3)
			{
				UnityEngine.Texture2D arg0 = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D));
				UnityEngine.Rect arg1 = StackTraits<UnityEngine.Rect>.Check(L, 2);
				UnityEngine.Vector2 arg2 = ToLua.ToVector2(L, 3);
				UnityEngine.Sprite o = UnityEngine.Sprite.Create(arg0, arg1, arg2);
				ToLua.PushSealed(L, o);
				return 1;
			}
			else if (count == 4)
			{
				UnityEngine.Texture2D arg0 = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D));
				UnityEngine.Rect arg1 = StackTraits<UnityEngine.Rect>.Check(L, 2);
				UnityEngine.Vector2 arg2 = ToLua.ToVector2(L, 3);
				float arg3 = (float)LuaDLL.luaL_checknumber(L, 4);
				UnityEngine.Sprite o = UnityEngine.Sprite.Create(arg0, arg1, arg2, arg3);
				ToLua.PushSealed(L, o);
				return 1;
			}
			else if (count == 5)
			{
				UnityEngine.Texture2D arg0 = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D));
				UnityEngine.Rect arg1 = StackTraits<UnityEngine.Rect>.Check(L, 2);
				UnityEngine.Vector2 arg2 = ToLua.ToVector2(L, 3);
				float arg3 = (float)LuaDLL.luaL_checknumber(L, 4);
				uint arg4 = (uint)LuaDLL.luaL_checknumber(L, 5);
				UnityEngine.Sprite o = UnityEngine.Sprite.Create(arg0, arg1, arg2, arg3, arg4);
				ToLua.PushSealed(L, o);
				return 1;
			}
			else if (count == 6)
			{
				UnityEngine.Texture2D arg0 = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D));
				UnityEngine.Rect arg1 = StackTraits<UnityEngine.Rect>.Check(L, 2);
				UnityEngine.Vector2 arg2 = ToLua.ToVector2(L, 3);
				float arg3 = (float)LuaDLL.luaL_checknumber(L, 4);
				uint arg4 = (uint)LuaDLL.luaL_checknumber(L, 5);
				UnityEngine.SpriteMeshType arg5 = (UnityEngine.SpriteMeshType)ToLua.CheckObject(L, 6, typeof(UnityEngine.SpriteMeshType));
				UnityEngine.Sprite o = UnityEngine.Sprite.Create(arg0, arg1, arg2, arg3, arg4, arg5);
				ToLua.PushSealed(L, o);
				return 1;
			}
			else if (count == 7)
			{
				UnityEngine.Texture2D arg0 = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D));
				UnityEngine.Rect arg1 = StackTraits<UnityEngine.Rect>.Check(L, 2);
				UnityEngine.Vector2 arg2 = ToLua.ToVector2(L, 3);
				float arg3 = (float)LuaDLL.luaL_checknumber(L, 4);
				uint arg4 = (uint)LuaDLL.luaL_checknumber(L, 5);
				UnityEngine.SpriteMeshType arg5 = (UnityEngine.SpriteMeshType)ToLua.CheckObject(L, 6, typeof(UnityEngine.SpriteMeshType));
				UnityEngine.Vector4 arg6 = ToLua.ToVector4(L, 7);
				UnityEngine.Sprite o = UnityEngine.Sprite.Create(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
				ToLua.PushSealed(L, o);
				return 1;
			}
			else if (count == 8)
			{
				UnityEngine.Texture2D arg0 = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D));
				UnityEngine.Rect arg1 = StackTraits<UnityEngine.Rect>.Check(L, 2);
				UnityEngine.Vector2 arg2 = ToLua.ToVector2(L, 3);
				float arg3 = (float)LuaDLL.luaL_checknumber(L, 4);
				uint arg4 = (uint)LuaDLL.luaL_checknumber(L, 5);
				UnityEngine.SpriteMeshType arg5 = (UnityEngine.SpriteMeshType)ToLua.CheckObject(L, 6, typeof(UnityEngine.SpriteMeshType));
				UnityEngine.Vector4 arg6 = ToLua.ToVector4(L, 7);
				bool arg7 = LuaDLL.luaL_checkboolean(L, 8);
				UnityEngine.Sprite o = UnityEngine.Sprite.Create(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
				ToLua.PushSealed(L, o);
				return 1;
			}
			else
			{
				return LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Sprite.Create");
			}
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}