Skip to content

Instantly share code, notes, and snippets.

@rawo2010
rawo2010 / AutoDestoryPartcles.cs
Created March 1, 2018 05:54
AutoDestoryPartcles
using UnityEngine;
using System.Collections.Generic ;//Use :System.Collections.Generic.List<>.
//ChildrenのDurationにも対応したパーティクル自動削除スクリプト
[RequireComponent(typeof(ParticleSystem))]
public class AutoDestoryPartcles : MonoBehaviour {
// Use this for initialization
void Start () {
using UnityEngine ;
[RequireComponent(typeof(ParticleSystem))]
public class AutoDestoryPartcle : MonoBehaviour {
void Start () {
ParticleSystem partcleSystem = GetComponent<ParticleSystem>() ;
//Delete object after duration.
Destroy(gameObject,(float)partcleSystem.main.duration ) ;
}
@rawo2010
rawo2010 / AutoDestroyInstantiate.cs
Last active March 1, 2018 03:54
AutoDestroyInstantiate
[SerializeField]
GameObject partclePrefab = null ;//inspector上でParticleSystemがアタッチされたGameObjectを設定してください。
//関数名は仮定義 関数で使わなくとも,Instantiateを呼び出している部分を差し替えしてもよい.
// その際,Instantiateの第二引数以降は差し替え前のものを使用すること.
void AutoDestroyInstantiate(){
Destroy(Instantiate(partclePrefab),partclePrefab.GetComponent<ParticleSystem>().main.duration ) ;
}
@rawo2010
rawo2010 / Ball.cs
Last active March 7, 2018 02:05
ContactPointsExample of use Raw
//Update内でPositionに加算するなりしてください。
Vector3 vecocity = new Vector3(0,0,0);
//衝突したとき の イベント
private void OnCollisionEnter(Collision collision)
{
Vector3 normal = Vector3.zero ;
//法線ベクトルを取得