forked from neil3d/Unity-glTF-Exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlTF_Shader.cs
45 lines (39 loc) · 859 Bytes
/
GlTF_Shader.cs
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
#if UNITY_EDITOR
using UnityEngine;
using System.Collections;
public class GlTF_Shader : GlTF_Writer {
public enum Type {
Vertex,
Fragment
}
public Type type = Type.Vertex;
public string uri = "";
public static string GetNameFromObject(Object o, Type type)
{
var name = GlTF_Writer.GetNameFromObject(o);
var typeName = type == Type.Vertex ? "vertex" : "fragment";
return typeName + "_" + name;
}
public override void Write()
{
Indent(); jsonWriter.Write ("\"" + name + "\": {\n");
IndentIn();
Indent(); jsonWriter.Write ("\"type\": " + TypeStr() +",\n");
Indent(); jsonWriter.Write ("\"uri\": \"" + uri +"\"\n");
IndentOut();
Indent(); jsonWriter.Write ("}");
}
int TypeStr()
{
if (type == Type.Vertex)
{
return 35633;
}
else if (type == Type.Fragment)
{
return 35632;
}
return 0;
}
}
#endif