PrettifyVarName() public static method

Turns the given variable name into a nice display name.
public static PrettifyVarName ( string name ) : string
name string
return string
コード例 #1
0
 /// <summary>
 /// Generates a shader that outputs a color based on the graph's noise and a color ramp texture.
 /// </summary>
 /// <param name="shaderName">The shader's name in the file.</param>
 public string GenerateShader(string shaderName, string colorRampParamName)
 {
     return(GenerateShader(shaderName,
                           (sb) =>
     {
         sb.Append("\t\t\t");
         sb.Append(colorRampParamName);
         sb.Append(" (\"");
         sb.Append(StringUtils.PrettifyVarName(colorRampParamName));
         sb.AppendLine("\", 2D) = \"\" {}");
     },
                           (sb) =>
     {
         sb.Append("\t\t\t\tsampler2D ");
         sb.Append(colorRampParamName);
         sb.AppendLine(";");
     },
                           (o, sb) =>
     {
         sb.Append("return tex2D(");
         sb.Append(colorRampParamName);
         sb.Append(", float2(");
         sb.Append(o);
         sb.AppendLine(", 0.0));");
     }));
 }
コード例 #2
0
 public override void EmitProperties(StringBuilder outCode)
 {
     outCode.Append("\t\t\t");
     outCode.Append(Param.Name);
     outCode.Append(" (\"");
     outCode.Append(StringUtils.PrettifyVarName(Param.Name));
     outCode.Append("\", 2D) = \"\" {}");
 }
コード例 #3
0
		/// <summary>
		/// Runs a GUI using EditorGUILayout for these parameters.
		/// This GUI can be used to modify each parameter's "default value" fields.
		/// Returns whether any values have been changed.
		/// </summary>
		public bool ParamEditorGUI()
		{
			bool changed = false;

			for (int i = 0; i < FloatParams.Count; ++i)
			{
				GUILayout.BeginHorizontal();
				GUILayout.Label(StringUtils.PrettifyVarName(FloatParams[i].Name));
				float oldVal = FloatParams[i].DefaultValue;
				if (FloatParams[i].IsSlider)
				{
					GUILayout.Label(FloatParams[i].SliderMin.ToString());
					FloatParams[i] = new FloatParamInfo(FloatParams[i],
						Mathf.InverseLerp(FloatParams[i].SliderMin, FloatParams[i].SliderMax,
										  GUILayout.HorizontalSlider(Mathf.Lerp(FloatParams[i].SliderMin,
																				FloatParams[i].SliderMax,
																				FloatParams[i].DefaultValue),
																	 FloatParams[i].SliderMin,
																	 FloatParams[i].SliderMax,
																	 GUILayout.MinWidth(50.0f))));
					GUILayout.Label(FloatParams[i].SliderMax.ToString());
				}
				else
				{
					FloatParams[i] = new FloatParamInfo(FloatParams[i],
														EditorGUILayout.FloatField(FloatParams[i].DefaultValue));
				}

				changed = (changed || Node.AreFloatsDifferent(oldVal, FloatParams[i].DefaultValue));

				GUILayout.EndHorizontal();
			}
			for (int i = 0; i < Tex2DParams.Count; ++i)
			{
				GUILayout.BeginHorizontal();

				GUILayout.Label(StringUtils.PrettifyVarName(Tex2DParams[i].Name));

				Texture2D oldVal = Tex2DParams[i].DefaultVal;
				Tex2DParams[i] = new Texture2DParamInfo(Tex2DParams[i].Name,
						(Texture2D)EditorGUILayout.ObjectField(Tex2DParams[i].DefaultVal,
															   typeof(Texture2D), false));

				changed = (oldVal != Tex2DParams[i].DefaultVal);

				GUILayout.EndHorizontal();
			}

			return changed;
		}
コード例 #4
0
 public override void EmitProperties(StringBuilder outCode)
 {
     outCode.Append("\t\t\t");
     outCode.Append(Param.Name);
     outCode.Append(" (\"");
     outCode.Append(StringUtils.PrettifyVarName(Param.Name));
     outCode.Append("\", ");
     if (Param.IsSlider)
     {
         outCode.Append("Range(");
         outCode.Append(Param.SliderMin);
         outCode.Append(", ");
         outCode.Append(Param.SliderMax);
         outCode.Append(")) = ");
         outCode.Append(Mathf.Lerp(Param.SliderMin, Param.SliderMax,
                                   Param.DefaultValue).ToCodeString());
     }
     else
     {
         outCode.Append("Float) = ");
         outCode.Append(Param.DefaultValue);
     }
     outCode.AppendLine();
 }