ViewDirectionMaterialSlot.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using UnityEditor.ShaderGraph.Drawing.Slots;
  3. using UnityEditor.ShaderGraph.Internal;
  4. using UnityEngine.UIElements;
  5. namespace UnityEditor.ShaderGraph
  6. {
  7. [Serializable]
  8. class ViewDirectionMaterialSlot : SpaceMaterialSlot, IMayRequireViewDirection
  9. {
  10. public ViewDirectionMaterialSlot()
  11. {}
  12. public ViewDirectionMaterialSlot(int slotId, string displayName, string shaderOutputName, CoordinateSpace space,
  13. ShaderStageCapability stageCapability = ShaderStageCapability.All, bool hidden = false)
  14. : base(slotId, displayName, shaderOutputName, space, stageCapability, hidden)
  15. {}
  16. public override VisualElement InstantiateControl()
  17. {
  18. return new LabelSlotControlView(space + " Space");
  19. }
  20. public override string GetDefaultValue(GenerationMode generationMode)
  21. {
  22. return string.Format("IN.{0}", space.ToVariableName(InterpolatorType.ViewDirection));
  23. }
  24. public NeededCoordinateSpace RequiresViewDirection(ShaderStageCapability stageCapability)
  25. {
  26. if (isConnected)
  27. return NeededCoordinateSpace.None;
  28. return space.ToNeededCoordinateSpace();
  29. }
  30. }
  31. }