유니티 파티클


ParticleSystem testParticle         = null;
 
// 버튼이 눌러졌을때
if (Input.GetMouseButtonUp(0) == true)
{
    // 파티클이 있고
    if (testParticle)
    {
        // 파티클이 재생중이면 재생을 멈추고 지워줍니다
        if (testParticle.isPlaying == true)
        {
            testParticle.Stop();
            testParticle.Clear();   
 
            //Debug.Log("STOP");
        }
        // 재생중이 아니라면 재생해주고요
        else
        {
            testParticle.Play();
 
            //Debug.Log("PLAY");
        }
    }
    // 파티클이 없다면 새로 만들어주구요
    else
    {
        Vector3 pos       = Vector3.zero;
        pos.y               = 3;
        pos.x               = 3 - 30.0f;
 
        Transform particleObject        = (Transform)Instantiate(Resources.Load("Prefabs/Effects/pfBlockBomb", typeof(Transform)), pos, Quaternion.identity);
 
        testParticle        = (ParticleSystem)particleObject.GetComponent(typeof(ParticleSystem));
 
        //Debug.Log("CREATE");
    }
 
    return;
}
출처 : http://kookiandkiki.blogspot.com/2013/12/unity3d.html

댓글

이 블로그의 인기 게시물

유니티 오브젝트 서서히 사라지게

WebView에서 YOUTUBE 동영상 플레이 방법