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.

75 lines
1.4 KiB

  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using UnityEngine;
  4. namespace AmplifyShaderEditor
  5. {
  6. public class ToolsMenuButtonParent
  7. {
  8. protected AmplifyShaderEditorWindow m_parentWindow = null;
  9. private float m_buttonSpacing = 10;
  10. private int m_currentState = 0;
  11. private bool m_isInitialized = false;
  12. protected GUIContent m_content;
  13. public ToolsMenuButtonParent( AmplifyShaderEditorWindow parentWindow, string text, string tooltip, float buttonSpacing )
  14. {
  15. m_parentWindow = parentWindow;
  16. m_content = new GUIContent( text, tooltip );
  17. if ( buttonSpacing > 0 )
  18. m_buttonSpacing = buttonSpacing;
  19. }
  20. public virtual void Draw()
  21. {
  22. if ( !m_isInitialized )
  23. {
  24. Init();
  25. }
  26. GUILayout.Space( m_buttonSpacing );
  27. }
  28. public virtual void Draw( Vector2 pos )
  29. {
  30. Draw( pos.x, pos.y );
  31. }
  32. public virtual void Draw( float x ,float y )
  33. {
  34. if ( !m_isInitialized )
  35. {
  36. Init();
  37. }
  38. }
  39. protected virtual void Init()
  40. {
  41. m_isInitialized = false;
  42. }
  43. public virtual void SetStateOnButton( int state, string tooltip )
  44. {
  45. m_currentState = state;
  46. m_content.tooltip = tooltip;
  47. }
  48. public virtual void SetStateOnButton( int state )
  49. {
  50. m_currentState = state;
  51. }
  52. public virtual void Destroy() { }
  53. public float ButtonSpacing
  54. {
  55. get { return m_buttonSpacing; }
  56. }
  57. public int CurrentState
  58. {
  59. get { return m_currentState; }
  60. }
  61. }
  62. }