Assignment for RMIT Mixed Reality in 2020
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.

97 lines
3.4 KiB

  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using System;
  4. using UnityEngine;
  5. namespace AmplifyShaderEditor
  6. {
  7. public enum NodeAvailability
  8. {
  9. SurfaceShader = 1 << 0,
  10. ShaderFunction = 1 << 1,
  11. CustomLighting = 1 << 2,
  12. TemplateShader = 1 << 3
  13. }
  14. [AttributeUsage( AttributeTargets.Class )]
  15. public class NodeAttributes : Attribute
  16. {
  17. public string Name;
  18. public string Description;
  19. public string Category;
  20. public KeyCode ShortcutKey;
  21. public bool Available;
  22. public System.Type[] CastType; // Type that will be converted to AttribType if dropped on the canvas ... p.e. dropping a texture2d on the canvas will generate a sampler2d node
  23. public bool Deprecated;
  24. public string DeprecatedAlternative;
  25. public System.Type DeprecatedAlternativeType;
  26. public bool FromCommunity;
  27. public string CustomCategoryColor; // Color created via a string containing its hexadecimal representation
  28. public int SortOrderPriority; // to be used when name comparing on sorting
  29. public int NodeAvailabilityFlags;// used to define where this node can be used
  30. private string m_nodeUrl;
  31. public string Community;
  32. public string Tags;
  33. public NodeAttributes( string name, string category, string description, System.Type castType = null, KeyCode shortcutKey = KeyCode.None, bool available = true, bool deprecated = false, string deprecatedAlternative = null, System.Type deprecatedAlternativeType = null, string community = null, string customCategoryColor = null, int sortOrderPriority = -1, int nodeAvailabilityFlags = int.MaxValue, string tags = null )
  34. {
  35. Name = name;
  36. Description = description;
  37. Category = category;
  38. if( castType != null )
  39. CastType = new System.Type[] { castType };
  40. ShortcutKey = shortcutKey;
  41. Available = available;
  42. Deprecated = deprecated;
  43. DeprecatedAlternative = deprecatedAlternative;
  44. Community = community;
  45. if( string.IsNullOrEmpty( Community ) )
  46. Community = string.Empty;
  47. else
  48. FromCommunity = true;
  49. if( !string.IsNullOrEmpty( customCategoryColor ) )
  50. CustomCategoryColor = customCategoryColor;
  51. DeprecatedAlternativeType = deprecatedAlternativeType;
  52. SortOrderPriority = sortOrderPriority;
  53. NodeAvailabilityFlags = nodeAvailabilityFlags;
  54. Tags = tags;
  55. if( string.IsNullOrEmpty( tags ) )
  56. Tags = string.Empty;
  57. //m_nodeUrl = ( FromCommunity ? Constants.CommunityNodeCommonUrl : Constants.NodeCommonUrl ) + UIUtils.UrlReplaceInvalidStrings( Name );
  58. }
  59. public NodeAttributes( string name, string category, string description, KeyCode shortcutKey, bool available, int sortOrderPriority, int nodeAvailabilityFlags, params System.Type[] castTypes )
  60. {
  61. Name = name;
  62. Description = description;
  63. Category = category;
  64. if( castTypes != null && castTypes.Length > 0 )
  65. {
  66. CastType = castTypes;
  67. }
  68. ShortcutKey = shortcutKey;
  69. Available = available;
  70. SortOrderPriority = sortOrderPriority;
  71. NodeAvailabilityFlags = nodeAvailabilityFlags;
  72. //m_nodeUrl = ( FromCommunity ? Constants.CommunityNodeCommonUrl : Constants.NodeCommonUrl ) + UIUtils.UrlReplaceInvalidStrings( Name );
  73. }
  74. public string NodeUrl
  75. {
  76. get
  77. {
  78. if( string.IsNullOrEmpty( m_nodeUrl ) )
  79. {
  80. m_nodeUrl = ( FromCommunity ? Constants.CommunityNodeCommonUrl : Constants.NodeCommonUrl ) + UIUtils.UrlReplaceInvalidStrings( Name );
  81. }
  82. return m_nodeUrl;
  83. }
  84. }
  85. }
  86. }