반응형

스토어에 deprecated되어있어 개인적으로 사용하기 위해 블로깅해둠.

Shader "UI/Blur/UIBlurHQ" {
  Properties {
    _TintColor ("Tint Color", Color) = (1, 1, 1, 0.2)
    _Size ("Spacing", Range(0, 40)) = 5.0
    _Vibrancy ("Vibrancy", Range(0, 2)) = 0.2
    _MainTex ("Texture", 2D) = "white" {}

    [HideInInspector]
    _StencilComp ("Stencil Comparison", Float) = 8
    [HideInInspector]
    _Stencil ("Stencil ID", Float) = 0
    [HideInInspector]
    _StencilOp ("Stencil Operation", Float) = 0
    [HideInInspector]
    _StencilWriteMask ("Stencil Write Mask", Float) = 255
    [HideInInspector]
    _StencilReadMask ("Stencil Read Mask", Float) = 255
    [HideInInspector]
    _ColorMask ("Color Mask", Color) = (1, 1, 1, 0.2)

  }
 
  Category {
    // We must be transparent, so other objects are drawn before this one.
    Tags { 
      "Queue"="Transparent"
      "IgnoreProjector"="True" 
      "RenderType"="Opaque" 
    }

    Stencil {
      Ref [_Stencil]
      Comp [_StencilComp]
      Pass [_StencilOp] 
      ReadMask [_StencilReadMask]
      WriteMask [_StencilWriteMask]
    }

    SubShader {

      GrabPass {
        // "_GrabTexture" // Uncomment to speed-up, see documentation.
        Tags { "LightMode" = "Always" }
      }
      
      // Vertical blur
      Pass {
        Name "VERTICAL"
        Tags { "LightMode" = "Always" }

        Blend SrcAlpha OneMinusSrcAlpha
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #pragma fragmentoption ARB_precision_hint_fastest
        #include "UnityCG.cginc"
         
        struct appdata_t {
          float4 vertex : POSITION;
          float2 texcoord: TEXCOORD0;
        };
         
        struct v2f {
          float4 vertex : POSITION;
          float4 uvgrab : TEXCOORD0;
          float2 uv : TEXCOORD1;
        };

        float4 _MainTex_ST;
         
        v2f vert (appdata_t v) {
          v2f o;
          o.vertex = UnityObjectToClipPos(v.vertex);
          #if UNITY_UV_STARTS_AT_TOP
          float scale = -1.0;
          #else
          float scale = 1.0;
          #endif
          o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y*scale) + o.vertex.w) * 0.5;
          o.uvgrab.zw = o.vertex.zw;
          o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
          return o;
        }
         
        sampler2D _GrabTexture;
        float4 _GrabTexture_TexelSize;
        float _Size;
        sampler2D _MainTex;
         
        half4 frag( v2f i ) : COLOR {
          half4 sum = half4(0,0,0,0);
 
          #define GRABPIXEL(weight,kernely) tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(float4(i.uvgrab.x, i.uvgrab.y + _GrabTexture_TexelSize.y * kernely * _Size * 1.61, i.uvgrab.z, i.uvgrab.w))) * weight
 
          sum += GRABPIXEL(0.05, -4.0);
          sum += GRABPIXEL(0.09, -3.0);
          sum += GRABPIXEL(0.12, -2.0);
          sum += GRABPIXEL(0.15, -1.0);
          sum += GRABPIXEL(0.18,  0.0);
          sum += GRABPIXEL(0.15, +1.0);
          sum += GRABPIXEL(0.12, +2.0);
          sum += GRABPIXEL(0.09, +3.0);
          sum += GRABPIXEL(0.05, +4.0);

          half4 texcol = tex2D(_MainTex, i.uv);
          sum.a = texcol.a;
          return sum;
        }
        
        ENDCG
      }

      GrabPass {
        Tags { "LightMode" = "Always" }
      }

      // Horizontal blur
      Pass {
        Name "HORIZONTAL"
        Tags { "LightMode" = "Always" }

        Blend SrcAlpha OneMinusSrcAlpha
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #pragma fragmentoption ARB_precision_hint_fastest
        #include "UnityCG.cginc"

         
        struct appdata_t {
          float4 vertex : POSITION;
          float2 texcoord: TEXCOORD0;
        };
         
        struct v2f {
          float4 vertex : POSITION;
          float4 uvgrab : TEXCOORD0;
          float2 uv : TEXCOORD1;
        };

        float4 _MainTex_ST;
         
        v2f vert (appdata_t v) {
          v2f o;
          o.vertex = UnityObjectToClipPos(v.vertex);
          #if UNITY_UV_STARTS_AT_TOP
          float scale = -1.0;
          #else
          float scale = 1.0;
          #endif
          o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y*scale) + o.vertex.w) * 0.5;
          o.uvgrab.zw = o.vertex.zw;
          o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
          return o;
        }
         
        sampler2D _GrabTexture;
        float4 _GrabTexture_TexelSize;
        float _Size;
        sampler2D _MainTex;
         
        half4 frag( v2f i ) : COLOR {
          half4 sum = half4(0,0,0,0);
 
          #define GRABPIXEL(weight,kernelx) tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(float4(i.uvgrab.x + _GrabTexture_TexelSize.x * kernelx * _Size * 1.61, i.uvgrab.y, i.uvgrab.z, i.uvgrab.w))) * weight
 
          sum += GRABPIXEL(0.05, -4.0);
          sum += GRABPIXEL(0.09, -3.0);
          sum += GRABPIXEL(0.12, -2.0);
          sum += GRABPIXEL(0.15, -1.0);
          sum += GRABPIXEL(0.18,  0.0);
          sum += GRABPIXEL(0.15, +1.0);
          sum += GRABPIXEL(0.12, +2.0);
          sum += GRABPIXEL(0.09, +3.0);
          sum += GRABPIXEL(0.05, +4.0);

          half4 texcol = tex2D(_MainTex, i.uv);
          sum.a = texcol.a;
          return sum;
        }
        
        ENDCG
      }
        
      GrabPass {
        Tags { "LightMode" = "Always" }
      }
      
      // Vertical blur
      Pass {
        Name "VERTICAL"
        Tags { "LightMode" = "Always" }

        Blend SrcAlpha OneMinusSrcAlpha
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #pragma fragmentoption ARB_precision_hint_fastest
        #include "UnityCG.cginc"
         
        struct appdata_t {
          float4 vertex : POSITION;
          float2 texcoord: TEXCOORD0;
        };
         
        struct v2f {
          float4 vertex : POSITION;
          float4 uvgrab : TEXCOORD0;
          float2 uv : TEXCOORD1;
        };

        float4 _MainTex_ST;
         
        v2f vert (appdata_t v) {
          v2f o;
          o.vertex = UnityObjectToClipPos(v.vertex);
          #if UNITY_UV_STARTS_AT_TOP
          float scale = -1.0;
          #else
          float scale = 1.0;
          #endif
          o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y*scale) + o.vertex.w) * 0.5;
          o.uvgrab.zw = o.vertex.zw;
          o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
          return o;
        }
         
        sampler2D _GrabTexture;
        float4 _GrabTexture_TexelSize;
        float _Size;
        sampler2D _MainTex;
         
        half4 frag( v2f i ) : COLOR {
          half4 sum = half4(0,0,0,0);
 
          #define GRABPIXEL(weight,kernely) tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(float4(i.uvgrab.x, i.uvgrab.y + _GrabTexture_TexelSize.y * kernely * _Size, i.uvgrab.z, i.uvgrab.w))) * weight
 
          sum += GRABPIXEL(0.05, -4.0);
          sum += GRABPIXEL(0.09, -3.0);
          sum += GRABPIXEL(0.12, -2.0);
          sum += GRABPIXEL(0.15, -1.0);
          sum += GRABPIXEL(0.18,  0.0);
          sum += GRABPIXEL(0.15, +1.0);
          sum += GRABPIXEL(0.12, +2.0);
          sum += GRABPIXEL(0.09, +3.0);
          sum += GRABPIXEL(0.05, +4.0);

          half4 texcol = tex2D(_MainTex, i.uv);
          sum.a = texcol.a;
          return sum;
        }
        
        ENDCG
      }

      GrabPass {             
        Tags { "LightMode" = "Always" }
      }

      // Horizontal blur
      Pass {
        Name "HORIZONTAL"
        Tags { "LightMode" = "Always" }

        Blend SrcAlpha OneMinusSrcAlpha
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #pragma fragmentoption ARB_precision_hint_fastest
        #include "UnityCG.cginc"
         
        struct appdata_t {
          float4 vertex : POSITION;
          float2 texcoord: TEXCOORD0;
        };
         
        struct v2f {
          float4 vertex : POSITION;
          float4 uvgrab : TEXCOORD0;
          float2 uv : TEXCOORD1;
        };

        float4 _MainTex_ST;
         
        v2f vert (appdata_t v) {
          v2f o;
          o.vertex = UnityObjectToClipPos(v.vertex);
          #if UNITY_UV_STARTS_AT_TOP
          float scale = -1.0;
          #else
          float scale = 1.0;
          #endif
          o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y*scale) + o.vertex.w) * 0.5;
          o.uvgrab.zw = o.vertex.zw;
          o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
          return o;
        }
         
        sampler2D _GrabTexture;
        float4 _GrabTexture_TexelSize;
        float _Size;
        sampler2D _MainTex;
         
        half4 frag( v2f i ) : COLOR {
          half4 sum = half4(0,0,0,0);
 
          #define GRABPIXEL(weight,kernelx) tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(float4(i.uvgrab.x + _GrabTexture_TexelSize.x * kernelx * _Size, i.uvgrab.y, i.uvgrab.z, i.uvgrab.w))) * weight
 
          sum += GRABPIXEL(0.05, -4.0);
          sum += GRABPIXEL(0.09, -3.0);
          sum += GRABPIXEL(0.12, -2.0);
          sum += GRABPIXEL(0.15, -1.0);
          sum += GRABPIXEL(0.18,  0.0);
          sum += GRABPIXEL(0.15, +1.0);
          sum += GRABPIXEL(0.12, +2.0);
          sum += GRABPIXEL(0.09, +3.0);
          sum += GRABPIXEL(0.05, +4.0);

          half4 texcol = tex2D(_MainTex, i.uv);
          sum.a = texcol.a;
          return sum;
        }
        
        ENDCG
      }
      GrabPass {
        Tags { "LightMode" = "Always" }
      }
      
      // Vertical blur
      Pass {
        Name "VERTICAL"
        Tags { "LightMode" = "Always" }

        Blend SrcAlpha OneMinusSrcAlpha
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #pragma fragmentoption ARB_precision_hint_fastest
        #include "UnityCG.cginc"
         
        struct appdata_t {
          float4 vertex : POSITION;
          float2 texcoord: TEXCOORD0;
        };
         
        struct v2f {
          float4 vertex : POSITION;
          float4 uvgrab : TEXCOORD0;
          float2 uv : TEXCOORD1;
        };

        float4 _MainTex_ST;
         
        v2f vert (appdata_t v) {
          v2f o;
          o.vertex = UnityObjectToClipPos(v.vertex);
          #if UNITY_UV_STARTS_AT_TOP
          float scale = -1.0;
          #else
          float scale = 1.0;
          #endif
          o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y*scale) + o.vertex.w) * 0.5;
          o.uvgrab.zw = o.vertex.zw;
          o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
          return o;
        }
         
        sampler2D _GrabTexture;
        float4 _GrabTexture_TexelSize;
        float _Size;
        sampler2D _MainTex;
         
        half4 frag( v2f i ) : COLOR {
          half4 sum = half4(0,0,0,0);
 
          #define GRABPIXEL(weight,kernely) tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(float4(i.uvgrab.x, i.uvgrab.y + _GrabTexture_TexelSize.y * kernely * _Size * 0.2, i.uvgrab.z, i.uvgrab.w))) * weight
 
          sum += GRABPIXEL(0.05, -4.0);
          sum += GRABPIXEL(0.09, -3.0);
          sum += GRABPIXEL(0.12, -2.0);
          sum += GRABPIXEL(0.15, -1.0);
          sum += GRABPIXEL(0.18,  0.0);
          sum += GRABPIXEL(0.15, +1.0);
          sum += GRABPIXEL(0.12, +2.0);
          sum += GRABPIXEL(0.09, +3.0);
          sum += GRABPIXEL(0.05, +4.0);

          half4 texcol = tex2D(_MainTex, i.uv);
          sum.a = texcol.a;
          return sum;
        }
        
        ENDCG
      }

      GrabPass {             
        Tags { "LightMode" = "Always" }
      }

      // Horizontal blur
      Pass {
        Name "HORIZONTAL"
        Tags { "LightMode" = "Always" }

        Blend SrcAlpha OneMinusSrcAlpha
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #pragma fragmentoption ARB_precision_hint_fastest
        #include "UnityCG.cginc"
         
        struct appdata_t {
          float4 vertex : POSITION;
          float2 texcoord: TEXCOORD0;
        };
         
        struct v2f {
          float4 vertex : POSITION;
          float4 uvgrab : TEXCOORD0;
          float2 uv : TEXCOORD1;
        };

        float4 _MainTex_ST;
         
        v2f vert (appdata_t v) {
          v2f o;
          o.vertex = UnityObjectToClipPos(v.vertex);
          #if UNITY_UV_STARTS_AT_TOP
          float scale = -1.0;
          #else
          float scale = 1.0;
          #endif
          o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y*scale) + o.vertex.w) * 0.5;
          o.uvgrab.zw = o.vertex.zw;
          o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
          return o;
        }
         
        sampler2D _GrabTexture;
        float4 _GrabTexture_TexelSize;
        float _Size;
        sampler2D _MainTex;
         
        half4 frag( v2f i ) : COLOR {
          half4 sum = half4(0,0,0,0);
 
          #define GRABPIXEL(weight,kernelx) tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(float4(i.uvgrab.x + _GrabTexture_TexelSize.x * kernelx * _Size * 0.2, i.uvgrab.y, i.uvgrab.z, i.uvgrab.w))) * weight
 
          sum += GRABPIXEL(0.05, -4.0);
          sum += GRABPIXEL(0.09, -3.0);
          sum += GRABPIXEL(0.12, -2.0);
          sum += GRABPIXEL(0.15, -1.0);
          sum += GRABPIXEL(0.18,  0.0);
          sum += GRABPIXEL(0.15, +1.0);
          sum += GRABPIXEL(0.12, +2.0);
          sum += GRABPIXEL(0.09, +3.0);
          sum += GRABPIXEL(0.05, +4.0);

          half4 texcol = tex2D(_MainTex, i.uv);
          sum.a = texcol.a;
           
          return sum;
        }
        
        ENDCG
      }
 
      // Distortion
      GrabPass {             
        Tags { "LightMode" = "Always" }
      }
      
      Pass {
        Tags { "LightMode" = "Always" }

        Blend SrcAlpha OneMinusSrcAlpha
        CGPROGRAM
        // Upgrade NOTE: excluded shader from DX11 and Xbox360; has structs without semantics (struct v2f members uv)
        // #pragma exclude_renderers d3d11 xbox360
        #pragma vertex vert
        #pragma fragment frag
        #pragma fragmentoption ARB_precision_hint_fastest
        #include "UnityCG.cginc"

        struct appdata_t {
          float4 vertex : POSITION;
          float2 texcoord: TEXCOORD0;
        };
         
        struct v2f {
          float4 vertex : POSITION;
          float4 uvgrab : TEXCOORD0;
          float2 uv : TEXCOORD1;
        };
         
        float4 _MainTex_ST;

        v2f vert (appdata_t v) {
          v2f o;
          o.vertex = UnityObjectToClipPos(v.vertex);
          #if UNITY_UV_STARTS_AT_TOP
          float scale = -1.0;
          #else
          float scale = 1.0;
          #endif
          o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y*scale) + o.vertex.w) * 0.5;
          o.uvgrab.zw = o.vertex.zw;
          o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
          return o;
        }
         
        half4 _TintColor;
        float _Vibrancy;
        sampler2D _GrabTexture;
        float4 _GrabTexture_TexelSize;
        sampler2D _MainTex;
        
        half4 frag( v2f i ) : COLOR {
          half4 col = tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(i.uvgrab));
          half4 texcol = tex2D(_MainTex, i.uv);
          col.r *= texcol.r;
          col.g *= texcol.g;
          col.b *= texcol.b;
          col.rgb *= 1 + _Vibrancy;
          col.a = texcol.a;
          col = lerp (col, _TintColor, _TintColor.w);
          return col;
        }
        
        ENDCG
      }
    }
  }
}

