16/01/14 22:13:33.92 Q2ZA3yWj.net
>>36
目的がシンプルなのでやり方は色々あるね
例えばUnityEventメンバ変数持てばインスペクタやスクリプトからも処理を追加出来る様になる
public class Ball{
public UnityEvent Destroy;
void OnDestroy(){
Destroy.Invoke();
}
}
public class Player{
int ballcount
void Shoot(){
if(ballcount>=maxBallCount)return;
Ball b =.Instantinate(prefab);
b.Destroy.AddListener(OnBallDestroy);
//射出時の処理諸々
ballcount++;
}
void OnBallDestroy(){
ballcount--;
}
}