2012년 12월 29일 토요일

CMake Could not create named generator Visual Studio

If you already installed Cygwin with cmake package, cmake command will execute in cygwin which does not support Visual Studio.

In this case, modify cmake command to full path of cmake like "C:\Program Files (x86)\CMake 2.8\bin\cmake.exe".

2012년 12월 23일 일요일

Unity3D Rotate GameObject with mouse

using UnityEngine;
using System.Collections;

public class RotateWithMouse : MonoBehaviour {
 
 public float sensitivityX = 15.0f;
 public float sensitivityY = 15.0f;
 private Transform cameraTm;
 
 public bool down = false;

 // Use this for initialization
 void Start ()
 {
  cameraTm = Camera.mainCamera.transform;
 }
 
 // Update is called once per frame
 void Update () {
  if( Input.GetMouseButtonDown( 0 ) )
   down = true;
  else if( Input.GetMouseButtonUp( 0 ) )
   down = false;
  
  if( down )
  {
   float rotationX = Input.GetAxis("Mouse X") * sensitivityX;
   float rotationY = Input.GetAxis("Mouse Y") * sensitivityY;
   transform.RotateAroundLocal( cameraTm.up, -Mathf.Deg2Rad * rotationX );
   transform.RotateAroundLocal( cameraTm.right, Mathf.Deg2Rad * rotationY );
  }
 }
}

2012년 10월 22일 월요일

Android likes a post on Facebook

public void onClick(View v) {

    Bundle params = new Bundle();
    params.putString("post_id", mPostId);
    params.putString(Facebook.TOKEN, mFacebook.getAccessToken());
                
    mAsyncRunner.request("/"+mPostId+"/likes", params, "POST", new LikeListener(), null);
}
public class LikeListener extends BaseRequestListener
{
    public void onComplete(final String response, final Object state)
    {
        public void run()
        {
            mText.setText("Liked!");
        }
    }
}

2012년 7월 20일 금요일

Unity3D Billboard

using UnityEngine;
using System.Collections;

public class Billboard : MonoBehaviour
{
 // Update is called once per frame
 void LateUpdate () {
  // Billboard
  transform.rotation = Camera.main.transform.rotation;
 }
}

2012년 6월 1일 금요일

Unity3D Rotate transform to vector direction

Vector3 direction;
transform.rotation = Quaternion.FromToRotation(Vector3.forward, direction);
or
Vector3 direction;
transform.forward = direction;

2012년 5월 3일 목요일

JavaScript Difference between == and ===

=== and !== are strict comparison operators

0==false // true
0===false // false, because they are of a different type
1=="1" // true, auto type coercion
1==="1" // false, because they are of a different type

Difference between == and === in JavaScript [closed]

2012년 4월 15일 일요일

HTC Desire add notification sound & ring tone

Hi All,
you can put your own mp3 file for your ring tones or notifications

create folder in SD card root folder. named by media/audio/ringtones for ringtone.
create folder in SD card root folder. named by media/audio/notifications for notifications.

http://www.htcdesireforum.com/htc-desire-how-to/changing-sms-alert-tone/

2012년 3월 13일 화요일

Unity3D Korean input with EZGUI UITextField

To input Korean on UITextField, add this line when UITextField was focused or entiry point of UIManager.

Input.imeCompositionMode = IMECompositionMode.On;

Unity3D의 EZGUI에서 한글 입력이 안될 때, 위의 한 줄을 추가하면 한글 입력이 가능하다.
UITextField가 Focus 되었을 때나, 한 번만 적용하면 된다.
하지만 조합 중인 글자는 보이지 않는다.

2012년 3월 12일 월요일

Android ImageView grayscale filter

public static void setGrayScale(ImageView v){
    ColorMatrix matrix = new ColorMatrix();
    matrix.setSaturation(0); //0 means grayscale
    ColorMatrixColorFilter cf = new ColorMatrixColorFilter(matrix);
    v.setColorFilter(cf);
}

이미지에 grayscale효과 주기

2012년 3월 3일 토요일

Unity3D in 3.4 version there is a bug Texture2D to save PNG file on Android platform.

In Unity3D 3.5, this bus was fixed.

Fixes
Android
Texture2D.EncodeToPNG() / Application.CaptureScreenshot() produced broken images.

In 3.4 I used JPGEncoder instead of Texture2D.EncodeToPNG().
Original JPGEncoder with javascript is here
And with C# version are here(thread) and here(zip file)

Now, I'll try JPGEncoder with C#.

2012년 3월 1일 목요일

iOS 5 ASIHTTPRequest sent twice

If you wish to prevent your ASIHTTPRequest GET sometimes sending 2 or more server requests (due to network issues outside your control) you can simply set this flag:

request.shouldAttemptPersistentConnection = NO;

ASIHTTPRequest, request sent twice

2012년 2월 16일 목요일

iOS How to get current app version

[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]
will return current your app version.

ex)
NSLog([NSString stringWithFormat:@"Version %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]);

How can my iphone app detect its own version number?

2012년 2월 5일 일요일

iOS Play Sound Effects

1. AudioServicesPlaySystemSound : Cannot control sound volume
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:path ofType:@"wav"]];

if( soundID[index] == -1 )
AudioServicesCreateSystemSoundID((CFURLRef)url, &soundID[index]);

AudioServicesPlaySystemSound(soundID[index]);
2. AVAudioPlayer : Cannot use iPod/iPhone native music player
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:path ofType:@"wav"]];

NSError *error;

AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
[player play];
3. CocosDenshion : With configure mode param, can use iPod/iPhone native music player and control sound volume
// initialize
[CDAudioManager configure:kAMM_FxOnly];

NSString *effect = [[NSBundle mainBundle] pathForResource:path ofType:@"wav"];

if( soundID[index] == -1 )
{
[[SimpleAudioEngine sharedEngine] preloadEffect:effect];
soundID[index] = 1;
}

[[SimpleAudioEngine sharedEngine] playEffect:effect];

2012년 2월 2일 목요일

iOS AudioServicesPlaySystemSound Play Sound

1. 필요한 framework
AudioToolbox.framework

2. include header file
#import

3. Create and play sound
// create & play
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)url, &soundID);
AudioServicesPlaySystemSound(soundID);

4. Release resource
// release
AudioServicesDisposeSystemSoundID(soundID);

2012년 2월 1일 수요일

Android GC줄이기

onMeasure()
onLayout()
onDraw()
dispatchDraw()
onTouchEvent()
dispatchTouchEvent()
getView()
bindView()

메소드 내에서 객체생성을 줄이자

http://goo.gl/OYeuD

2012년 1월 31일 화요일

Google Chrome 에서 Flash Debugger 연결하기

1. 주소창에 chrome://plugins 를 입력한다.
2. 상단에 보이는 details 버튼을 누른다. (Chrome 6.x 이상의 버전에서만 가능하다.)
3. Flash 라고 써 있는 것들 중에 다음의 경로를 포함하는 플러그인은 사용 해제한다.
$HOME/AppData/Local/Google/Chrome/Application/chrome_version/gcswf32.dll

GOOGLE CHROME FLASH DEBUGGER NOT CONNECTING TO FLEX/FLASH BUILDER?