Material생성 후 해당 Shader적용 후 UI Image에 Material 적용.

반응형

'unity C#' 카테고리의 다른 글

[Unity] 화면보호기 끄기  (0) 2023.01.30
[Unity] 중첩 코루틴 Coroutine  (0) 2023.01.30
[Unity] VS Code Settings Sync  (0) 2022.12.26
[Unity] 암호화 복호화  (0) 2022.11.29
[Unity] mov파일 만들어 webm파일 사용하기  (0) 2022.02.04
반응형

깃허브 저장소를 무료호스팅으로 사용하는 방법을 간단히 기록.

 

1. Github 계정생성

2. Repository 생성

3. 파일 업로드

4. 끝

 

Github의 계정이 생성되어있다는 가정하에...

New를 클릭하여 새로운 저장소를 만든다.

Repository name을 적당히 만들고,

Public체크

Add a README file체크 후 

Create repository를 눌러 새 저장소를 만든다.

 

index.html이 포함 된 Publish할 파일을 드래그 드랍으로 저장소에 올리고

Commit changes를 눌른다.

저장소의 Settings > Pages로 들어간다.

Branch의 None을 눌러 main으로 선택 후 저장을 누른다.

주소는 GithubID(깃허브사용자아이디).github.io/Test(저장소이름)

