본문 바로가기

전체 글

(307)
서브 쓰레드에서 메인 쓰레드 이용하기 글 쓰기 앞서서 쓰려고 하는 내용이 제목에 부합되는지는 정확히는 모르겠다. 하지만 내가 알고있는 메인 쓰레드와 추가로 사용되는 쓰레드는 분명히 다르다는걸 알기에 저렇게 적어본다. ---- ---- 안드로이드를 사용하다가 유니티에서는 잘 사용하지 않는 몇몇가지를 경험했다. 그중에 액티비티를 생성하고 접근할때 생성한 액티비티에 static 변수를 oncreate 에서 초기화 하고 사용한다는것. 쓰레드를 사용할때 Handler를 사용한다는것. 그중에 Handler 사용법에 대해 알아보자. A의 액티비티에서 타이머기능을 Thread로 생성하여 일정 시간이 되면 B의 액티비티의 다이얼로그를 B의 static 변수로 켜고 끄는 코드를 넣었다. 그러던중 메인 쓰레드에서 handler를 사용할수없다는 에러가 나왔다. ..
안드로이드 스튜디오 다이얼로그 관련 시도 : 앱이 Background상태에서 다이얼로그를 호출하려 했지만 불가능한것으로 확인 대안 : Foreground에서 Activity를 투명으로 하고 다이얼로그를 띄운다고 함. 라고 알고있었으나 ---- ---- Update!!!! Intent로 다른 앱 위에 Activity를 생성하고 그 위에 Dialog를 띄우는것을 성공~! Intent mIntent = new Intent(MainActivity.this, (사용할 액티비티 클래스)MyDialogClass.class); mIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); MainActivity.this.getApplicationContext..
안드로이드 스튜디오 플러그인 만들기 (2018.11.03) : aar 형식 ㅁ 유의점 1. 패키지 이름은 유니티 프로젝트의 패키지 이름과 같지 않게 한다. 2. NDK가 설치되지 않아도 된다. 3. 유니티에서 classes.jar 파일을 가져올 필요가 없다. ---- ---- ㅁ 작업환경 유니티 : 2017.4.8f1 안드로이드 스튜디오 : 3.2.1 스크린샷을 참고해서 순서대로 하시면 됩니다. 1. 기본 프로젝트 만들기 ※ 패키지 명은 임의대로 하셔도 됩니다. 여기까진 특별할것이 없는 기본 프로젝트를 만드시면 됩니다. 2. 모듈 추가하기 ※ 유니티에서 호출할 함수를 넣을 클래스를 만듭시다. ※ 유니티에서 문자형 인자를 넘겨줘서 잘 받는지 확인하고 TEST OK 란 문자열을 리턴 받습니다. ※ 빌드를 해줍니다. ※ 위의 경로에서 aar 파일을 유니티 폴더에 복사합니다. ※ 유니..
UGUI - UI Button OnClick 리스너 비활성화 스크립트로 RemoveallListeners가 기능을 하지 않은것같아서 찾아본결과 a_bt.onClick.SetPersistentListenerState (0, UnityEngine.Events.UnityEventCallState.Off); 이런 식으로 0번째있는 리스너를 oFF 상태로 변경할수있다.
파일) Unity Resource폴더와 저장소의 바이너리파일 읽기 (re : 2019.05.07) public BinaryReader PlayFileToBinary (string _fname) { TextAsset _textAsset = Resources.Load (_fname) as TextAsset; Stream _s; //if file not exist read from device storage if (_textAsset == null) { _s = GetBinaryFileStream (_fname); } else { _s = new MemoryStream (_textAsset.bytes); } BinaryReader br = new BinaryReader (_s, Encoding.Default); return br; } //get file from device storage public St..
파일) Line단위로 쓰기 public void MakeFile (List _stringListA, string _fname) { string a_filePath = GetFilePath (_fname); FileStream a_fstrem = new FileStream (a_filePath, FileMode.Create, FileAccess.Write); StreamWriter a_sw = new StreamWriter (a_fstrem); ---- ---- for (int i = 0; i < _stringListA.Count; i++) { a_sw.WriteLine (_stringListA [i]); } a_sw.Close (); a_fstrem.Close (); }
파일) Path string GetFilePath (string _fname) { string _path = ""; if (Application.platform == RuntimePlatform.Android) { _path = Application.persistentDataPath; _path = _path.Substring (0, _path.LastIndexOf ('/')); } else if (Application.platform == RuntimePlatform.IPhonePlayer) { _path = Application.dataPath.Substring (0, Application.dataPath.Length - 5); _path = _path.Substring (0, _path.LastIndexOf ('/..
문자열) 숫자에 , (콤마) 넣기 public string InsertComma (string _string, int offset = 0) { int _length = _string.Length; string _endInitial = ""; ---- ---- if (_length >= 10 - offset && _length = 13 - offset && _length = 16 - offset && _length 0){ for (int _stringIndex = _length-1; _stringIndex >= 0 ; _stringIndex--) { if (_index%3 == 0 && _index != _length) { _string = _string.Insert(_stringIndex, ","); } _index++; } } if (..