您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

65 行
1.9 KiB

  1. using System;
  2. using UnityEngine;
  3. public class WeatherParticles : MonoBehaviour
  4. {
  5. protected virtual void Awake()
  6. {
  7. if (this.parentCamera == null)
  8. {
  9. if (base.transform.parent != null)
  10. {
  11. this.parentCamera = base.transform.parent.GetComponent<Camera>();
  12. }
  13. if (this.parentCamera == null)
  14. {
  15. UnityEngine.Debug.LogError("WeatherParticles: Failed to find parentCamera, please assign it manually");
  16. }
  17. }
  18. this.PrecipitationPercentage = 0f;
  19. foreach (ParticleSystem particleSystem in this.particleLayers)
  20. {
  21. Renderer component = particleSystem.GetComponent<Renderer>();
  22. if (component != null)
  23. {
  24. component.sortingOrder = this.sortingOrder;
  25. }
  26. }
  27. }
  28. protected virtual void Start()
  29. {
  30. }
  31. protected virtual void Update()
  32. {
  33. float num = this.parentCamera.orthographicSize / 600f;
  34. base.transform.localPosition = new Vector3(base.transform.localPosition.x, this.parentCamera.orthographicSize, 0f);
  35. base.transform.localScale = new Vector3(num, num, 1f);
  36. foreach (ParticleSystem particleSystem in this.particleLayers)
  37. {
  38. ParticleSystem.MainModule main = particleSystem.main;
  39. main.startSize = num * 100f;
  40. }
  41. }
  42. public float PrecipitationPercentage
  43. {
  44. set
  45. {
  46. foreach (ParticleSystem particleSystem in this.particleLayers)
  47. {
  48. var _temp_val_887 = particleSystem.emission; _temp_val_887.rateOverTime = new ParticleSystem.MinMaxCurve(value * this.maxEmission);
  49. }
  50. }
  51. }
  52. public Camera parentCamera;
  53. public ParticleSystem[] particleLayers;
  54. public float maxEmission;
  55. public int sortingOrder = 200;
  56. }