으로 접속하면 해당 페이지가 열린다.

반응형
반응형

VS Code 설정 동기화하기

반응형

'unity C#' 카테고리의 다른 글

[Unity] 중첩 코루틴 Coroutine  (0) 2023.01.30
[Unity] UI Blur Shader  (0) 2023.01.05
[Unity] 암호화 복호화  (0) 2022.11.29
[Unity] mov파일 만들어 webm파일 사용하기  (0) 2022.02.04
[Unity] MQTT 통신 구현  (0) 2021.10.19
반응형
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace Study.Model
{
    public sealed class Crypto
    {
        protected RijndaelManaged myRijndael;
        private static string encryptionKey = "KEY 값";
        private static string initialisationVector = "IV값";
        // Singleton pattern used here with ensured thread safety 
        protected static readonly Crypto _instance = new Crypto();
        public static Crypto Instance
        {
            get
            {
                return _instance;
            }
        }
        public Crypto() { }

        //복호화 
        public string DecryptText(string encryptedString)
        {
            try
            {
                using (myRijndael = new RijndaelManaged())
                {
                    //key,iv 값의 인코딩방식에 따라 byte변환을 달리해야한다 
                    myRijndael.Key = HexStringToByte(encryptionKey);
                    myRijndael.IV = HexStringToByte(initialisationVector);
                    myRijndael.Mode = CipherMode.CBC;
                    myRijndael.Padding = PaddingMode.PKCS7;
                    Byte[] ourEnc = Convert.FromBase64String(encryptedString);
                    string ourDec = DecryptStringFromBytes(ourEnc, myRijndael.Key, myRijndael.IV);
                    return ourDec;
                }
            }
            catch (Exception e)
            {
                return encryptedString;
            }
        }

        //암호화 
        public string EncryptText(string plainText)
        {
            try
            {
                using (myRijndael = new RijndaelManaged())
                {
                    //key,iv 값의 인코딩방식에 따라 byte변환을 달리해야한다 
                    myRijndael.Key = HexStringToByte(encryptionKey);
                    myRijndael.IV = HexStringToByte(initialisationVector);
                    myRijndael.Mode = CipherMode.CBC;
                    myRijndael.Padding = PaddingMode.PKCS7;
                    byte[] encrypted = EncryptStringToBytes(plainText, myRijndael.Key, myRijndael.IV);
                    string encString = Convert.ToBase64String(encrypted);
                    return encString;
                }
            }
            catch (Exception e)
            {
                return plainText;
            }
        }

        //Byte를 EncryptString으로 변환 
        protected byte[] EncryptStringToBytes(string plainText, byte[] Key, byte[] IV)
        { 
            // Check arguments. 
            if (plainText == null || plainText.Length <= 0)
                throw new ArgumentNullException("plainText");
            if (Key == null || Key.Length <= 0)
                throw new ArgumentNullException("Key");
            if (IV == null || IV.Length <= 0)
                throw new ArgumentNullException("Key");
            byte[] encrypted;
            // Create an RijndaelManaged object 
            // with the specified key and IV. 
            using (RijndaelManaged rijAlg = new RijndaelManaged())
            {
                rijAlg.Key = Key; rijAlg.IV = IV;
                // Create a decrytor to perform the stream transform. 
                ICryptoTransform encryptor = rijAlg.CreateEncryptor(rijAlg.Key, rijAlg.IV);
                // Create the streams used for encryption. 
                using (MemoryStream msEncrypt = new MemoryStream())
                {
                    using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
                    {
                        using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
                        {
                            //Write all data to the stream. 
                            swEncrypt.Write(plainText);
                        }
                        encrypted = msEncrypt.ToArray();
                    }
                }
            }
            // Return the encrypted bytes from the memory stream. 
            return encrypted;
        }

        //Byte를 복호화된 스트링으로 변환 
        protected string DecryptStringFromBytes(byte[] cipherText, byte[] Key, byte[] IV)
        {
            // Check arguments. 
            if (cipherText == null || cipherText.Length <= 0)
                throw new ArgumentNullException("cipherText");
            if (Key == null || Key.Length <= 0)
                throw new ArgumentNullException("Key");
            if (IV == null || IV.Length <= 0)
                throw new ArgumentNullException("Key");
            // Declare the string used to hold // the decrypted text. 
            string plaintext = null;
            // Create an RijndaelManaged object // with the specified key and IV. 
            using (RijndaelManaged rijAlg = new RijndaelManaged())
            {
                rijAlg.Key = Key;
                rijAlg.IV = IV;
                // Create a decrytor to perform the stream transform. 
                ICryptoTransform decryptor = rijAlg.CreateDecryptor(rijAlg.Key, rijAlg.IV);
                // Create the streams used for decryption. 
                using (MemoryStream msDecrypt = new MemoryStream(cipherText))
                {
                    using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
                    {
                        using (StreamReader srDecrypt = new StreamReader(csDecrypt))
                        {
                            // Read the decrypted bytes from the decrypting stream // and place them in a string. 
                            plaintext = srDecrypt.ReadToEnd();
                        }
                    }
                }
            }
            return plaintext;
        }

        //BASE64 인코딩된 키 , IV 값 Byte변환 
        protected static byte[] Base64StringToByte(string base64String)
        {
            try
            {
                return Convert.FromBase64String(encryptionKey);
            }
            catch (Exception e)
            {
                throw;
            }
        }

        //UTF8 인코딩된 키 , IV 값 Byte변환 
        protected static byte[] Utf8StringToByte(string utf8String)
        {
            try
            {
                byte[] bytes = Encoding.UTF8.GetBytes(utf8String);
                return bytes;
            }
            catch (Exception e)
            {
                throw;
            }
        }

        //HexString KEY , IV 값 Byte변환 
        protected static byte[] HexStringToByte(string hexString)
        {
            try
            {
                int bytesCount = (hexString.Length) / 2;
                byte[] bytes = new byte[bytesCount];
                for (int x = 0; x < bytesCount; ++x)
                {
                    bytes[x] = Convert.ToByte(hexString.Substring(x * 2, 2), 16);
                }
                return bytes;
            }
            catch (Exception e)
            {
                throw;
            }
        }
    }
}
반응형

