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