검색결과 리스트
전체글보기에 해당되는 글 44건
- 2018.11.07 AES256 암호화, 복호화
- 2018.10.26 클래스 리스트를 클래스 안에있는 정보로 정렬하는법
- 2018.10.19 유니티에서 파이어베이스 아이콘 설정
- 2018.01.29 2D상에서의 각도를 기반으로 회전값 구하기
- 2018.01.03 유니티에서 비동기적으로 scene을 불러오며 progress를 얻는 방법
- 2017.12.24 Tiled GPU perf. warning: RenderTexture color surface (0x0) was not cleared/discarded, doing <run with profiler for info> 경고 2
- 2017.12.20 RectTransform Min Max
- 2017.11.11 코드 실행시간 측정 방법
- 2017.11.09 LitJson
- 2017.10.28 php, mysql 한글 깨짐
글
AES256 암호화, 복호화
암호화
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
private AES256Encrypt(string _Data)
{
byte[] plainBytes = System.Text.Encoding.UTF8.GetBytes(_Data);
System.Security.Cryptography.RijndaelManaged rm = new System.Security.Cryptography.RijndaelManaged
{
Mode = System.Security.Cryptography.CipherMode.CBC,
Padding = System.Security.Cryptography.PaddingMode.PKCS7,
KeySize = 256
};
MemoryStream memoryStream = new MemoryStream();
System.Security.Cryptography.ICryptoTransform encryptor = rm.CreateEncryptor(
System.Text.Encoding.UTF8.GetBytes("01234567890123456789012345678901".Substring(0, 256 / 8)),
System.Text.Encoding.UTF8.GetBytes("01234567890123456789012345678901".Substring(0, 128 / 8)));
System.Security.Cryptography.CryptoStream cryptoStream = new System.Security.Cryptography.CryptoStream(memoryStream, encryptor, System.Security.Cryptography.CryptoStreamMode.Write);
cryptoStream.Write(plainBytes, 0, plainBytes.Length);
cryptoStream.FlushFinalBlock();
byte[] encryptBytes = memoryStream.ToArray();
string encryptString = System.Convert.ToBase64String(encryptBytes);
cryptoStream.Close();
memoryStream.Close();
return encryptString;
}
|
cs |
복호화
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
private string AES256Decrypt()
{
byte[] encryptBytes = System.Convert.FromBase64String(o);
System.Security.Cryptography.RijndaelManaged rm = new System.Security.Cryptography.RijndaelManaged
{
Mode = System.Security.Cryptography.CipherMode.CBC,
Padding = System.Security.Cryptography.PaddingMode.PKCS7,
KeySize = 256
};
MemoryStream memoryStream = new MemoryStream(encryptBytes);
System.Security.Cryptography.ICryptoTransform decryptor = rm.CreateDecryptor(
System.Text.Encoding.UTF8.GetBytes("01234567890123456789012345678901".Substring(0, 256 / 8)),
System.Text.Encoding.UTF8.GetBytes("01234567890123456789012345678901".Substring(0, 128 / 8)));
System.Security.Cryptography.CryptoStream cryptoStream = new System.Security.Cryptography.CryptoStream(memoryStream, decryptor, System.Security.Cryptography.CryptoStreamMode.Read);
byte[] plainBytes = new byte[encryptBytes.Length];
int plainCount = cryptoStream.Read(plainBytes, 0, plainBytes.Length);
string plainString = System.Text.Encoding.UTF8.GetString(plainBytes, 0, plainCount);
cryptoStream.Close();
memoryStream.Close();
return plainString;
}
|
cs |
설정
트랙백
댓글
글
클래스 리스트를 클래스 안에있는 정보로 정렬하는법
List<TestClass> Test = new List<TestClass>();
Test.Sort(delegate(TestClass t1, TestClass t2) { return t1.date.CompareTo(t2.date); });
설정
트랙백
댓글
글
유니티에서 파이어베이스 아이콘 설정
아이콘을 Assets/Plugins/Android/firebase/res/drawable 폴더에 넣는다.
Assets/Plugins/Android/AndroidManifest.xml을 수정한다.
1 2 3 4 5 6 7 8 | <manifest> <application ...> <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/my_sweet_icon" /> <activity ... > </activity> </application> <manifest> | cs |
설정
트랙백
댓글
글
2D상에서의 각도를 기반으로 회전값 구하기
void Start()
{
// z축 +180은 이미지 방향에 따라 수정하여 적용.
// target1은 자신의 객체가 아닌 비교할 해당 객체.
transform.eulerAngles = new Vector3(0, 0, -getAngle(transform.position.x, transform.position.y, target1.position.x, target1.position.y) + 180.0f);
}
private float getAngle(float x1, float y1, float x2, float y2)
{
float dx = x2 - x1;
float dy = y2 - y1;
float rad = Mathf.Atan2(dx, dy);
float degree = rad * Mathf.Rad2Deg;
return degree;
}
출처: http://redccoma.tistory.com/110
설정
트랙백
댓글
글
유니티에서 비동기적으로 scene을 불러오며 progress를 얻는 방법
using UnityEngine;
using System.Collections;
public delegate void ProgressDelegate(float progress);
public class MyScript {
public void OnStartMyScene() {
StartCoroutine(LoadSceneAsyncByName("MySceneName", OnLoadLevelProgressUpdate));
}
public static IEnumerator LoadSceneAsyncByName(string nextLevel, ProgressDelegate progressDelegate) {
AsyncOperation async = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(nextLevel);
while (!async.isDone) {
progressDelegate (async.progress);
async.allowSceneActivation = async.progress > 0.8;
yield return null;
}
}
private void OnLoadLevelProgressUpdate(float progress) {
Debug.Log ("async.progress: " + progress);
}
}
출처: http://crowjdh.blogspot.kr/2016/07/scene-progress-c.html
설정
트랙백
댓글
글
Tiled GPU perf. warning: RenderTexture color surface (0x0) was not cleared/discarded, doing <run with profiler for info> 경고
Tiled GPU perf. warning: RenderTexture color surface (0x0) was not cleared/discarded, doing <run with profiler for info>
경고가 뜰때가 있다.
카메라를 여러대 사용할 때 나온다고 대부분 말을 합니다.
https://forum.unity.com/threads/4-2-any-way-to-turn-off-the-tiled-gpu-perf-warning.191906/
주로 여기서 내용을 다뤘으며
카메라 한대의 Depth를 -1로 바꾸면 가능하면 Clear Flags를 Solid Color로 바꿔서 사용하자.
설정
트랙백
댓글
글
RectTransform Min Max
Min.x = Left
Min.y = Bottom
Max.x = -Right
Max.y = -Top
설정
트랙백
댓글
글
코드 실행시간 측정 방법
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
코드 실행
sw.Stop();
Debug.Log(sw.ElapsedMilliseconds.ToString() + "ms");
설정
트랙백
댓글
글
글
php, mysql 한글 깨짐
서버의 /etc/my.cnf 수정
/etc/my.enf에 다음 구문을 추가한뒤 mysqld를 재시작한다.
[mysqld]
collation-server=utf8_unicode_ci
default-character-set=utf8
character-set-server=utf8
init_connect=set collation_connection=utf8_unicode_ci
init_connect=set names utf8
(mysql 5.5 버전 이상에서는 collation-server와 default-character-set은 추가하지 마세요. 버전업 되면서 파라미터가 변경되어 추가하면 mysql 서비스가 실행이 안됩니다.
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
출처: http://luckyyowu.tistory.com/279