'unity C#' 카테고리의 다른 글

[Unity] UI Blur Shader  (0) 2023.01.05
[Unity] VS Code Settings Sync  (0) 2022.12.26
[Unity] mov파일 만들어 webm파일 사용하기  (0) 2022.02.04
[Unity] MQTT 통신 구현  (0) 2021.10.19
[Unity] Tetris 게임 만들기  (1) 2021.06.25
반응형

스다스하 촬영지 월곡산 애기능터 밤풍경 

반응형

'맛집' 카테고리의 다른 글

성수동 할아버지공장  (0) 2020.06.29
반응형

유니티에서 투명 한 애니메이션을 가져오는 방법은 png시퀀스로 가져와 애니메이터에 넣어 사용하는 방식이 간편하고 좋아서 웬만한 투명 애니메이션은 가능하면 png시퀀스로 사용해 왔었다.

하지만 영상으로 가져와서 사용할 수 있는 방법을 찾던 중 webM파일로 가져와서 간단하게 사용하는 방식이 있어 정리해본다.

 

1. 배경이 투명 한 mov 영상파일을 만든다.

2. mov파일을 webM파일로 컨버팅 한다.

3. 유니티에 webM파일을 임포트해서 VideoClip으로 가져와 VideoPlayer에 넣어 사용한다.

 

