Ingen beskrivning
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ParticlesUnlitShader.cs 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace UnityEditor.Rendering.Universal.ShaderGUI
  5. {
  6. internal class ParticlesUnlitShader : BaseShaderGUI
  7. {
  8. // Properties
  9. private BakedLitGUI.BakedLitProperties shadingModelProperties;
  10. private ParticleGUI.ParticleProperties particleProps;
  11. // List of renderers using this material in the scene, used for validating vertex streams
  12. List<ParticleSystemRenderer> m_RenderersUsingThisMaterial = new List<ParticleSystemRenderer>();
  13. public override void FindProperties(MaterialProperty[] properties)
  14. {
  15. base.FindProperties(properties);
  16. shadingModelProperties = new BakedLitGUI.BakedLitProperties(properties);
  17. particleProps = new ParticleGUI.ParticleProperties(properties);
  18. }
  19. public override void ValidateMaterial(Material material)
  20. {
  21. SetMaterialKeywords(material, null, ParticleGUI.SetMaterialKeywords);
  22. }
  23. public override void DrawSurfaceOptions(Material material)
  24. {
  25. base.DrawSurfaceOptions(material);
  26. DoPopup(ParticleGUI.Styles.colorMode, particleProps.colorMode, Enum.GetNames(typeof(ParticleGUI.ColorMode)));
  27. }
  28. public override void DrawSurfaceInputs(Material material)
  29. {
  30. base.DrawSurfaceInputs(material);
  31. BakedLitGUI.Inputs(shadingModelProperties, materialEditor);
  32. DrawEmissionProperties(material, true);
  33. }
  34. public override void DrawAdvancedOptions(Material material)
  35. {
  36. materialEditor.ShaderProperty(particleProps.flipbookMode, ParticleGUI.Styles.flipbookMode);
  37. ParticleGUI.FadingOptions(material, materialEditor, particleProps);
  38. ParticleGUI.DoVertexStreamsArea(material, m_RenderersUsingThisMaterial);
  39. DrawQueueOffsetField();
  40. }
  41. public override void OnOpenGUI(Material material, MaterialEditor materialEditor)
  42. {
  43. CacheRenderersUsingThisMaterial(material);
  44. base.OnOpenGUI(material, materialEditor);
  45. }
  46. void CacheRenderersUsingThisMaterial(Material material)
  47. {
  48. m_RenderersUsingThisMaterial.Clear();
  49. ParticleSystemRenderer[] renderers = UnityEngine.Object.FindObjectsByType<ParticleSystemRenderer>(FindObjectsSortMode.InstanceID);
  50. foreach (ParticleSystemRenderer renderer in renderers)
  51. {
  52. if (renderer.sharedMaterial == material)
  53. m_RenderersUsingThisMaterial.Add(renderer);
  54. }
  55. }
  56. }
  57. } // namespace UnityEditor