public void GenerateNodeFunction(FunctionRegistry registry, GraphContext graphContext, GenerationMode generationMode) { if (generationMode == GenerationMode.Preview) { registry.ProvideFunction(GetFunctionName(), s => { s.AppendLine("Gradient {0} ()", GetFunctionName()); using (s.BlockScope()) { s.AppendLine("Gradient g;"); s.AppendLine("g.type = _{0}_Type;", GetVariableNameForNode()); s.AppendLine("g.colorsLength = _{0}_ColorsLength;", GetVariableNameForNode()); s.AppendLine("g.alphasLength = _{0}_AlphasLength;", GetVariableNameForNode()); for (int i = 0; i < 8; i++) { s.AppendLine("g.colors[{0}] = _{1}_ColorKey{0};", i, GetVariableNameForNode()); } for (int i = 0; i < 8; i++) { s.AppendLine("g.alphas[{0}] = _{1}_AlphaKey{0};", i, GetVariableNameForNode()); } s.AppendLine("return g;", true); } }); } else { registry.ProvideFunction(GetFunctionName(), s => { s.AppendLine("Gradient {0} ()", GetFunctionName()); using (s.BlockScope()) { GradientUtils.GetGradientDeclaration(m_Gradient, ref s); s.AppendLine("return g;", true); } }); } }
public override string GetPropertyDeclarationString(string delimiter = ";") { if (m_OverrideMembers) { ShaderStringBuilder s = new ShaderStringBuilder(); s.AppendLine("Gradient Unity{0} ()", referenceName); using (s.BlockScope()) { s.AppendLine("Gradient g;"); s.AppendLine("g.type = {0}_Type;", m_OverrideSlotName); s.AppendLine("g.colorsLength = {0}_ColorsLength;", m_OverrideSlotName); s.AppendLine("g.alphasLength = {0}_AlphasLength;", m_OverrideSlotName); for (int i = 0; i < 8; i++) { s.AppendLine("g.colors[{0}] = {1}_ColorKey{0};", i, m_OverrideSlotName); } for (int i = 0; i < 8; i++) { s.AppendLine("g.alphas[{0}] = {1}_AlphaKey{0};", i, m_OverrideSlotName); } s.AppendLine("return g;", true); } return(s.ToString()); } else { ShaderStringBuilder s = new ShaderStringBuilder(); s.AppendLine("Gradient Unity{0} ()", referenceName); using (s.BlockScope()) { GradientUtils.GetGradientDeclaration(value, ref s); s.AppendLine("return g;", true); } return(s.ToString()); } }