일단 인터넷에 검색하면 나오는 클라우드 컨버팅으로 이것저것 다 해봤지만 잘 되지 않았다.

내가 사용했던 되는 방식을 그대로 정리한다.

 

애팩에서 유니티에서 사용할 애니메이션클립을 제작하고 배경을 투명하게 세팅한다. 컴포지션 창 왼쪽 하단에 투명하게 해주는 아이콘이 있으니 확인해서 클릭.

 

File / Export / Add to Render Queue 클릭해서

Output Module 옆에 Lossless클릭

알파채널을 추가해서 설정해 준 후 ok클릭.

적당한 이름으로 랜더를 눌러 mov 파일을 뽑아준다.

 

1-Click Video Converter를 실행하고 좌상단 Add File을 눌러 mov파일을 불러온다.

불러온 파일 오른쪽에 아웃풋 영상을 선택할 수 잇는데 클릭. (캡쳐화면에는 AVI라는 아이콘)

종류가 많은데... General Video를 클릭하고 아래로 내리다 보면 WebM이라고 보인다. 맨 아랫쪽에 더 내리면 WebM vp9이라고도 있는데 이걸로 하면 유니티 에디터에서 지원하지 않는다는 에러가 난다. 첫번째로 보이는 WebM으로 선택.

하단에 보이는 Profile옆에 Settings를 클릭.

