Created
November 2, 2017 18:14
-
-
Save tatmos/b70ff832d29d6c15a15a59d1014005a6 to your computer and use it in GitHub Desktop.
ADX2LEの音量でパーティクルシステムをコントロールしているSoundManager。MusicEngine使ってる。
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; | |
using System.Collections; | |
public class SoundManager : MonoBehaviour | |
{ | |
public static CriAtomSource atomSource; | |
public ParticleSystem heartParticle; | |
// Use this for initialization | |
void Start() | |
{ | |
atomSource = GetComponent<CriAtomSource>(); | |
GameObject heartGetParticleObj = GameObject.Find("HeartParticle"); | |
if (heartGetParticleObj != null) | |
{ | |
heartParticle = heartGetParticleObj.GetComponent<ParticleSystem>(); | |
} | |
} | |
bool particlePlay = false; | |
GameObject lastColliderObj; | |
// Update is called once per frame | |
void Update() | |
{ | |
// if (Input.GetMouseButtonDown (0)) | |
{ | |
{ | |
Vector3 mousePos = Input.mousePosition; | |
mousePos.z = 10.0f; | |
Vector2 tapPoint = Camera.main.ScreenToWorldPoint(mousePos); | |
// Debug.Log("pos " + Input.mousePosition + " " + tapPoint); | |
Collider2D collider = Physics2D.OverlapPoint(tapPoint); | |
if (collider != null) | |
{ | |
if (heartParticle != null && lastColliderObj != collider.gameObject) | |
{ | |
Debug.Log("hit " + collider.gameObject.name + " " + Input.mousePosition); | |
heartParticle.gameObject.transform.position = collider.gameObject.transform.position; | |
heartParticle.Emit(10); // ハートパーティクル | |
OnPlay(); | |
particlePlay = true; | |
lastColliderObj = collider.gameObject; | |
// GameObject obj = collider.transform.gameObject; | |
// Destroy (obj); | |
} | |
} else | |
{ | |
if (particlePlay) | |
{ | |
// Debug.Log("not hit "); | |
particlePlay = false; | |
} | |
} | |
} | |
} | |
} | |
public void OnPlay() | |
{ | |
Music.QuantizePlay(atomSource); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment