-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
Update JSON
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using UnityEngine; | ||
using UnityEngine.Networking; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
using System.Net; | ||
using System.IO; | ||
|
||
abstract class APIService { | ||
|
||
public static File GetDocument() { | ||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create($"https://api.figma.com/v1/files{Global.documentID}"); | ||
request.Headers.Add("Authorization", $"Bearer {Global.token}"); | ||
using (HttpWebResponse response = (HttpWebResponse) request.GetResponse()) { | ||
StreamReader reader = new StreamReader(response.GetResponseStream()); | ||
string json = reader.ReadToEnd(); | ||
Regex regex = new Regex("(|(PositionX)|(PositionY)|(PositionZ)|(RotationX)|(RotationY))#[0-9]+:[0-9]+"); | ||
json = regex.Replace(json, "$1"); | ||
return JsonUtility.FromJson<File>(json); | ||
} | ||
} | ||
|
||
public static string GetImage() { | ||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create($"https://api.figma.com/v1/files{Global.documentID}/images"); | ||
request.Headers.Add("Authorization", $"Bearer {Global.token}"); | ||
using (HttpWebResponse response = (HttpWebResponse) request.GetResponse()) { | ||
StreamReader reader = new StreamReader(response.GetResponseStream()); | ||
return reader.ReadToEnd(); | ||
} | ||
} | ||
|
||
public static string ContentType(string url) { | ||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); | ||
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); | ||
string type = response.ContentType; | ||
return type.Remove(0, type.IndexOf("/")+1); | ||
} | ||
|
||
public static bool DownloadImage(string url, string path) { | ||
UnityWebRequest uwr = new UnityWebRequest(url, UnityWebRequest.kHttpVerbGET); | ||
uwr.downloadHandler = new DownloadHandlerFile(path); | ||
uwr.SendWebRequest(); | ||
while(!uwr.isDone){} | ||
return uwr.responseCode == 200 ? true : false; | ||
} | ||
|
||
public static string GetImageID(string id) { | ||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create($"https://api.figma.com/v1/images{Global.documentID}?ids={id}"); | ||
request.Headers.Add("Authorization", "Bearer "+ Global.token); | ||
using (HttpWebResponse response = (HttpWebResponse) request.GetResponse()) { | ||
StreamReader reader = new StreamReader(response.GetResponseStream()); | ||
return reader.ReadToEnd(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[System.Serializable] | ||
public class Document { | ||
public string id; | ||
public string name; | ||
public string type; | ||
public string scrollBehavior; | ||
public Page[] children; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[System.Serializable] | ||
public class File { | ||
public Document document; | ||
public string[] components; | ||
public string[] componentSets; | ||
public string[] schemaVersion; | ||
public string[] styles; | ||
public string name; | ||
public string lastModified; | ||
public string thumbnailUrl; | ||
public string version; | ||
public string role; | ||
public string editorType; | ||
public string linkAccess; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Collections.Generic; | ||
|
||
[System.Serializable] | ||
public class ObjectProperty { | ||
public string id; | ||
public string name; | ||
public bool visible = true; | ||
public string type; | ||
public string scrollBehavior; | ||
public ComponentProperty componentPropertyDefinitions; | ||
public string blendMode; | ||
public ObjectProperty[] children = null; | ||
public Absolute absoluteBoundingBox; | ||
public Absolute absoluteRenderBounds; | ||
public Constraints constraits; | ||
public bool clipsContent; | ||
public Fills[] background; | ||
public Fills[] fills; | ||
public Fills[] strokes; | ||
public float cornerRadius; | ||
public float strokeWeight = 0; | ||
public string storekeAlign; | ||
public Color backgroundColor; | ||
// public LayoutGrids[] layoutGrids; | ||
public ExportSettings[] exportSettings; | ||
public string[] effects; | ||
public string characters; | ||
public Style style; | ||
public int layoutVersion; | ||
public string[] characterStyleOverrides; | ||
public string styleOverrideTable; | ||
public string[] lineTypes; | ||
public int[] lineIndentations; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[System.Serializable] | ||
public class Absolute { | ||
public float x; | ||
public float y; | ||
public float width; | ||
public float height; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[System.Serializable] | ||
public class Color { | ||
public float r; | ||
public float g; | ||
public float b; | ||
public float a; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[System.Serializable] | ||
public class ComponentProperty { | ||
public PropertyDefinitions PositionX; | ||
public PropertyDefinitions PositionY; | ||
public PropertyDefinitions PositionZ; | ||
public PropertyDefinitions RotationX; | ||
public PropertyDefinitions RotationY; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[System.Serializable] | ||
public class Constraints { | ||
public string vertical; | ||
public string horizontal; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[System.Serializable] | ||
public class Constrait { | ||
public string type; | ||
public string value; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[System.Serializable] | ||
public class ExportSettings { | ||
public string suffix; | ||
public string format; | ||
public Constrait constrait; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[System.Serializable] | ||
public class Fills { | ||
public string blendMode; | ||
public string type; | ||
public bool visible = true; | ||
public string scaleMode; | ||
public string imageRef; | ||
public Color color; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[System.Serializable] | ||
public class PropertyDefinitions{ | ||
public string type; | ||
public string defaultValue; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[System.Serializable] | ||
public class PrototypeDevice { | ||
public string type; | ||
public Size size; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.