아래와 같이 Keep Original로 설정하고 ok를 눌러준다.

유니티로 파일을 드래그해서 가져온 후 아래처럼 설정한다.

... 비디오클립/비디오 설정
[SerializeField] VideoClip m_FindImageClip;
[SerializeField] VideoPlayer m_VideoPlayer;


... 사용할 때 ...
m_VideoPlayer.clip = m_FindImageClip;
m_VideoPlayer.Play();
반응형

'unity C#' 카테고리의 다른 글

[Unity] VS Code Settings Sync  (0) 2022.12.26
[Unity] 암호화 복호화  (0) 2022.11.29
[Unity] MQTT 통신 구현  (0) 2021.10.19
[Unity] Tetris 게임 만들기  (1) 2021.06.25
[Unity] 스도쿠게임 만들기  (0) 2021.06.15
반응형

https://github.com/eclipse/paho.mqtt.m2mqtt

 

GitHub - eclipse/paho.mqtt.m2mqtt

Contribute to eclipse/paho.mqtt.m2mqtt development by creating an account on GitHub.

github.com

 

요거 가져다 사용하면 문제 없이 잘 된다.

단 주의할것들은...

 

Project Settings / Player / Other Settings 에서

위에 보이는 Api Compatibility Level을 .NET 4.x로 해주고

