mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-10-27 04:38:22 -05:00
Move Assets/* (expect Plugins) to Assets/VRM/*
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static class ArraySegmentExtensions
|
||||
{
|
||||
public static T[] ArrayOrCopy<T>(this ArraySegment<T> self)
|
||||
{
|
||||
if (self.Array == null || self.Count==0)
|
||||
{
|
||||
return new T[] { };
|
||||
}
|
||||
else if(self.Offset==0 && self.Count==self.Array.Length)
|
||||
{
|
||||
return self.Array;
|
||||
}
|
||||
else
|
||||
{
|
||||
var array = new T[self.Count];
|
||||
Array.Copy(self.Array, self.Offset, array, 0, self.Count);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<T> ToEnumerable<T>(this ArraySegment<T> self)
|
||||
{
|
||||
return self.Array.Skip(self.Offset).Take(self.Count);
|
||||
}
|
||||
|
||||
public static void Set<T>(this ArraySegment<T> self, int index, T value)
|
||||
{
|
||||
if (index < 0 || index >= self.Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
self.Array[self.Offset + index] = value;
|
||||
}
|
||||
|
||||
public static T Get<T>(this ArraySegment<T> self, int index)
|
||||
{
|
||||
if (index < 0 || index >= self.Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
return self.Array[self.Offset + index];
|
||||
}
|
||||
|
||||
public static ArraySegment<T> Advance<T>(this ArraySegment<T> self, Int32 n)
|
||||
{
|
||||
return new ArraySegment<T>(self.Array, self.Offset + n, self.Count - n);
|
||||
}
|
||||
|
||||
public static ArraySegment<T> Take<T>(this ArraySegment<T> self, Int32 n)
|
||||
{
|
||||
return new ArraySegment<T>(self.Array, self.Offset, n);
|
||||
}
|
||||
|
||||
public static T[] TakeReversedArray<T>(this ArraySegment<T> self, Int32 n)
|
||||
{
|
||||
var array = new T[n];
|
||||
var x = n - 1;
|
||||
for (int i = 0; i < n; ++i, --x)
|
||||
{
|
||||
array[i] = self.Get(x);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public static byte[] Concat(this byte[] lhs, ArraySegment<byte> rhs)
|
||||
{
|
||||
return new ArraySegment<byte>(lhs).Concat(rhs);
|
||||
}
|
||||
|
||||
public static byte[] Concat(this ArraySegment<byte> lhs, ArraySegment<byte> rhs)
|
||||
{
|
||||
var bytes = new byte[lhs.Count + rhs.Count];
|
||||
Buffer.BlockCopy(lhs.Array, lhs.Offset, bytes, 0, lhs.Count);
|
||||
Buffer.BlockCopy(rhs.Array, rhs.Offset, bytes, lhs.Count, rhs.Count);
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12d3e22e2e62d4948a5aff4bc42208e9
|
||||
timeCreated: 1495517072
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
60
Assets/VRM/UniJSON/Scripts/Extensions/ByteExtensions.cs
Normal file
60
Assets/VRM/UniJSON/Scripts/Extensions/ByteExtensions.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static class ByteExtensions
|
||||
{
|
||||
public static Byte GetHexDigit(this UInt16 n, int index)
|
||||
{
|
||||
return (Byte)(n >> 8 * index & 0xff);
|
||||
}
|
||||
public static Byte GetHexDigit(this UInt32 n, int index)
|
||||
{
|
||||
return (Byte)(n >> 8 * index & 0xff);
|
||||
}
|
||||
public static Byte GetHexDigit(this UInt64 n, int index)
|
||||
{
|
||||
return (Byte)(n >> 8 * index & 0xff);
|
||||
}
|
||||
public static Byte GetHexDigit(this Int16 n, int index)
|
||||
{
|
||||
return (Byte)(n >> 8 * index & 0xff);
|
||||
}
|
||||
public static Byte GetHexDigit(this Int32 n, int index)
|
||||
{
|
||||
return (Byte)(n >> 8 * index & 0xff);
|
||||
}
|
||||
public static Byte GetHexDigit(this Int64 n, int index)
|
||||
{
|
||||
return (Byte)(n >> 8 * index & 0xff);
|
||||
}
|
||||
|
||||
public static UInt32 ToUint32(this Single n, Byte[] buffer)
|
||||
{
|
||||
if (buffer.Length < 4)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
using (var ms = new MemoryStream(buffer))
|
||||
using (var w = new BinaryWriter(ms))
|
||||
{
|
||||
w.Write(n);
|
||||
}
|
||||
return BitConverter.ToUInt32(buffer, 0);
|
||||
}
|
||||
public static UInt64 ToUint64(this Double n, Byte[] buffer)
|
||||
{
|
||||
if (buffer.Length < 8)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
using (var ms = new MemoryStream(buffer))
|
||||
using (var w = new BinaryWriter(ms))
|
||||
{
|
||||
w.Write(n);
|
||||
}
|
||||
return BitConverter.ToUInt64(buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/VRM/UniJSON/Scripts/Extensions/ByteExtensions.cs.meta
Normal file
12
Assets/VRM/UniJSON/Scripts/Extensions/ByteExtensions.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa32ad3ea4c1ec540a03225c0d520af9
|
||||
timeCreated: 1495517078
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static class DateTimeOffsetExtensions
|
||||
{
|
||||
public const long TicksPerSecond = 10000000;
|
||||
public readonly static DateTimeOffset EpocTime = new DateTimeOffset(1970, 1, 1, 0, 0, 0, 0, TimeSpan.Zero);
|
||||
#if !NET_4_6 && !NET_STANDARD_2_0
|
||||
public static long ToUnixTimeSeconds(this DateTimeOffset now)
|
||||
{
|
||||
if (now < EpocTime)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
return (now - EpocTime).Ticks / TicksPerSecond;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2fd687914fcde848ab36867817cb873
|
||||
timeCreated: 1544155597
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
15
Assets/VRM/UniJSON/Scripts/Extensions/EnumExtensions.cs
Normal file
15
Assets/VRM/UniJSON/Scripts/Extensions/EnumExtensions.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static class EnumExtensions
|
||||
{
|
||||
public static bool HasFlag(this Enum keys, Enum flag)
|
||||
{
|
||||
if (keys.GetType() != flag.GetType())
|
||||
throw new ArgumentException("Type Mismatch");
|
||||
return (Convert.ToUInt64(keys) & Convert.ToUInt64(flag)) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/VRM/UniJSON/Scripts/Extensions/EnumExtensions.cs.meta
Normal file
12
Assets/VRM/UniJSON/Scripts/Extensions/EnumExtensions.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8691eccccb3e214db8bc5b86179f428
|
||||
timeCreated: 1526057070
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
52
Assets/VRM/UniJSON/Scripts/Extensions/ParserExtensions.cs
Normal file
52
Assets/VRM/UniJSON/Scripts/Extensions/ParserExtensions.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static ListTreeNode<JsonValue> ParseAsJson(this string json)
|
||||
{
|
||||
return JsonParser.Parse(json);
|
||||
}
|
||||
public static ListTreeNode<JsonValue> ParseAsJson(this Utf8String json)
|
||||
{
|
||||
return JsonParser.Parse(json);
|
||||
}
|
||||
public static ListTreeNode<JsonValue> ParseAsJson(this byte[] bytes)
|
||||
{
|
||||
return JsonParser.Parse(new Utf8String(bytes));
|
||||
}
|
||||
public static ListTreeNode<JsonValue> ParseAsJson(this ArraySegment<byte> bytes)
|
||||
{
|
||||
return JsonParser.Parse(new Utf8String(bytes));
|
||||
}
|
||||
|
||||
public static ListTreeNode<MsgPackValue> ParseAsMsgPack(this byte[] bytes)
|
||||
{
|
||||
return MsgPackParser.Parse(bytes);
|
||||
}
|
||||
public static ListTreeNode<MsgPackValue> ParseAsMsgPack(this ArraySegment<byte> bytes)
|
||||
{
|
||||
return MsgPackParser.Parse(bytes);
|
||||
}
|
||||
|
||||
public static ListTreeNode<TomlValue> ParseAsToml(this string toml)
|
||||
{
|
||||
return TomlParser.Parse(toml);
|
||||
}
|
||||
public static ListTreeNode<TomlValue> ParseAsToml(this Utf8String toml)
|
||||
{
|
||||
return TomlParser.Parse(toml);
|
||||
}
|
||||
public static ListTreeNode<TomlValue> ParseAsToml(this byte[] bytes)
|
||||
{
|
||||
return TomlParser.Parse(new Utf8String(bytes));
|
||||
}
|
||||
public static ListTreeNode<TomlValue> ParseAsToml(this ArraySegment<byte> bytes)
|
||||
{
|
||||
return TomlParser.Parse(new Utf8String(bytes));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c25e655e5dc993145a70d9ddde6a6034
|
||||
timeCreated: 1545735557
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
28
Assets/VRM/UniJSON/Scripts/Extensions/TypeExtensions.cs
Normal file
28
Assets/VRM/UniJSON/Scripts/Extensions/TypeExtensions.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace UniJSON
|
||||
{
|
||||
public static class TypeExtensions
|
||||
{
|
||||
public static bool GetIsGenericList(this Type t)
|
||||
{
|
||||
if (t == null) return false;
|
||||
|
||||
return t.IsGenericType
|
||||
&& (t.GetGenericTypeDefinition() == typeof(List<>));
|
||||
}
|
||||
|
||||
public static bool GetIsGenericDictionary(this Type t)
|
||||
{
|
||||
if (t == null) return false;
|
||||
|
||||
return t.IsGenericType
|
||||
&& (t.GetGenericTypeDefinition() == typeof(Dictionary<,>)
|
||||
&& t.GetGenericArguments().FirstOrDefault() == typeof(string)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/VRM/UniJSON/Scripts/Extensions/TypeExtensions.cs.meta
Normal file
12
Assets/VRM/UniJSON/Scripts/Extensions/TypeExtensions.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fb728ca27f90c947890313df5f94d4d
|
||||
timeCreated: 1531634657
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user