BlendWeightsNode.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. using UnityEditor;
  5. using UnityEngine;
  6. namespace AmplifyShaderEditor
  7. {
  8. [Serializable]
  9. [NodeAttributes( "Bone Blend Weights" , "Vertex Data" , "Bone blend weights for skinned Meshes" )]
  10. public sealed class BlendWeightsNode : VertexDataNode
  11. {
  12. private const string IncorrectUnityVersionMessage = "This info is only available on Unity 2019.1 or above.";
  13. private const string StandardSurfaceErrorMessage = "This info is not available on standard surface shaders.";
  14. protected override void CommonInit( int uniqueId )
  15. {
  16. base.CommonInit( uniqueId );
  17. m_currentVertexData = GeneratorUtils.VertexBlendWeightsStr;
  18. m_errorMessageTypeIsError = NodeMessageType.Error;
  19. }
  20. public override void OnNodeLogicUpdate( DrawInfo drawInfo )
  21. {
  22. base.OnNodeLogicUpdate( drawInfo );
  23. if( UIUtils.CurrentWindow.OutsideGraph.IsStandardSurface )
  24. {
  25. if( !m_showErrorMessage )
  26. {
  27. m_showErrorMessage = true;
  28. m_errorMessageTooltip = StandardSurfaceErrorMessage;
  29. }
  30. }
  31. else
  32. {
  33. m_showErrorMessage = false;
  34. }
  35. }
  36. public override string GenerateShaderForOutput( int outputId , ref MasterNodeDataCollector dataCollector , bool ignoreLocalVar )
  37. {
  38. string blendWeights = string.Empty;
  39. if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template )
  40. {
  41. blendWeights = dataCollector.TemplateDataCollectorInstance.GetBlendWeights();
  42. return GetOutputVectorItem( 0 , outputId , blendWeights );
  43. }
  44. return GenerateErrorValue( outputId );
  45. }
  46. }
  47. }