Last active
October 24, 2016 02:49
-
-
Save tsubaki/ef1733693aca182add718da17328460b to your computer and use it in GitHub Desktop.
タップした位置にパーティクルエフェクトを追加する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class TapEffect : MonoBehaviour | |
{ | |
[SerializeField] ParticleSystem tapEffect; // タップエフェクト | |
[SerializeField] Camera _camera; // カメラの座標 | |
void Update() | |
{ | |
if(Input.GetMouseButtonDown(0)) | |
{ | |
// マウスのワールド座標までパーティクルを移動し、パーティクルエフェクトを1つ生成する | |
var pos = _camera.ScreenToWorldPoint(Input.mousePosition + _camera.transform.forward * 10); | |
tapEffect.transform.position = pos; | |
tapEffect.Emit(1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment