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.

47 lines
1.5 KiB

  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 TemplateShaderPropertyData( int index, string fullValue, string identation, string propertyInspectorName, string propertyName, WirePortDataType propertyDataType, PropertyType propertyType, bool isMacro = false )
  19. {
  20. Index = index;
  21. FullValue = fullValue;
  22. Identation = identation;
  23. PropertyInspectorName = string.IsNullOrEmpty( propertyInspectorName )?propertyName: propertyInspectorName;
  24. PropertyName = propertyName;
  25. PropertyDataType = propertyDataType;
  26. PropertyType = propertyType;
  27. int idx = FullValue.LastIndexOf( "=" );
  28. ReplacementValueHelper = ( idx >= 0 ) ? FullValue.Substring( 0, idx + 1 ) +" ": FullValue + " = ";
  29. IsMacro = isMacro;
  30. }
  31. public string CreatePropertyForValue( string value )
  32. {
  33. return value.Contains( PropertyName ) ? Identation + value : ReplacementValueHelper + value;
  34. }
  35. public override string ToString()
  36. {
  37. return string.Format( "{0}(\"{1}\", {2})", PropertyName, PropertyInspectorName,UIUtils.WirePortToCgType( PropertyDataType ) );
  38. }
  39. }
  40. }