A game about forced loneliness, made by TACStudios
1using UnityEngine;
2using UnityEditor.Graphing;
3using UnityEditor.ShaderGraph.Internal;
4using System.Collections.Generic;
5
6namespace UnityEditor.ShaderGraph
7{
8 [FormerName("UnityEngine.MaterialGraph.ViewDirectionNode")]
9 [Title("Input", "Geometry", "View Direction")]
10 class ViewDirectionNode : GeometryNode, IMayRequireViewDirection, IHasCustomDeprecationMessage
11 {
12 private const int kOutputSlotId = 0;
13 public const string kOutputSlotName = "Out";
14
15 public override int latestVersion => 1;
16 public override IEnumerable<int> allowedNodeVersions => new int[] { 1 };
17
18 public ViewDirectionNode()
19 {
20 name = "View Direction";
21 synonyms = new string[] { "eye direction" };
22 UpdateNodeAfterDeserialization();
23 onAfterVersionChange += () => { if (sgVersion > 0) owner.ClearErrorsForNode(this); };
24 }
25
26 public override void ValidateNode()
27 {
28 base.ValidateNode();
29 if (sgVersion == 0)
30 {
31 owner.AddValidationError(objectId, "Node behavior was changed. See inspector for details", Rendering.ShaderCompilerMessageSeverity.Warning);
32 }
33 }
34
35 public sealed override void UpdateNodeAfterDeserialization()
36 {
37 AddSlot(new Vector3MaterialSlot(
38 kOutputSlotId,
39 kOutputSlotName,
40 kOutputSlotName,
41 SlotType.Output,
42 Vector4.zero));
43 RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
44 }
45
46 public override string GetVariableNameForSlot(int slotId)
47 {
48 return string.Format("IN.{0}", space.ToVariableName(InterpolatorType.ViewDirection));
49 }
50
51 public NeededCoordinateSpace RequiresViewDirection(ShaderStageCapability stageCapability)
52 {
53 return space.ToNeededCoordinateSpace();
54 }
55
56 public void GetCustomDeprecationMessage(out string deprecationString, out string buttonText, out string labelText, out MessageType messageType)
57 {
58 deprecationString = null;
59 buttonText = null;
60 labelText = null;
61 messageType = MessageType.Warning;
62 if (sgVersion == 0)
63 {
64 deprecationString = "The View Direction node has changed behavior in 2021.2. Please see documentation for more info.";
65 buttonText = "Dismiss";
66 labelText = "UPDATED: Hover for info";
67 messageType = MessageType.Info;
68 }
69 }
70
71 public string GetCustomDeprecationLabel()
72 {
73 return name;
74 }
75 }
76}