Scipt Compilation 하단에 SSL이라고 입력해줘야 한다.

 

 

참고>

https://medium.com/@jspark141515/mqtt란-314472c246ee

 

MQTT란?

MQTT는 M2M, IOT를 위한 프로토콜로서, 최소한의 전력과 패킷량으로 통신하는 프로토콜입니다. 따라서 IOT와 모바일 어플리케이션 등의 통신에 매우 적합한 프로토콜입니다.

medium.com

https://hamait.tistory.com/390

 

MQTT 와 모스키토(Mosquitto) 란 무엇인가?

MQTT 시작하기 좋은 글 https://dzone.com/refcardz/getting-started-with-mqtt MQTT 란? (http://www.codejs.co.kr/mqtt-mq-telemetry-transport%EC%9D%B4%ED%95%B4%ED%95%98%EA%B8%B0/ 펌) [MQTT 프로토콜 설계..

hamait.tistory.com

http://lemonheim.blogspot.com/2017/01/mqtt-mosquitto-mac.html

 

MQTT mosquitto 서버 Mac 설치/ 테스트

lemonheim's program note

lemonheim.blogspot.com

 

반응형

'unity C#' 카테고리의 다른 글

[Unity] 암호화 복호화  (0) 2022.11.29
[Unity] mov파일 만들어 webm파일 사용하기  (0) 2022.02.04
[Unity] Tetris 게임 만들기  (1) 2021.06.25
[Unity] 스도쿠게임 만들기  (0) 2021.06.15
[Unity] UDP 통신  (0) 2021.05.04
반응형

