TemplateModuleParent.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using System;
  4. using UnityEngine;
  5. using UnityEditor;
  6. namespace AmplifyShaderEditor
  7. {
  8. [Serializable]
  9. public class TemplateModuleParent
  10. {
  11. private const string UnreadableDataMessagePrefix = "Unreadable data on Module ";
  12. protected string m_unreadableMessage;
  13. [SerializeField]
  14. protected bool m_validData = false;
  15. [SerializeField]
  16. protected bool m_isDirty = false;
  17. [SerializeField]
  18. protected string m_moduleName = string.Empty;
  19. //[SerializeField]
  20. //protected bool m_foldoutValue = false;
  21. [SerializeField]
  22. protected bool m_independentModule = true;
  23. [SerializeField]
  24. private bool m_customEdited = false;
  25. public TemplateModuleParent( string moduleName ) { m_moduleName = moduleName; m_unreadableMessage = UnreadableDataMessagePrefix + moduleName; }
  26. public virtual void Draw( UndoParentNode owner , bool style = true) { }
  27. public virtual void ReadFromString( ref uint index, ref string[] nodeParams )
  28. {
  29. if( UIUtils.CurrentShaderVersion() > 18805 )
  30. {
  31. CustomEdited = Convert.ToBoolean( nodeParams[ index++ ] );
  32. }
  33. }
  34. public virtual void WriteToString( ref string nodeInfo )
  35. {
  36. IOUtils.AddFieldValueToString( ref nodeInfo, m_customEdited );
  37. }
  38. public virtual string GenerateShaderData( bool isSubShader ) { return string.Empty; }
  39. public virtual void Destroy() { }
  40. public bool ValidData { get { return m_validData; } }
  41. public bool ValidAndIndependent { get { return m_validData && m_independentModule; } }
  42. public virtual void ShowUnreadableDataMessage( ParentNode owner )
  43. {
  44. ShowUnreadableDataMessage();
  45. }
  46. public virtual void ShowUnreadableDataMessage()
  47. {
  48. EditorGUILayout.HelpBox( m_unreadableMessage, MessageType.Info );
  49. }
  50. public bool IsDirty
  51. {
  52. get { return m_isDirty; }
  53. set { m_isDirty = value; }
  54. }
  55. public bool IndependentModule
  56. {
  57. get { return m_independentModule; }
  58. set { m_independentModule = value; }
  59. }
  60. public bool CustomEdited
  61. {
  62. get { return m_customEdited; }
  63. set { m_customEdited = value; }
  64. }
  65. }
  66. }