Skip to content

Commit

Permalink
Minor fixes for unity 2018
Browse files Browse the repository at this point in the history
  • Loading branch information
svermeulen committed Jun 17, 2018
1 parent a68eebf commit bbda0c7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public class Ship : MonoBehaviour
[SerializeField]
MeshRenderer _meshRenderer;

#if !UNITY_2018
[SerializeField]
ParticleEmitter _particleEmitter;
#endif

ShipStateFactory _stateFactory;
ShipState _state = null;
Expand All @@ -31,10 +33,12 @@ public MeshRenderer MeshRenderer
get { return _meshRenderer; }
}

#if !UNITY_2018
public ParticleEmitter ParticleEmitter
{
get { return _particleEmitter; }
}
#endif

public Vector3 Position
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public ShipStateDead(
public override void Start()
{
_ship.MeshRenderer.enabled = false;

#if !UNITY_2018
_ship.ParticleEmitter.gameObject.SetActive(false);
#endif

_explosion = _explosionFactory.Create().gameObject;
_explosion.transform.position = _ship.Position;
Expand All @@ -55,7 +58,10 @@ public override void Start()
public override void Dispose()
{
_ship.MeshRenderer.enabled = true;

#if !UNITY_2018
_ship.ParticleEmitter.gameObject.SetActive(true);
#endif

GameObject.Destroy(_explosion);
GameObject.Destroy(_shipBroken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ void ApplyOscillation()

void UpdateThruster()
{
// doesn't work on 2018
//var speed = (_ship.Position - _lastPosition).magnitude / Time.deltaTime;
//var speedPx = Mathf.Clamp(speed / _settings.speedForMaxEmisssion, 0.0f, 1.0f);
#if !UNITY_2018
var speed = (_ship.Position - _lastPosition).magnitude / Time.deltaTime;
var speedPx = Mathf.Clamp(speed / _settings.speedForMaxEmisssion, 0.0f, 1.0f);

//_ship.ParticleEmitter.maxEmission = _settings.maxEmission * speedPx;
_ship.ParticleEmitter.maxEmission = _settings.maxEmission * speedPx;
#endif
}

void Move()
Expand All @@ -75,12 +76,17 @@ void Move()
public override void Start()
{
_lastPosition = _ship.Position;

#if !UNITY_2018
_ship.ParticleEmitter.gameObject.SetActive(true);
#endif
}

public override void Dispose()
{
#if !UNITY_2018
_ship.ParticleEmitter.gameObject.SetActive(false);
#endif
}

public override void OnTriggerEnter(Collider other)
Expand Down

0 comments on commit bbda0c7

Please sign in to comment.