A game about forced loneliness, made by TACStudios
1using System;
2using UnityEditor.Graphing;
3using UnityEditor.ShaderGraph.Internal;
4using UnityEngine;
5
6namespace UnityEditor.ShaderGraph
7{
8 [Serializable]
9 [BlackboardInputInfo(70)]
10 class Matrix2ShaderProperty : MatrixShaderProperty
11 {
12 public Matrix2ShaderProperty()
13 {
14 displayName = "Matrix2x2";
15 value = Matrix4x4.identity;
16 }
17
18 public override PropertyType propertyType => PropertyType.Matrix2;
19
20 internal override string GetPropertyAsArgumentString(string precisionString)
21 {
22 return $"{precisionString}2x2 {referenceName}";
23 }
24
25 internal override AbstractMaterialNode ToConcreteNode()
26 {
27 return new Matrix2Node
28 {
29 row0 = new Vector2(value.m00, value.m01),
30 row1 = new Vector2(value.m10, value.m11)
31 };
32 }
33
34 internal override PreviewProperty GetPreviewMaterialProperty()
35 {
36 return new PreviewProperty(propertyType)
37 {
38 name = referenceName,
39 matrixValue = value
40 };
41 }
42
43 internal override ShaderInput Copy()
44 {
45 return new Matrix2ShaderProperty()
46 {
47 displayName = displayName,
48 value = value,
49 };
50 }
51
52 public override int latestVersion => 1;
53 public override void OnAfterDeserialize(string json)
54 {
55 if (sgVersion == 0)
56 {
57 // all old matrices were declared global; yes even if flagged hybrid!
58 // maintain old behavior on versioning, users can always change the override if they wish
59 overrideHLSLDeclaration = true;
60 hlslDeclarationOverride = HLSLDeclaration.Global;
61 ChangeVersion(1);
62 }
63 }
64 }
65}