클라이언트가 3D Asset을 FBX가 아닌 SFB로 요청이 왔다. 안드로이드 ARcore에서 사용하는 리소스 방식인듯 한데 일단 좀 찾아보니 안드로이드 스튜디오에 Google Sceneform Tools이라는 플러그인을 설치하라고 한다.

 

아래 링크에 나와있는대로 열심히 따라해 봤는데 안된다.

 

https://developers.google.com/sceneform/develop/import-assets

 

Import and preview 3D assets  |  Sceneform (1.15.0)  |  Google Developers

Learn how to import 3D models, convert them into Sceneform format, and preview them in Android Studio. Note: To import and work with 3D models in Sceneform, ensure you have installed the Google Sceneform Tools (Beta) plugin. Import a new 3D asset Sceneform

developers.google.com

https://learn-and-give.tistory.com/4

 

[sceneform]#3. model 변경하기

 ARCore 문서에 있는 다른 내용들을 해 보려고 하는데, 쉽지 않네요.  특히, lambda 표현식 때문에 샘플 코드들이 오히려 더 한 눈에 딱 들어오지 않네요. 타입 지정하지 않고 사용되는 변수들이 그

learn-and-give.tistory.com

https://blog.naver.com/jogilsang/221754738905

 

안드로이드 AR앱 - 2편 Import Sceneform Asset 하는법, "Import Sceneform Asset" option not shown on right click

1. Import Sceneform Asset 세팅 Settings에서 Plugins에서 Sceneform을 다운받는다. 2. 모델을 구한...

blog.naver.com

 

문제는 2021년 7월 20일 기준으로 최신버전 Android Studio에서는 안된다는 것이다.

그렇다면 되는 버전은? 어딘가에 표기되어있을것도 같은데 못찾겠다 ㅠㅠ

아무튼 최신버전으로 안드로이드스튜디오를 설치하고 플러그인을 설치하면 아래와 같은 에러메세지가 나온다.

안드로이드를 다뤄보지 않은 입장에서 저 애러가 뭔지 몰랐는데 나중에 알고보니 

IDE 플랫폼을 이야기 하는것이었던 것이다 ㅠㅠ

 

https://developer.android.com/studio/archive

 

Android 스튜디오 다운로드 자료실  |  Android 개발자  |  Android Developers

이 페이지에는 Android 스튜디오 출시 관련 다운로드 자료실이 포함되어 있습니다.

developer.android.com

버전 진짜 많아~ ㅠ

일단 플러그인이 처음 개발되어 배포된 시기가 2018년도 5월 인듯 한데 그렇다면 그 당시에 안드로이드 스튜디오 버전이 무엇인고?

3.1 ~3.4 버전인듯 하다.

일단 3.4.1버전에서 잘되는듯 하다.

플러그인을 설치하는 방법은 Preferences를 열고

좌측의 Plugins탭을 클릭 한 후,  Google Sceneform Tools (Beta)를 검색해서 설치해준다.

이렇게 임포트 하고 나면 이제 fbx를 적당한 폴더에 위치한 후 마우스 우클릭 해보면 아래와 같이 Import Sceneform Asset이라는 메뉴가 나오게 된다.

Finish버튼을 누르면 큰문제 없이 변환이 되는듯 하다.

반응형

+ Recent posts