LengthNode.cs 660 B

12345678910111213141516171819202122232425262728293031
  1. using System.Reflection;
  2. namespace UnityEditor.ShaderGraph
  3. {
  4. [Title("Math", "Advanced", "Length")]
  5. class LengthNode : CodeFunctionNode
  6. {
  7. public LengthNode()
  8. {
  9. name = "Length";
  10. }
  11. protected override MethodInfo GetFunctionToConvert()
  12. {
  13. return GetType().GetMethod("Unity_Length", BindingFlags.Static | BindingFlags.NonPublic);
  14. }
  15. static string Unity_Length(
  16. [Slot(0, Binding.None)] DynamicDimensionVector In,
  17. [Slot(1, Binding.None)] out Vector1 Out)
  18. {
  19. return
  20. @"
  21. {
  22. Out = length(In);
  23. }
  24. ";
  25. }
  26. }
  27. }