graph chart引入&骑行结果弹窗
This commit is contained in:
1 parent
40d118cea3
commit
96f3644b5b
2374 files changed
+485161
-2410
No files matched your search
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012-2017 Markus Göbel (Bunny83)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d7d903c5275d27429d51baf04556c3b
|
||||
timeCreated: 1536774789
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Whitespace-only changes.
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c517b8d40b717594ead58238109714cc
|
||||
timeCreated: 1536774789
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bce8c0faad072d3448f2c1124ce743f9
|
||||
timeCreated: 1536774790
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+298
@@ -0,0 +1,298 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
//#define USE_SharpZipLib
|
||||
/* * * * *
|
||||
* This is an extension of the SimpleJSON framework to provide methods to
|
||||
* serialize a JSON object tree into a compact binary format. Optionally the
|
||||
* binary stream can be compressed with the SharpZipLib when using the define
|
||||
* "USE_SharpZipLib"
|
||||
*
|
||||
* Those methods where originally part of the framework but since it's rarely
|
||||
* used I've extracted this part into this seperate module file.
|
||||
*
|
||||
* You can use the define "SimpleJSON_ExcludeBinary" to selectively disable
|
||||
* this extension without the need to remove the file from the project.
|
||||
*
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2012-2017 Markus Göbel (Bunny83)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* * * * */
|
||||
using System;
|
||||
|
||||
namespace SimpleJSON
|
||||
{
|
||||
#if !SimpleJSON_ExcludeBinary
|
||||
public abstract partial class JSONNode
|
||||
{
|
||||
public abstract void SerializeBinary(System.IO.BinaryWriter aWriter);
|
||||
|
||||
public void SaveToBinaryStream(System.IO.Stream aData)
|
||||
{
|
||||
var W = new System.IO.BinaryWriter(aData);
|
||||
SerializeBinary(W);
|
||||
}
|
||||
|
||||
#if USE_SharpZipLib
|
||||
public void SaveToCompressedStream(System.IO.Stream aData)
|
||||
{
|
||||
using (var gzipOut = new ICSharpCode.SharpZipLib.BZip2.BZip2OutputStream(aData))
|
||||
{
|
||||
gzipOut.IsStreamOwner = false;
|
||||
SaveToBinaryStream(gzipOut);
|
||||
gzipOut.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveToCompressedFile(string aFileName)
|
||||
{
|
||||
|
||||
System.IO.Directory.CreateDirectory((new System.IO.FileInfo(aFileName)).Directory.FullName);
|
||||
using(var F = System.IO.File.OpenWrite(aFileName))
|
||||
{
|
||||
SaveToCompressedStream(F);
|
||||
}
|
||||
}
|
||||
public string SaveToCompressedBase64()
|
||||
{
|
||||
using (var stream = new System.IO.MemoryStream())
|
||||
{
|
||||
SaveToCompressedStream(stream);
|
||||
stream.Position = 0;
|
||||
return System.Convert.ToBase64String(stream.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
public void SaveToCompressedStream(System.IO.Stream aData)
|
||||
{
|
||||
throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON");
|
||||
}
|
||||
|
||||
public void SaveToCompressedFile(string aFileName)
|
||||
{
|
||||
throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON");
|
||||
}
|
||||
|
||||
public string SaveToCompressedBase64()
|
||||
{
|
||||
throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON");
|
||||
}
|
||||
#endif
|
||||
|
||||
public void SaveToBinaryFile(string aFileName)
|
||||
{
|
||||
System.IO.Directory.CreateDirectory((new System.IO.FileInfo(aFileName)).Directory.FullName);
|
||||
using (var F = System.IO.File.OpenWrite(aFileName))
|
||||
{
|
||||
SaveToBinaryStream(F);
|
||||
}
|
||||
}
|
||||
|
||||
public string SaveToBinaryBase64()
|
||||
{
|
||||
using (var stream = new System.IO.MemoryStream())
|
||||
{
|
||||
SaveToBinaryStream(stream);
|
||||
stream.Position = 0;
|
||||
return System.Convert.ToBase64String(stream.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public static JSONNode DeserializeBinary(System.IO.BinaryReader aReader)
|
||||
{
|
||||
JSONNodeType type = (JSONNodeType)aReader.ReadByte();
|
||||
switch (type)
|
||||
{
|
||||
case JSONNodeType.Array:
|
||||
{
|
||||
int count = aReader.ReadInt32();
|
||||
JSONArray tmp = new JSONArray();
|
||||
for (int i = 0; i < count; i++)
|
||||
tmp.Add(DeserializeBinary(aReader));
|
||||
return tmp;
|
||||
}
|
||||
case JSONNodeType.Object:
|
||||
{
|
||||
int count = aReader.ReadInt32();
|
||||
JSONObject tmp = new JSONObject();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
string key = aReader.ReadString();
|
||||
var val = DeserializeBinary(aReader);
|
||||
tmp.Add(key, val);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
case JSONNodeType.String:
|
||||
{
|
||||
return new JSONString(aReader.ReadString());
|
||||
}
|
||||
case JSONNodeType.Number:
|
||||
{
|
||||
return new JSONNumber(aReader.ReadDouble());
|
||||
}
|
||||
case JSONNodeType.Boolean:
|
||||
{
|
||||
return new JSONBool(aReader.ReadBoolean());
|
||||
}
|
||||
case JSONNodeType.NullValue:
|
||||
{
|
||||
return JSONNull.CreateOrGet();
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw new Exception("Error deserializing JSON. Unknown tag: " + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_SharpZipLib
|
||||
public static JSONNode LoadFromCompressedStream(System.IO.Stream aData)
|
||||
{
|
||||
var zin = new ICSharpCode.SharpZipLib.BZip2.BZip2InputStream(aData);
|
||||
return LoadFromStream(zin);
|
||||
}
|
||||
public static JSONNode LoadFromCompressedFile(string aFileName)
|
||||
{
|
||||
using(var F = System.IO.File.OpenRead(aFileName))
|
||||
{
|
||||
return LoadFromCompressedStream(F);
|
||||
}
|
||||
}
|
||||
public static JSONNode LoadFromCompressedBase64(string aBase64)
|
||||
{
|
||||
var tmp = System.Convert.FromBase64String(aBase64);
|
||||
var stream = new System.IO.MemoryStream(tmp);
|
||||
stream.Position = 0;
|
||||
return LoadFromCompressedStream(stream);
|
||||
}
|
||||
#else
|
||||
public static JSONNode LoadFromCompressedFile(string aFileName)
|
||||
{
|
||||
throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON");
|
||||
}
|
||||
|
||||
public static JSONNode LoadFromCompressedStream(System.IO.Stream aData)
|
||||
{
|
||||
throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON");
|
||||
}
|
||||
|
||||
public static JSONNode LoadFromCompressedBase64(string aBase64)
|
||||
{
|
||||
throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON");
|
||||
}
|
||||
#endif
|
||||
|
||||
public static JSONNode LoadFromBinaryStream(System.IO.Stream aData)
|
||||
{
|
||||
using (var R = new System.IO.BinaryReader(aData))
|
||||
{
|
||||
return DeserializeBinary(R);
|
||||
}
|
||||
}
|
||||
|
||||
public static JSONNode LoadFromBinaryFile(string aFileName)
|
||||
{
|
||||
using (var F = System.IO.File.OpenRead(aFileName))
|
||||
{
|
||||
return LoadFromBinaryStream(F);
|
||||
}
|
||||
}
|
||||
|
||||
public static JSONNode LoadFromBinaryBase64(string aBase64)
|
||||
{
|
||||
var tmp = System.Convert.FromBase64String(aBase64);
|
||||
var stream = new System.IO.MemoryStream(tmp);
|
||||
stream.Position = 0;
|
||||
return LoadFromBinaryStream(stream);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class JSONArray : JSONNode
|
||||
{
|
||||
public override void SerializeBinary(System.IO.BinaryWriter aWriter)
|
||||
{
|
||||
aWriter.Write((byte)JSONNodeType.Array);
|
||||
aWriter.Write(m_List.Count);
|
||||
for (int i = 0; i < m_List.Count; i++)
|
||||
{
|
||||
m_List[i].SerializeBinary(aWriter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class JSONObject : JSONNode
|
||||
{
|
||||
public override void SerializeBinary(System.IO.BinaryWriter aWriter)
|
||||
{
|
||||
aWriter.Write((byte)JSONNodeType.Object);
|
||||
aWriter.Write(m_Dict.Count);
|
||||
foreach (string K in m_Dict.Keys)
|
||||
{
|
||||
aWriter.Write(K);
|
||||
m_Dict[K].SerializeBinary(aWriter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class JSONString : JSONNode
|
||||
{
|
||||
public override void SerializeBinary(System.IO.BinaryWriter aWriter)
|
||||
{
|
||||
aWriter.Write((byte)JSONNodeType.String);
|
||||
aWriter.Write(m_Data);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class JSONNumber : JSONNode
|
||||
{
|
||||
public override void SerializeBinary(System.IO.BinaryWriter aWriter)
|
||||
{
|
||||
aWriter.Write((byte)JSONNodeType.Number);
|
||||
aWriter.Write(m_Data);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class JSONBool : JSONNode
|
||||
{
|
||||
public override void SerializeBinary(System.IO.BinaryWriter aWriter)
|
||||
{
|
||||
aWriter.Write((byte)JSONNodeType.Boolean);
|
||||
aWriter.Write(m_Data);
|
||||
}
|
||||
}
|
||||
public partial class JSONNull : JSONNode
|
||||
{
|
||||
public override void SerializeBinary(System.IO.BinaryWriter aWriter)
|
||||
{
|
||||
aWriter.Write((byte)JSONNodeType.NullValue);
|
||||
}
|
||||
}
|
||||
internal partial class JSONLazyCreator : JSONNode
|
||||
{
|
||||
public override void SerializeBinary(System.IO.BinaryWriter aWriter)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 810e70c37cced8a4b9c3fb8e5079f283
|
||||
timeCreated: 1536774789
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,370 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
#region License and information
|
||||
/* * * * *
|
||||
*
|
||||
* Unity extension for the SimpleJSON framework. It does only work together with
|
||||
* the SimpleJSON.cs
|
||||
* It provides several helpers and conversion operators to serialize/deserialize
|
||||
* common Unity types such as Vector2/3/4, Rect, RectOffset, Quaternion and
|
||||
* Matrix4x4 as JSONObject or JSONArray.
|
||||
* This extension will add 3 static settings to the JSONNode class:
|
||||
* ( VectorContainerType, QuaternionContainerType, RectContainerType ) which
|
||||
* control what node type should be used for serializing the given type. So a
|
||||
* Vector3 as array would look like [12,32,24] and {"x":12, "y":32, "z":24} as
|
||||
* object.
|
||||
*
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2012-2017 Markus Göbel (Bunny83)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* * * * */
|
||||
|
||||
#endregion License and information
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace SimpleJSON
|
||||
{
|
||||
public enum JSONContainerType { Array, Object }
|
||||
public partial class JSONNode
|
||||
{
|
||||
public static JSONContainerType VectorContainerType = JSONContainerType.Array;
|
||||
public static JSONContainerType QuaternionContainerType = JSONContainerType.Array;
|
||||
public static JSONContainerType RectContainerType = JSONContainerType.Array;
|
||||
private static JSONNode GetContainer(JSONContainerType aType)
|
||||
{
|
||||
if (aType == JSONContainerType.Array)
|
||||
return new JSONArray();
|
||||
return new JSONObject();
|
||||
}
|
||||
|
||||
#region implicit conversion operators
|
||||
public static implicit operator JSONNode(Vector2 aVec)
|
||||
{
|
||||
JSONNode n = GetContainer(VectorContainerType);
|
||||
n.WriteVector2(aVec);
|
||||
return n;
|
||||
}
|
||||
public static implicit operator JSONNode(Vector3 aVec)
|
||||
{
|
||||
JSONNode n = GetContainer(VectorContainerType);
|
||||
n.WriteVector3(aVec);
|
||||
return n;
|
||||
}
|
||||
public static implicit operator JSONNode(Vector4 aVec)
|
||||
{
|
||||
JSONNode n = GetContainer(VectorContainerType);
|
||||
n.WriteVector4(aVec);
|
||||
return n;
|
||||
}
|
||||
public static implicit operator JSONNode(Quaternion aRot)
|
||||
{
|
||||
JSONNode n = GetContainer(QuaternionContainerType);
|
||||
n.WriteQuaternion(aRot);
|
||||
return n;
|
||||
}
|
||||
public static implicit operator JSONNode(Rect aRect)
|
||||
{
|
||||
JSONNode n = GetContainer(RectContainerType);
|
||||
n.WriteRect(aRect);
|
||||
return n;
|
||||
}
|
||||
public static implicit operator JSONNode(RectOffset aRect)
|
||||
{
|
||||
JSONNode n = GetContainer(RectContainerType);
|
||||
n.WriteRectOffset(aRect);
|
||||
return n;
|
||||
}
|
||||
|
||||
public static implicit operator Vector2(JSONNode aNode)
|
||||
{
|
||||
return aNode.ReadVector2();
|
||||
}
|
||||
public static implicit operator Vector3(JSONNode aNode)
|
||||
{
|
||||
return aNode.ReadVector3();
|
||||
}
|
||||
public static implicit operator Vector4(JSONNode aNode)
|
||||
{
|
||||
return aNode.ReadVector4();
|
||||
}
|
||||
public static implicit operator Quaternion(JSONNode aNode)
|
||||
{
|
||||
return aNode.ReadQuaternion();
|
||||
}
|
||||
public static implicit operator Rect(JSONNode aNode)
|
||||
{
|
||||
return aNode.ReadRect();
|
||||
}
|
||||
public static implicit operator RectOffset(JSONNode aNode)
|
||||
{
|
||||
return aNode.ReadRectOffset();
|
||||
}
|
||||
#endregion implicit conversion operators
|
||||
|
||||
#region Vector2
|
||||
public Vector2 ReadVector2(Vector2 aDefault)
|
||||
{
|
||||
if (IsObject)
|
||||
return new Vector2(this["x"].AsFloat, this["y"].AsFloat);
|
||||
if (IsArray)
|
||||
return new Vector2(this[0].AsFloat, this[1].AsFloat);
|
||||
return aDefault;
|
||||
}
|
||||
public Vector2 ReadVector2(string aXName, string aYName)
|
||||
{
|
||||
if (IsObject)
|
||||
{
|
||||
return new Vector2(this[aXName].AsFloat, this[aYName].AsFloat);
|
||||
}
|
||||
return Vector2.zero;
|
||||
}
|
||||
|
||||
public Vector2 ReadVector2()
|
||||
{
|
||||
return ReadVector2(Vector2.zero);
|
||||
}
|
||||
public JSONNode WriteVector2(Vector2 aVec, string aXName = "x", string aYName = "y")
|
||||
{
|
||||
if (IsObject)
|
||||
{
|
||||
Inline = true;
|
||||
this[aXName].AsFloat = aVec.x;
|
||||
this[aYName].AsFloat = aVec.y;
|
||||
}
|
||||
else if (IsArray)
|
||||
{
|
||||
Inline = true;
|
||||
this[0].AsFloat = aVec.x;
|
||||
this[1].AsFloat = aVec.y;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
#endregion Vector2
|
||||
|
||||
#region Vector3
|
||||
public Vector3 ReadVector3(Vector3 aDefault)
|
||||
{
|
||||
if (IsObject)
|
||||
return new Vector3(this["x"].AsFloat, this["y"].AsFloat, this["z"].AsFloat);
|
||||
if (IsArray)
|
||||
return new Vector3(this[0].AsFloat, this[1].AsFloat, this[2].AsFloat);
|
||||
return aDefault;
|
||||
}
|
||||
public Vector3 ReadVector3(string aXName, string aYName, string aZName)
|
||||
{
|
||||
if (IsObject)
|
||||
return new Vector3(this[aXName].AsFloat, this[aYName].AsFloat, this[aZName].AsFloat);
|
||||
return Vector3.zero;
|
||||
}
|
||||
public Vector3 ReadVector3()
|
||||
{
|
||||
return ReadVector3(Vector3.zero);
|
||||
}
|
||||
public JSONNode WriteVector3(Vector3 aVec, string aXName = "x", string aYName = "y", string aZName = "z")
|
||||
{
|
||||
if (IsObject)
|
||||
{
|
||||
Inline = true;
|
||||
this[aXName].AsFloat = aVec.x;
|
||||
this[aYName].AsFloat = aVec.y;
|
||||
this[aZName].AsFloat = aVec.z;
|
||||
}
|
||||
else if (IsArray)
|
||||
{
|
||||
Inline = true;
|
||||
this[0].AsFloat = aVec.x;
|
||||
this[1].AsFloat = aVec.y;
|
||||
this[2].AsFloat = aVec.z;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
#endregion Vector3
|
||||
|
||||
#region Vector4
|
||||
public Vector4 ReadVector4(Vector4 aDefault)
|
||||
{
|
||||
if (IsObject)
|
||||
return new Vector4(this["x"].AsFloat, this["y"].AsFloat, this["z"].AsFloat, this["w"].AsFloat);
|
||||
if (IsArray)
|
||||
return new Vector4(this[0].AsFloat, this[1].AsFloat, this[2].AsFloat, this[3].AsFloat);
|
||||
return aDefault;
|
||||
}
|
||||
public Vector4 ReadVector4()
|
||||
{
|
||||
return ReadVector4(Vector4.zero);
|
||||
}
|
||||
public JSONNode WriteVector4(Vector4 aVec)
|
||||
{
|
||||
if (IsObject)
|
||||
{
|
||||
Inline = true;
|
||||
this["x"].AsFloat = aVec.x;
|
||||
this["y"].AsFloat = aVec.y;
|
||||
this["z"].AsFloat = aVec.z;
|
||||
this["w"].AsFloat = aVec.w;
|
||||
}
|
||||
else if (IsArray)
|
||||
{
|
||||
Inline = true;
|
||||
this[0].AsFloat = aVec.x;
|
||||
this[1].AsFloat = aVec.y;
|
||||
this[2].AsFloat = aVec.z;
|
||||
this[3].AsFloat = aVec.w;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
#endregion Vector4
|
||||
|
||||
#region Quaternion
|
||||
public Quaternion ReadQuaternion(Quaternion aDefault)
|
||||
{
|
||||
if (IsObject)
|
||||
return new Quaternion(this["x"].AsFloat, this["y"].AsFloat, this["z"].AsFloat, this["w"].AsFloat);
|
||||
if (IsArray)
|
||||
return new Quaternion(this[0].AsFloat, this[1].AsFloat, this[2].AsFloat, this[3].AsFloat);
|
||||
return aDefault;
|
||||
}
|
||||
public Quaternion ReadQuaternion()
|
||||
{
|
||||
return ReadQuaternion(Quaternion.identity);
|
||||
}
|
||||
public JSONNode WriteQuaternion(Quaternion aRot)
|
||||
{
|
||||
if (IsObject)
|
||||
{
|
||||
Inline = true;
|
||||
this["x"].AsFloat = aRot.x;
|
||||
this["y"].AsFloat = aRot.y;
|
||||
this["z"].AsFloat = aRot.z;
|
||||
this["w"].AsFloat = aRot.w;
|
||||
}
|
||||
else if (IsArray)
|
||||
{
|
||||
Inline = true;
|
||||
this[0].AsFloat = aRot.x;
|
||||
this[1].AsFloat = aRot.y;
|
||||
this[2].AsFloat = aRot.z;
|
||||
this[3].AsFloat = aRot.w;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
#endregion Quaternion
|
||||
|
||||
#region Rect
|
||||
public Rect ReadRect(Rect aDefault)
|
||||
{
|
||||
if (IsObject)
|
||||
return new Rect(this["x"].AsFloat, this["y"].AsFloat, this["width"].AsFloat, this["height"].AsFloat);
|
||||
if (IsArray)
|
||||
return new Rect(this[0].AsFloat, this[1].AsFloat, this[2].AsFloat, this[3].AsFloat);
|
||||
return aDefault;
|
||||
}
|
||||
public Rect ReadRect()
|
||||
{
|
||||
return ReadRect(new Rect());
|
||||
}
|
||||
public JSONNode WriteRect(Rect aRect)
|
||||
{
|
||||
if (IsObject)
|
||||
{
|
||||
Inline = true;
|
||||
this["x"].AsFloat = aRect.x;
|
||||
this["y"].AsFloat = aRect.y;
|
||||
this["width"].AsFloat = aRect.width;
|
||||
this["height"].AsFloat = aRect.height;
|
||||
}
|
||||
else if (IsArray)
|
||||
{
|
||||
Inline = true;
|
||||
this[0].AsFloat = aRect.x;
|
||||
this[1].AsFloat = aRect.y;
|
||||
this[2].AsFloat = aRect.width;
|
||||
this[3].AsFloat = aRect.height;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
#endregion Rect
|
||||
|
||||
#region RectOffset
|
||||
public RectOffset ReadRectOffset(RectOffset aDefault)
|
||||
{
|
||||
if (this is JSONObject)
|
||||
return new RectOffset(this["left"].AsInt, this["right"].AsInt, this["top"].AsInt, this["bottom"].AsInt);
|
||||
if (this is JSONArray)
|
||||
return new RectOffset(this[0].AsInt, this[1].AsInt, this[2].AsInt, this[3].AsInt);
|
||||
return aDefault;
|
||||
}
|
||||
public RectOffset ReadRectOffset()
|
||||
{
|
||||
return ReadRectOffset(new RectOffset());
|
||||
}
|
||||
public JSONNode WriteRectOffset(RectOffset aRect)
|
||||
{
|
||||
if (IsObject)
|
||||
{
|
||||
Inline = true;
|
||||
this["left"].AsInt = aRect.left;
|
||||
this["right"].AsInt = aRect.right;
|
||||
this["top"].AsInt = aRect.top;
|
||||
this["bottom"].AsInt = aRect.bottom;
|
||||
}
|
||||
else if (IsArray)
|
||||
{
|
||||
Inline = true;
|
||||
this[0].AsInt = aRect.left;
|
||||
this[1].AsInt = aRect.right;
|
||||
this[2].AsInt = aRect.top;
|
||||
this[3].AsInt = aRect.bottom;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
#endregion RectOffset
|
||||
|
||||
#region Matrix4x4
|
||||
public Matrix4x4 ReadMatrix()
|
||||
{
|
||||
Matrix4x4 result = Matrix4x4.identity;
|
||||
if (IsArray)
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
result[i] = this[i].AsFloat;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public JSONNode WriteMatrix(Matrix4x4 aMatrix)
|
||||
{
|
||||
if (IsArray)
|
||||
{
|
||||
Inline = true;
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
this[i].AsFloat = aMatrix[i];
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
#endregion Matrix4x4
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d41c3309284cde240866149615704368
|
||||
timeCreated: 1536774793
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user