public override async void OnHit(Aircraft target, bool killed, Node bulletNode) { // show a small explosion when the cube reaches an aircraft. base.OnHit(target, killed, bulletNode); var cache = Application.ResourceCache; var explosionNode = Scene.CreateChild(); SoundSource soundSource = explosionNode.CreateComponent <SoundSource>(); soundSource.Play(Application.ResourceCache.GetSound(Assets.Sounds.SmallExplosion)); soundSource.Gain = 0.3f; explosionNode.Position = target.Node.WorldPosition; explosionNode.SetScale(1.6f); var particleEmitter = explosionNode.CreateComponent <ParticleEmitter2D>(); particleEmitter.Effect = cache.GetParticleEffect2D(Assets.Particles.Explosion); ScaleBy scaleBy = new ScaleBy(0.3f, 0.1f); await explosionNode.RunActionsAsync(scaleBy, new DelayTime(1f)); explosionNode.Remove(); }
void OnGUI() { GUILayout.Label("Settings", EditorStyles.boldLabel); _texture = (Texture)EditorGUILayout.ObjectField("Texture", _texture, typeof(Texture), false); _shaderType = (ShaderType)EditorGUILayout.EnumPopup("Shader Type", _shaderType); _anchorType = (AnchorType)EditorGUILayout.EnumPopup("Anchor Type", _anchorType); _scaleBy = (ScaleBy)EditorGUILayout.EnumPopup("Scale By", _scaleBy); _size = EditorGUILayout.FloatField("Size", _size); _isCreateAsset = EditorGUILayout.Toggle("Create Asset", _isCreateAsset); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUI.enabled = (_texture != null); if (GUILayout.Button("Process")) { _Process(); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); }