TemplateRenderPlatformHelper.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using UnityEngine;
  4. using System;
  5. namespace AmplifyShaderEditor
  6. {
  7. [Serializable]
  8. public class TemplateRenderPlatformHelper : TemplateModuleData
  9. {
  10. [SerializeField]
  11. private string m_id;
  12. [SerializeField]
  13. private int m_index;
  14. [SerializeField]
  15. private bool[] m_renderingPlatforms = null;
  16. private void CommonInit( bool initialValue )
  17. {
  18. DataCheck = TemplateDataCheck.Valid;
  19. int renderPlatformLength = RenderingPlatformOpHelper.RenderingPlatformsInfo.Length;
  20. m_renderingPlatforms = new bool[ renderPlatformLength ];
  21. for( int i = 0 ; i < m_renderingPlatforms.Length ; i++ )
  22. {
  23. m_renderingPlatforms[ i ] = initialValue;
  24. }
  25. }
  26. public void InitByTag(int index)
  27. {
  28. m_id = TemplatesManager.TemplateRenderPlatformsTag;
  29. m_index = index;
  30. CommonInit( true );
  31. }
  32. public void InitByExcludeRenders( int index, string id )
  33. {
  34. m_id = id;
  35. m_index = index;
  36. CommonInit( true );
  37. }
  38. public void InitByOnlyRenders( int index , string id )
  39. {
  40. m_id = id;
  41. m_index = index;
  42. CommonInit( false );
  43. }
  44. public void SetupPlatform( string platformStr , bool value )
  45. {
  46. try
  47. {
  48. RenderPlatforms platform = (RenderPlatforms)Enum.Parse( typeof( RenderPlatforms ) , platformStr );
  49. int index = -1;
  50. if( RenderingPlatformOpHelper.PlatformToIndex.TryGetValue( platform , out index ) )
  51. {
  52. m_renderingPlatforms[ index ] = value;
  53. }
  54. }
  55. catch( Exception e )
  56. {
  57. Debug.LogException( e );
  58. }
  59. }
  60. public void Destroy()
  61. {
  62. m_renderingPlatforms = null;
  63. }
  64. public bool[] RenderingPlatforms { get { return m_renderingPlatforms; } }
  65. public string ID { get { return m_id; } }
  66. public int Index { get { return m_index; } set{ m_index = value; } }
  67. }
  68. }