FInstantiateEvent.cs 525 B

1234567891011121314151617181920212223242526272829
  1. using UnityEngine;
  2. namespace Flux
  3. {
  4. //[FEvent("Game Object/Instantiate")]
  5. public class FInstantiateEvent : FEvent
  6. {
  7. [SerializeField]
  8. private GameObject _prefab = null;
  9. private GameObject _instance;
  10. protected override void OnTrigger( float timeSinceTrigger )
  11. {
  12. _instance = (GameObject)Instantiate( _prefab );
  13. }
  14. protected override void OnStop ()
  15. {
  16. if( _instance != null )
  17. {
  18. if( Application.isPlaying )
  19. Destroy( _instance );
  20. else
  21. DestroyImmediate( _instance );
  22. }
  23. }
  24. }
  25. }