blob: 55ba6f5e0ceecfb2a30897a735eccd074d7a4cff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
using System;
using System.Collections.Generic;
using UnityEngine;
using Poiyomi.ModularShaderSystem.UI;
namespace Poiyomi.ModularShaderSystem
{
public enum PropertyType
{
Float,
Int,
Range,
Vector,
Color,
Texture2D,
Texture2DArray,
Cube,
CubeArray,
Texture3D
}
[Serializable]
public class Property : IEquatable<Property>
{
public string Name;
public string DisplayName;
public string Type;
public string DefaultValue;
public Texture DefaultTextureAsset;
[PropertyAttribute]
public List<string> Attributes;
public virtual Variable ToVariable()
{
var variable = new Variable();
variable.Name = Name;
switch(Type)
{
case "Float": variable.Type = VariableType.Float; break;
case "Int": variable.Type = VariableType.Float; break;
case "Color": variable.Type = VariableType.Float4; break;
case "Vector": variable.Type = VariableType.Float4; break;
case "2D": variable.Type = VariableType.Texture2D; break;
case "3D": variable.Type = VariableType.Texture3D; break;
case "Cube": variable.Type = VariableType.TextureCube; break;
case "2DArray": variable.Type = VariableType.Texture2DArray; break;
case "CubeArray": variable.Type = VariableType.TextureCubeArray; break;
default: variable.Type = Type.StartsWith("Range") ? VariableType.Float : VariableType.Custom; break;
}
return variable;
}
public override bool Equals(object obj)
{
if (obj is Property other)
return Name == other.Name;
return false;
}
bool IEquatable<Property>.Equals(Property other)
{
return Equals(other);
}
public static bool operator == (Property left, Property right)
{
return left?.Equals(right) ?? right is null;
}
public static bool operator !=(Property left, Property right)
{
return !(left == right);
}
public override int GetHashCode()
{
int hashCode = (Name != null ? Name.GetHashCode() : 0);
return hashCode;
}
}
}
|