From bbda0c70fa97316ebcec8248347896ef9eb1484c Mon Sep 17 00:00:00 2001 From: Steve Vermeulen Date: Sun, 17 Jun 2018 21:32:35 +0800 Subject: [PATCH] Minor fixes for unity 2018 --- .../SampleGame1 (Beginner)/Scripts/Ship/Ship.cs | 4 ++++ .../Scripts/Ship/States/ShipStateDead.cs | 6 ++++++ .../Scripts/Ship/States/ShipStateMoving.cs | 14 ++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/UnityProject/Assets/Plugins/Zenject/OptionalExtras/SampleGame1 (Beginner)/Scripts/Ship/Ship.cs b/UnityProject/Assets/Plugins/Zenject/OptionalExtras/SampleGame1 (Beginner)/Scripts/Ship/Ship.cs index 02f6a50ba..49ffeb03f 100644 --- a/UnityProject/Assets/Plugins/Zenject/OptionalExtras/SampleGame1 (Beginner)/Scripts/Ship/Ship.cs +++ b/UnityProject/Assets/Plugins/Zenject/OptionalExtras/SampleGame1 (Beginner)/Scripts/Ship/Ship.cs @@ -14,8 +14,10 @@ public class Ship : MonoBehaviour [SerializeField] MeshRenderer _meshRenderer; +#if !UNITY_2018 [SerializeField] ParticleEmitter _particleEmitter; +#endif ShipStateFactory _stateFactory; ShipState _state = null; @@ -31,10 +33,12 @@ public MeshRenderer MeshRenderer get { return _meshRenderer; } } +#if !UNITY_2018 public ParticleEmitter ParticleEmitter { get { return _particleEmitter; } } +#endif public Vector3 Position { diff --git a/UnityProject/Assets/Plugins/Zenject/OptionalExtras/SampleGame1 (Beginner)/Scripts/Ship/States/ShipStateDead.cs b/UnityProject/Assets/Plugins/Zenject/OptionalExtras/SampleGame1 (Beginner)/Scripts/Ship/States/ShipStateDead.cs index 38174db33..845e9a0bc 100644 --- a/UnityProject/Assets/Plugins/Zenject/OptionalExtras/SampleGame1 (Beginner)/Scripts/Ship/States/ShipStateDead.cs +++ b/UnityProject/Assets/Plugins/Zenject/OptionalExtras/SampleGame1 (Beginner)/Scripts/Ship/States/ShipStateDead.cs @@ -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; @@ -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); diff --git a/UnityProject/Assets/Plugins/Zenject/OptionalExtras/SampleGame1 (Beginner)/Scripts/Ship/States/ShipStateMoving.cs b/UnityProject/Assets/Plugins/Zenject/OptionalExtras/SampleGame1 (Beginner)/Scripts/Ship/States/ShipStateMoving.cs index 1128819d8..15e38a24f 100644 --- a/UnityProject/Assets/Plugins/Zenject/OptionalExtras/SampleGame1 (Beginner)/Scripts/Ship/States/ShipStateMoving.cs +++ b/UnityProject/Assets/Plugins/Zenject/OptionalExtras/SampleGame1 (Beginner)/Scripts/Ship/States/ShipStateMoving.cs @@ -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() @@ -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)