TemplateShaderPropertyData.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using System;
  4. namespace AmplifyShaderEditor
  5. {
  6. [Serializable]
  7. public class TemplateShaderPropertyData
  8. {
  9. public string PropertyInspectorName;
  10. public string PropertyName;
  11. public WirePortDataType PropertyDataType;
  12. public PropertyType PropertyType;
  13. public int Index;
  14. public string FullValue;
  15. public string ReplacementValueHelper;
  16. public string Identation;
  17. public bool IsMacro;
  18. public int SubShaderId;
  19. public int PassId;
  20. public TemplateShaderPropertyData( int index, string fullValue, string identation, string propertyInspectorName, string propertyName, WirePortDataType propertyDataType, PropertyType propertyType,int subShaderId, int passId, bool isMacro = false )
  21. {
  22. Index = index;
  23. FullValue = fullValue;
  24. Identation = identation;
  25. PropertyInspectorName = string.IsNullOrEmpty( propertyInspectorName )?propertyName: propertyInspectorName;
  26. PropertyName = propertyName;
  27. PropertyDataType = propertyDataType;
  28. PropertyType = propertyType;
  29. int idx = FullValue.LastIndexOf( "=" );
  30. ReplacementValueHelper = ( idx >= 0 ) ? FullValue.Substring( 0, idx + 1 ) +" ": FullValue + " = ";
  31. IsMacro = isMacro;
  32. SubShaderId = subShaderId;
  33. PassId = passId;
  34. }
  35. public string CreatePropertyForValue( string value )
  36. {
  37. return value.Contains( PropertyName ) ? Identation + value : ReplacementValueHelper + value;
  38. }
  39. public override string ToString()
  40. {
  41. return string.Format( "{0}(\"{1}\", {2})", PropertyName, PropertyInspectorName,UIUtils.WirePortToCgType( PropertyDataType ) );
  42. }
  43. }
  44. }