├── .gitignore ├── .gitmodules ├── Assets ├── AddressBook.sproto ├── Main.cs ├── foobar.sproto ├── main.unity ├── main.unity.meta ├── protocol.sproto └── test │ ├── Benchmark.cs │ ├── Client.cs │ ├── Test.cs │ ├── TestAll.cs │ ├── TestRpc.cs │ ├── TestUnit.cs │ └── Util.cs ├── ProjectSettings ├── AudioManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NavMeshLayers.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── QualitySettings.asset ├── TagManager.asset └── TimeManager.asset ├── README.md └── benchmark /.gitignore: -------------------------------------------------------------------------------- 1 | /Temp 2 | /Library 3 | *.csproj 4 | *.sln 5 | *.DS_Store 6 | *.meta 7 | *.userprefs 8 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Assets/sproto-cs"] 2 | path = Assets/sproto-cs 3 | url = https://github.com/jintiao/sproto-cs 4 | -------------------------------------------------------------------------------- /Assets/AddressBook.sproto: -------------------------------------------------------------------------------- 1 | .Person { 2 | name 0 : string 3 | id 1 : integer 4 | email 2 : string 5 | 6 | .PhoneNumber { 7 | number 0 : string 8 | type 1 : integer 9 | } 10 | 11 | phone 3 : *PhoneNumber 12 | } 13 | 14 | .AddressBook { 15 | person 0 : *Person(id) 16 | others 1 : *Person 17 | } -------------------------------------------------------------------------------- /Assets/Main.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.IO; 4 | using System; 5 | 6 | public class Main : MonoBehaviour { 7 | private Client mClient = null; 8 | private string mText = ""; 9 | 10 | void Start () { 11 | new TestUnit ().Run (); 12 | new Test ().Run (); 13 | new TestAll ().Run (); 14 | new TestRpc ().Run (); 15 | } 16 | 17 | void OnGUI () { 18 | if (GUI.Button (new Rect (10, 10, 100, 100), "Benchmark")){ 19 | new Benchmark().Run (); 20 | } 21 | 22 | if (mClient != null) { 23 | 24 | mText = GUI.TextField (new Rect(120, 150, 200, 40), mText, 25); 25 | if (GUI.Button (new Rect (330, 150, 80, 40), "Get")){ 26 | mClient.SendGet (mText); 27 | mText = ""; 28 | } 29 | 30 | GUI.enabled = false; 31 | } 32 | 33 | if (GUI.Button (new Rect (10, 150, 100, 100), "Client")){ 34 | mClient = new Client(); 35 | mClient.Run (); 36 | } 37 | 38 | GUI.enabled = true; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Assets/foobar.sproto: -------------------------------------------------------------------------------- 1 | .foobar { 2 | .nest { 3 | a 1 : string 4 | b 3 : boolean 5 | c 5 : integer 6 | } 7 | a 0 : string 8 | b 1 : integer 9 | c 2 : boolean 10 | d 3 : nest 11 | 12 | e 4 : *string 13 | f 5 : *integer 14 | g 6 : *boolean 15 | h 7 : *foobar 16 | } -------------------------------------------------------------------------------- /Assets/main.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | SceneSettings: 5 | m_ObjectHideFlags: 0 6 | m_PVSData: 7 | m_PVSObjectsArray: [] 8 | m_PVSPortalsArray: [] 9 | m_OcclusionBakeSettings: 10 | smallestOccluder: 5 11 | smallestHole: .25 12 | backfaceThreshold: 100 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_Fog: 0 16 | m_FogColor: {r: .5, g: .5, b: .5, a: 1} 17 | m_FogMode: 3 18 | m_FogDensity: .00999999978 19 | m_LinearFogStart: 0 20 | m_LinearFogEnd: 300 21 | m_AmbientLight: {r: .200000003, g: .200000003, b: .200000003, a: 1} 22 | m_SkyboxMaterial: {fileID: 0} 23 | m_HaloStrength: .5 24 | m_FlareStrength: 1 25 | m_FlareFadeSpeed: 3 26 | m_HaloTexture: {fileID: 0} 27 | m_SpotCookie: {fileID: 0} 28 | m_ObjectHideFlags: 0 29 | --- !u!127 &3 30 | LevelGameManager: 31 | m_ObjectHideFlags: 0 32 | --- !u!157 &4 33 | LightmapSettings: 34 | m_ObjectHideFlags: 0 35 | m_LightProbes: {fileID: 0} 36 | m_Lightmaps: [] 37 | m_LightmapsMode: 1 38 | m_BakedColorSpace: 0 39 | m_UseDualLightmapsInForward: 0 40 | m_LightmapEditorSettings: 41 | m_Resolution: 50 42 | m_LastUsedResolution: 0 43 | m_TextureWidth: 1024 44 | m_TextureHeight: 1024 45 | m_BounceBoost: 1 46 | m_BounceIntensity: 1 47 | m_SkyLightColor: {r: .860000014, g: .930000007, b: 1, a: 1} 48 | m_SkyLightIntensity: 0 49 | m_Quality: 0 50 | m_Bounces: 1 51 | m_FinalGatherRays: 1000 52 | m_FinalGatherContrastThreshold: .0500000007 53 | m_FinalGatherGradientThreshold: 0 54 | m_FinalGatherInterpolationPoints: 15 55 | m_AOAmount: 0 56 | m_AOMaxDistance: .100000001 57 | m_AOContrast: 1 58 | m_LODSurfaceMappingDistance: 1 59 | m_Padding: 0 60 | m_TextureCompression: 0 61 | m_LockAtlas: 0 62 | --- !u!196 &5 63 | NavMeshSettings: 64 | m_ObjectHideFlags: 0 65 | m_BuildSettings: 66 | agentRadius: .5 67 | agentHeight: 2 68 | agentSlope: 45 69 | agentClimb: .400000006 70 | ledgeDropHeight: 0 71 | maxJumpAcrossDistance: 0 72 | accuratePlacement: 0 73 | minRegionArea: 2 74 | widthInaccuracy: 16.666666 75 | heightInaccuracy: 10 76 | m_NavMesh: {fileID: 0} 77 | --- !u!1 &1691594113 78 | GameObject: 79 | m_ObjectHideFlags: 0 80 | m_PrefabParentObject: {fileID: 0} 81 | m_PrefabInternal: {fileID: 0} 82 | serializedVersion: 4 83 | m_Component: 84 | - 4: {fileID: 1691594118} 85 | - 20: {fileID: 1691594117} 86 | - 92: {fileID: 1691594116} 87 | - 124: {fileID: 1691594115} 88 | - 81: {fileID: 1691594114} 89 | - 114: {fileID: 1691594119} 90 | m_Layer: 0 91 | m_Name: Main Camera 92 | m_TagString: MainCamera 93 | m_Icon: {fileID: 0} 94 | m_NavMeshLayer: 0 95 | m_StaticEditorFlags: 0 96 | m_IsActive: 1 97 | --- !u!81 &1691594114 98 | AudioListener: 99 | m_ObjectHideFlags: 0 100 | m_PrefabParentObject: {fileID: 0} 101 | m_PrefabInternal: {fileID: 0} 102 | m_GameObject: {fileID: 1691594113} 103 | m_Enabled: 1 104 | --- !u!124 &1691594115 105 | Behaviour: 106 | m_ObjectHideFlags: 0 107 | m_PrefabParentObject: {fileID: 0} 108 | m_PrefabInternal: {fileID: 0} 109 | m_GameObject: {fileID: 1691594113} 110 | m_Enabled: 1 111 | --- !u!92 &1691594116 112 | Behaviour: 113 | m_ObjectHideFlags: 0 114 | m_PrefabParentObject: {fileID: 0} 115 | m_PrefabInternal: {fileID: 0} 116 | m_GameObject: {fileID: 1691594113} 117 | m_Enabled: 1 118 | --- !u!20 &1691594117 119 | Camera: 120 | m_ObjectHideFlags: 0 121 | m_PrefabParentObject: {fileID: 0} 122 | m_PrefabInternal: {fileID: 0} 123 | m_GameObject: {fileID: 1691594113} 124 | m_Enabled: 1 125 | serializedVersion: 2 126 | m_ClearFlags: 1 127 | m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} 128 | m_NormalizedViewPortRect: 129 | serializedVersion: 2 130 | x: 0 131 | y: 0 132 | width: 1 133 | height: 1 134 | near clip plane: .300000012 135 | far clip plane: 1000 136 | field of view: 60 137 | orthographic: 1 138 | orthographic size: 5 139 | m_Depth: -1 140 | m_CullingMask: 141 | serializedVersion: 2 142 | m_Bits: 4294967295 143 | m_RenderingPath: -1 144 | m_TargetTexture: {fileID: 0} 145 | m_TargetDisplay: 0 146 | m_HDR: 0 147 | m_OcclusionCulling: 1 148 | m_StereoConvergence: 10 149 | m_StereoSeparation: .0219999999 150 | --- !u!4 &1691594118 151 | Transform: 152 | m_ObjectHideFlags: 0 153 | m_PrefabParentObject: {fileID: 0} 154 | m_PrefabInternal: {fileID: 0} 155 | m_GameObject: {fileID: 1691594113} 156 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 157 | m_LocalPosition: {x: 0, y: 0, z: -10} 158 | m_LocalScale: {x: 1, y: 1, z: 1} 159 | m_Children: [] 160 | m_Father: {fileID: 0} 161 | m_RootOrder: 0 162 | --- !u!114 &1691594119 163 | MonoBehaviour: 164 | m_ObjectHideFlags: 0 165 | m_PrefabParentObject: {fileID: 0} 166 | m_PrefabInternal: {fileID: 0} 167 | m_GameObject: {fileID: 1691594113} 168 | m_Enabled: 1 169 | m_EditorHideFlags: 0 170 | m_Script: {fileID: 11500000, guid: f8d80c0448068414e9f4cf2423c2412c, type: 3} 171 | m_Name: 172 | m_EditorClassIdentifier: 173 | -------------------------------------------------------------------------------- /Assets/main.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea6f87e24116040f8ab3344879c40a5c 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/protocol.sproto: -------------------------------------------------------------------------------- 1 | .package { 2 | type 0 : integer 3 | session 1 : integer 4 | } 5 | 6 | foobar 1 { 7 | request { 8 | what 0 : string 9 | } 10 | response { 11 | ok 0 : boolean 12 | } 13 | } 14 | 15 | foo 2 { 16 | response { 17 | ok 0 : boolean 18 | } 19 | } 20 | 21 | bar 3 {} 22 | 23 | blackhole 4 { 24 | request {} 25 | } -------------------------------------------------------------------------------- /Assets/test/Benchmark.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.IO; 3 | using System; 4 | 5 | public class Benchmark { 6 | private SpObject obj; 7 | SpStream encode_stream = new SpStream (1024); 8 | SpStream pack_stream = new SpStream (1024); 9 | SpStream unpack_stream = new SpStream (1024); 10 | const int BENCHUMARK_RUN_TIMES = 100000; 11 | SpTypeManager manager; 12 | 13 | public Benchmark () { 14 | manager = LoadProto (); 15 | 16 | obj = CreateObject (); 17 | manager.Codec.Encode ("AddressBook", obj, encode_stream); 18 | encode_stream.Position = 0; 19 | SpPacker.Pack (encode_stream, pack_stream); 20 | pack_stream.Position = 0; 21 | SpPacker.Unpack (pack_stream, unpack_stream); 22 | } 23 | 24 | public void Run () { 25 | double encode = Encode (); 26 | double pack = Pack (); 27 | double encodeAndPack = EncodeAndPack (); 28 | double unpack = Unpack (); 29 | double decode = Decode (); 30 | double unpackAndDecode = UnpackAndDecode (); 31 | 32 | Util.Log ("Encode:\t" + encode +" s\n" + 33 | "Pack:\t" + pack +" s\n" + 34 | "EncodeAndPack:\t" + encodeAndPack +" s\n" + 35 | "Unpack:\t" + unpack +" s\n" + 36 | "Decode:\t" + decode +" s\n" + 37 | "UnpackAndDecode:\t" + unpackAndDecode +" s\n" 38 | ); 39 | } 40 | 41 | public double Encode () { 42 | double begin = GetMs (); 43 | 44 | for (int i = 0; i < BENCHUMARK_RUN_TIMES; i++) { 45 | encode_stream.Position = 0; 46 | pack_stream.Position = 0; 47 | unpack_stream.Position = 0; 48 | 49 | manager.Codec.Encode ("AddressBook", obj, encode_stream); 50 | //SpPacker.Pack (encode_stream, pack_stream); 51 | //SpPacker.Unpack (pack_stream, unpack_stream); 52 | unpack_stream.Position = 0; 53 | //manager.Codec.Decode ("AddressBook", unpack_stream); 54 | } 55 | 56 | double end = GetMs (); 57 | return (end - begin)/1000; 58 | } 59 | 60 | public double Pack () { 61 | double begin = GetMs (); 62 | 63 | for (int i = 0; i < BENCHUMARK_RUN_TIMES; i++) { 64 | encode_stream.Position = 0; 65 | pack_stream.Position = 0; 66 | unpack_stream.Position = 0; 67 | 68 | //manager.Codec.Encode ("AddressBook", obj, encode_stream); 69 | SpPacker.Pack (encode_stream, pack_stream); 70 | //SpPacker.Unpack (pack_stream, unpack_stream); 71 | unpack_stream.Position = 0; 72 | //manager.Codec.Decode ("AddressBook", unpack_stream); 73 | } 74 | 75 | double end = GetMs (); 76 | return (end - begin)/1000; 77 | } 78 | 79 | public double EncodeAndPack () { 80 | double begin = GetMs (); 81 | 82 | for (int i = 0; i < BENCHUMARK_RUN_TIMES; i++) { 83 | encode_stream.Position = 0; 84 | pack_stream.Position = 0; 85 | unpack_stream.Position = 0; 86 | 87 | manager.Codec.Encode ("AddressBook", obj, encode_stream); 88 | SpPacker.Pack (encode_stream, pack_stream); 89 | //SpPacker.Unpack (pack_stream, unpack_stream); 90 | unpack_stream.Position = 0; 91 | //manager.Codec.Decode ("AddressBook", unpack_stream); 92 | } 93 | 94 | double end = GetMs (); 95 | return (end - begin)/1000; 96 | } 97 | 98 | public double Unpack () { 99 | double begin = GetMs (); 100 | 101 | for (int i = 0; i < BENCHUMARK_RUN_TIMES; i++) { 102 | encode_stream.Position = 0; 103 | pack_stream.Position = 0; 104 | unpack_stream.Position = 0; 105 | 106 | //manager.Codec.Encode ("AddressBook", obj, encode_stream); 107 | //SpPacker.Pack (encode_stream, pack_stream); 108 | SpPacker.Unpack (pack_stream, unpack_stream); 109 | unpack_stream.Position = 0; 110 | //manager.Codec.Decode ("AddressBook", unpack_stream); 111 | } 112 | 113 | double end = GetMs (); 114 | return (end - begin)/1000; 115 | } 116 | 117 | public double Decode () { 118 | double begin = GetMs (); 119 | 120 | for (int i = 0; i < BENCHUMARK_RUN_TIMES; i++) { 121 | encode_stream.Position = 0; 122 | pack_stream.Position = 0; 123 | unpack_stream.Position = 0; 124 | 125 | //manager.Codec.Encode ("AddressBook", obj, encode_stream); 126 | //SpPacker.Pack (encode_stream, pack_stream); 127 | //SpPacker.Unpack (pack_stream, unpack_stream); 128 | unpack_stream.Position = 0; 129 | manager.Codec.Decode ("AddressBook", unpack_stream); 130 | } 131 | 132 | double end = GetMs (); 133 | return (end - begin)/1000; 134 | } 135 | 136 | public double UnpackAndDecode () { 137 | double begin = GetMs (); 138 | 139 | for (int i = 0; i < BENCHUMARK_RUN_TIMES; i++) { 140 | encode_stream.Position = 0; 141 | pack_stream.Position = 0; 142 | unpack_stream.Position = 0; 143 | 144 | //manager.Codec.Encode ("AddressBook", obj, encode_stream); 145 | //SpPacker.Pack (encode_stream, pack_stream); 146 | SpPacker.Unpack (pack_stream, unpack_stream); 147 | unpack_stream.Position = 0; 148 | manager.Codec.Decode ("AddressBook", unpack_stream); 149 | } 150 | 151 | double end = GetMs (); 152 | return (end - begin)/1000; 153 | } 154 | 155 | private SpObject CreateObject () { 156 | SpObject obj = new SpObject (); 157 | 158 | SpObject person = new SpObject (); 159 | 160 | { 161 | SpObject p = new SpObject (); 162 | p.Insert ("name", "Alice"); 163 | p.Insert ("id", 10000); 164 | 165 | SpObject phone = new SpObject (); 166 | { 167 | SpObject p1 = new SpObject (); 168 | p1.Insert ("number", "123456789"); 169 | p1.Insert ("type", 1); 170 | phone.Append (p1); 171 | } 172 | { 173 | SpObject p1 = new SpObject (); 174 | p1.Insert ("number", "87654321"); 175 | p1.Insert ("type", 2); 176 | phone.Append (p1); 177 | } 178 | p.Insert ("phone", phone); 179 | 180 | person.Append (p); 181 | } 182 | { 183 | SpObject p = new SpObject (); 184 | p.Insert ("name", "Bob"); 185 | p.Insert ("id", 20000); 186 | 187 | SpObject phone = new SpObject (); 188 | { 189 | SpObject p1 = new SpObject (); 190 | p1.Insert ("number", "01234567890"); 191 | p1.Insert ("type", 3); 192 | phone.Append (p1); 193 | } 194 | p.Insert ("phone", phone); 195 | 196 | person.Append (p); 197 | } 198 | 199 | obj.Insert ("person", person); 200 | 201 | return obj; 202 | } 203 | 204 | private SpTypeManager LoadProto () { 205 | SpTypeManager tm = null; 206 | string path = Util.GetFullPath ("AddressBook.sproto"); 207 | using (FileStream stream = new FileStream (path, FileMode.Open)) { 208 | tm = SpTypeManager.Import (stream); 209 | } 210 | return tm; 211 | } 212 | 213 | double GetMs() { 214 | TimeSpan ts = DateTime.Now - new DateTime(1960, 1, 1); 215 | return ts.TotalMilliseconds; 216 | } 217 | } 218 | -------------------------------------------------------------------------------- /Assets/test/Client.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.IO; 3 | using System.Net; 4 | using System.Net.Sockets; 5 | using System; 6 | 7 | public class Client { 8 | private string c2s = @" 9 | .package { 10 | type 0 : integer 11 | session 1 : integer 12 | } 13 | 14 | handshake 1 { 15 | response { 16 | msg 0 : string 17 | } 18 | } 19 | 20 | get 2 { 21 | request { 22 | what 0 : string 23 | } 24 | response { 25 | result 0 : string 26 | } 27 | } 28 | 29 | set 3 { 30 | request { 31 | what 0 : string 32 | value 1 : string 33 | } 34 | }"; 35 | 36 | private string s2c = @" 37 | .package { 38 | type 0 : integer 39 | session 1 : integer 40 | } 41 | 42 | heartbeat 1 {} 43 | "; 44 | 45 | private Socket mSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 46 | SpStream mSendStream = new SpStream (); 47 | private byte[] mRecvBuffer = new byte[1024]; 48 | private int mRecvOffset = 0; 49 | private int mSession = 0; 50 | private SpRpc mRpc; 51 | 52 | public void Run () { 53 | IPAddress ip = IPAddress.Parse ("127.0.0.1"); 54 | mSocket.Connect(new IPEndPoint(ip, 8888)); 55 | 56 | mRpc = SpRpc.Create (s2c, "package"); 57 | mRpc.Attach (c2s); 58 | 59 | Send ("handshake", null); 60 | Send ("set", new SpObject (SpObject.ArgType.Table, 61 | "what", "hello", 62 | "value", "world")); 63 | 64 | mSocket.BeginReceive (mRecvBuffer, 0, mRecvBuffer.Length, SocketFlags.None, new AsyncCallback(ReadCallback), this); 65 | } 66 | 67 | public void Recv (IAsyncResult ar) { 68 | int ret = mSocket.EndReceive (ar); 69 | 70 | if (ret > 0) { 71 | mRecvOffset += ret; 72 | 73 | int read = 0; 74 | while (mRecvOffset > read) { 75 | int size = (mRecvBuffer[read + 1] | (mRecvBuffer[read + 0] << 8)); 76 | 77 | read += 2; 78 | if (mRecvOffset >= size + read) { 79 | SpStream stream = new SpStream (mRecvBuffer, read, size, size); 80 | SpRpcResult result = mRpc.Dispatch (stream); 81 | switch (result.Op) { 82 | case SpRpcOp.Request: 83 | Util.Log ("Recv Request : " + result.Protocol.Name + ", session : " + result.Session); 84 | if (result.Arg != null) 85 | Util.DumpObject (result.Arg); 86 | break; 87 | case SpRpcOp.Response: 88 | Util.Log ("Recv Response : " + result.Protocol.Name + ", session : " + result.Session); 89 | if (result.Arg != null) 90 | Util.DumpObject (result.Arg); 91 | break; 92 | } 93 | 94 | read += size; 95 | } 96 | } 97 | Util.Assert (mRecvOffset == read); 98 | mRecvOffset = 0; 99 | } 100 | 101 | mSocket.BeginReceive (mRecvBuffer, 0, mRecvBuffer.Length, SocketFlags.None, new System.AsyncCallback(ReadCallback), this); 102 | } 103 | 104 | public static void ReadCallback(IAsyncResult ar) { 105 | Client client = (Client)ar.AsyncState; 106 | client.Recv (ar); 107 | } 108 | 109 | private void Send (string proto, SpObject args) { 110 | mSendStream.Reset (); 111 | mSession++; 112 | 113 | Util.Log ("Send Request : " + proto + ", session : " + mSession); 114 | if (args != null) 115 | Util.DumpObject (args); 116 | 117 | mSendStream.Write ((short)0); 118 | mRpc.Request (proto, args, mSession, mSendStream); 119 | int len = mSendStream.Length - 2; 120 | mSendStream.Buffer[0] = (byte)((len >> 8) & 0xff); 121 | mSendStream.Buffer[1] = (byte)(len & 0xff); 122 | mSocket.Send (mSendStream.Buffer, mSendStream.Length, SocketFlags.None); 123 | } 124 | 125 | public void SendGet (string str) { 126 | Send ("get", new SpObject (SpObject.ArgType.Table, "what", str)); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /Assets/test/Test.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.IO; 3 | 4 | public class Test { 5 | public void Run () { 6 | SpTypeManager manager = LoadProto (); 7 | 8 | SpObject obj = CreateObject (); 9 | CheckObj (obj); 10 | 11 | Util.Log ("Encode"); 12 | SpStream encode_stream = new SpStream (); 13 | manager.Codec.Encode ("AddressBook", obj, encode_stream); 14 | 15 | encode_stream.Position = 0; 16 | Util.DumpStream (encode_stream); 17 | 18 | Util.Log ("Decode"); 19 | encode_stream.Position = 0; 20 | SpObject newObj = manager.Codec.Decode ("AddressBook", encode_stream); 21 | CheckObj (newObj); 22 | 23 | Util.Log ("Pack"); 24 | encode_stream.Position = 0; 25 | SpStream pack_stream = new SpStream (); 26 | SpPacker.Pack (encode_stream, pack_stream); 27 | 28 | pack_stream.Position = 0; 29 | Util.DumpStream (pack_stream); 30 | 31 | Util.Log ("Unpack"); 32 | pack_stream.Position = 0; 33 | SpStream unpack_stream = new SpStream (); 34 | SpPacker.Unpack (pack_stream, unpack_stream); 35 | 36 | unpack_stream.Position = 0; 37 | Util.DumpStream (unpack_stream); 38 | 39 | Util.Log ("Decode"); 40 | unpack_stream.Position = 0; 41 | newObj = manager.Codec.Decode ("AddressBook", unpack_stream); 42 | CheckObj (newObj); 43 | } 44 | 45 | private SpObject CreateObject () { 46 | SpObject obj = new SpObject (); 47 | 48 | SpObject person = new SpObject (); 49 | 50 | { 51 | SpObject p = new SpObject (); 52 | p.Insert ("name", "Alice"); 53 | p.Insert ("id", 10000); 54 | 55 | SpObject phone = new SpObject (); 56 | { 57 | SpObject p1 = new SpObject (); 58 | p1.Insert ("number", "123456789"); 59 | p1.Insert ("type", 1); 60 | phone.Append (p1); 61 | } 62 | { 63 | SpObject p1 = new SpObject (); 64 | p1.Insert ("number", "87654321"); 65 | p1.Insert ("type", 2); 66 | phone.Append (p1); 67 | } 68 | p.Insert ("phone", phone); 69 | 70 | person.Insert (p["id"].AsInt (), p); 71 | } 72 | { 73 | SpObject p = new SpObject (); 74 | p.Insert ("name", "Bob"); 75 | p.Insert ("id", 20000); 76 | 77 | SpObject phone = new SpObject (); 78 | { 79 | SpObject p1 = new SpObject (); 80 | p1.Insert ("number", "01234567890"); 81 | p1.Insert ("type", 3); 82 | phone.Append (p1); 83 | } 84 | p.Insert ("phone", phone); 85 | 86 | person.Insert (p["id"].AsInt (), p); 87 | } 88 | 89 | obj.Insert ("person", person); 90 | 91 | return obj; 92 | } 93 | 94 | private SpTypeManager LoadProto () { 95 | SpTypeManager tm = null; 96 | string path = Util.GetFullPath ("AddressBook.sproto"); 97 | using (FileStream stream = new FileStream (path, FileMode.Open)) { 98 | tm = SpTypeManager.Import (stream); 99 | } 100 | return tm; 101 | } 102 | 103 | private void CheckObj (SpObject obj) { 104 | Util.DumpObject (obj); 105 | Util.Assert (obj["person"][10000]["id"].AsInt () == 10000); 106 | Util.Assert (obj["person"][10000]["name"].AsString ().Equals ("Alice")); 107 | Util.Assert (obj["person"][10000]["phone"][0]["type"].AsInt () == 1); 108 | Util.Assert (obj["person"][10000]["phone"][0]["number"].AsString ().Equals ("123456789")); 109 | Util.Assert (obj["person"][10000]["phone"][1]["type"].AsInt () == 2); 110 | Util.Assert (obj["person"][10000]["phone"][1]["number"].AsString ().Equals ("87654321")); 111 | Util.Assert (obj["person"][20000]["id"].AsInt () == 20000); 112 | Util.Assert (obj["person"][20000]["name"].AsString ().Equals ("Bob")); 113 | Util.Assert (obj["person"][20000]["phone"][0]["type"].AsInt () == 3); 114 | Util.Assert (obj["person"][20000]["phone"][0]["number"].AsString ().Equals ("01234567890")); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Assets/test/TestAll.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | public class TestAll { 8 | public void Run () { 9 | SpTypeManager manager = LoadProto (); 10 | 11 | // different ways to create SpObject 12 | Util.Log ("Object Create Check"); 13 | CheckObj (CreateObject ()); 14 | CheckObj (CreateObject2 ()); 15 | SpObject obj = CreateObject3 (); 16 | CheckObj (obj); 17 | 18 | Util.Log ("Encode"); 19 | SpStream small_stream = new SpStream (32); 20 | bool success = manager.Codec.Encode ("foobar", obj, small_stream); 21 | Util.Assert (success == false); 22 | Util.Log ("encode failed! require size : " + small_stream.Position); 23 | small_stream.Position = 0; 24 | Util.DumpStream (small_stream); 25 | 26 | SpStream encode_stream = manager.Codec.Encode ("foobar", obj); 27 | encode_stream.Position = 0; 28 | Util.DumpStream (encode_stream); 29 | 30 | Util.Log ("Decode "); 31 | encode_stream.Position = 0; 32 | SpObject ooo = manager.Codec.Decode ("foobar", encode_stream); 33 | CheckObj (ooo); 34 | 35 | Util.Log ("Pack"); 36 | encode_stream.Position = 0; 37 | small_stream.Position = 0; 38 | success = SpPacker.Pack (encode_stream, small_stream); 39 | Util.Assert (success == false); 40 | Util.Log ("pack failed! require size : " + small_stream.Position); 41 | small_stream.Position = 0; 42 | Util.DumpStream (small_stream); 43 | 44 | SpStream pack_stream = SpPacker.Pack (encode_stream); 45 | pack_stream.Position = 0; 46 | Util.DumpStream (pack_stream); 47 | 48 | Util.Log ("Unpack"); 49 | pack_stream.Position = 0; 50 | small_stream.Position = 0; 51 | success = SpPacker.Unpack (pack_stream, small_stream); 52 | Util.Assert (success == false); 53 | Util.Log ("unpack failed! require size : " + small_stream.Position); 54 | small_stream.Position = 0; 55 | Util.DumpStream (small_stream); 56 | 57 | pack_stream.Position = 0; 58 | SpStream decode_stream = SpPacker.Unpack (pack_stream); 59 | decode_stream.Position = 0; 60 | Util.DumpStream (decode_stream); 61 | 62 | Util.Log ("Decode "); 63 | decode_stream.Position = 0; 64 | SpObject newObj = manager.Codec.Decode ("foobar", decode_stream); 65 | CheckObj (newObj); 66 | } 67 | 68 | private SpTypeManager LoadProto () { 69 | SpTypeManager tm = null; 70 | string path = Util.GetFullPath ("foobar.sproto"); 71 | using (FileStream stream = new FileStream (path, FileMode.Open)) { 72 | tm = SpTypeManager.Import (stream); 73 | } 74 | return tm; 75 | } 76 | 77 | private SpObject CreateObject () { 78 | SpObject obj = new SpObject (); 79 | 80 | obj.Insert ("a", new SpObject ("hello")); 81 | obj.Insert ("b", new SpObject (1000000)); 82 | obj.Insert ("c", new SpObject (true)); 83 | 84 | SpObject d = new SpObject (); 85 | d.Insert ("a", "world"); 86 | d.Insert ("c", -1); 87 | obj.Insert ("d", d); 88 | 89 | SpObject e = new SpObject (); 90 | e.Append ("ABC"); 91 | e.Append ("def"); 92 | obj.Insert ("e", e); 93 | 94 | SpObject f = new SpObject (); 95 | f.Append (-3); 96 | f.Append (-2); 97 | f.Append (-1); 98 | f.Append (0); 99 | f.Append (1); 100 | f.Append (2); 101 | obj.Insert ("f", f); 102 | 103 | SpObject g = new SpObject (); 104 | g.Append (true); 105 | g.Append (false); 106 | g.Append (true); 107 | obj.Insert ("g", g); 108 | 109 | SpObject h = new SpObject (); 110 | { 111 | SpObject t = new SpObject (); 112 | t.Insert ("b", 100); 113 | h.Append (t); 114 | } 115 | { 116 | SpObject t = new SpObject (); 117 | t.Insert ("b", -100); 118 | t.Insert ("c", false); 119 | h.Append (t); 120 | } 121 | { 122 | SpObject t = new SpObject (); 123 | t.Insert ("b", 0); 124 | 125 | SpObject he = new SpObject (); 126 | he.Append ("test"); 127 | t.Insert ("e", he); 128 | h.Append (t); 129 | } 130 | obj.Insert ("h", h); 131 | 132 | return obj; 133 | } 134 | 135 | private SpObject CreateObject2 () { 136 | SpObject obj = new SpObject (); 137 | 138 | obj.Insert ("a", "hello"); 139 | obj.Insert ("b", 1000000); 140 | obj.Insert ("c", true); 141 | 142 | SpObject d = new SpObject (); 143 | d.Insert ("a", "world"); 144 | d.Insert ("c", -1); 145 | obj.Insert ("d", d); 146 | 147 | obj.Insert ("e", new SpObject (SpObject.ArgType.Array, "ABC", "def")); 148 | obj.Insert ("f", new SpObject (SpObject.ArgType.Array, -3, -2, -1, 0, 1, 2)); 149 | obj.Insert ("g", new SpObject (SpObject.ArgType.Array, true, false, true)); 150 | 151 | SpObject h = new SpObject (); 152 | { 153 | SpObject t = new SpObject (); 154 | t.Insert ("b", 100); 155 | h.Append (t); 156 | } 157 | { 158 | SpObject t = new SpObject (); 159 | t.Insert ("b", -100); 160 | t.Insert ("c", false); 161 | h.Append (t); 162 | } 163 | { 164 | SpObject t = new SpObject (); 165 | t.Insert ("b", 0); 166 | 167 | SpObject he = new SpObject (); 168 | he.Append ("test"); 169 | t.Insert ("e", he); 170 | h.Append (t); 171 | } 172 | obj.Insert ("h", h); 173 | 174 | return obj; 175 | } 176 | 177 | private SpObject CreateObject3 () { 178 | SpObject obj = new SpObject (SpObject.ArgType.Table, 179 | "a", "hello", 180 | "b", 1000000, 181 | "c", true, 182 | "d", new SpObject (SpObject.ArgType.Table, 183 | "a", "world", 184 | "c", -1), 185 | "e", new SpObject (SpObject.ArgType.Array, "ABC", "def"), 186 | "f", new SpObject (SpObject.ArgType.Array, -3, -2, -1, 0, 1, 2), 187 | "g", new SpObject (SpObject.ArgType.Array, true, false, true), 188 | "h", new SpObject (SpObject.ArgType.Array, 189 | new SpObject (SpObject.ArgType.Table, "b", 100), 190 | new SpObject (SpObject.ArgType.Table, "b", -100, "c", false), 191 | new SpObject (SpObject.ArgType.Table, "b", 0, "e", new SpObject (SpObject.ArgType.Array, "test"))) 192 | ); 193 | 194 | return obj; 195 | } 196 | 197 | private void CheckObj (SpObject obj) { 198 | Util.DumpObject (obj); 199 | Util.Assert (obj["a"].AsString ().Equals ("hello")); 200 | Util.Assert (obj["b"].AsInt () == 1000000); 201 | Util.Assert (obj["c"].AsBoolean () == true); 202 | Util.Assert (obj["d"]["a"].AsString ().Equals ("world")); 203 | Util.Assert (obj["d"]["c"].AsInt () == -1); 204 | Util.Assert (obj["e"][0].AsString ().Equals ("ABC")); 205 | Util.Assert (obj["e"][1].AsString ().Equals ("def")); 206 | Util.Assert (obj["f"][0].AsInt () == -3); 207 | Util.Assert (obj["f"][1].AsInt () == -2); 208 | Util.Assert (obj["f"][2].AsInt () == -1); 209 | Util.Assert (obj["f"][3].AsInt () == 0); 210 | Util.Assert (obj["f"][4].AsInt () == 1); 211 | Util.Assert (obj["f"][5].AsInt () == 2); 212 | Util.Assert (obj["g"][0].AsBoolean () == true); 213 | Util.Assert (obj["g"][1].AsBoolean () == false); 214 | Util.Assert (obj["g"][2].AsBoolean () == true); 215 | Util.Assert (obj["h"][0]["b"].AsInt () == 100); 216 | Util.Assert (obj["h"][1]["b"].AsInt () == -100); 217 | Util.Assert (obj["h"][1]["c"].AsBoolean () == false); 218 | Util.Assert (obj["h"][2]["b"].AsInt () == 0); 219 | Util.Assert (obj["h"][2]["e"][0].AsString ().Equals ("test")); 220 | } 221 | } 222 | 223 | -------------------------------------------------------------------------------- /Assets/test/TestRpc.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.IO; 3 | 4 | public class TestRpc { 5 | private const string server_proto = @" 6 | .package { 7 | type 0 : integer 8 | session 1 : integer 9 | } 10 | 11 | foobar 1 { 12 | request { 13 | what 0 : string 14 | } 15 | response { 16 | ok 0 : boolean 17 | } 18 | } 19 | 20 | foo 2 { 21 | response { 22 | ok 0 : boolean 23 | } 24 | } 25 | 26 | bar 3 {} 27 | 28 | blackhole 4 { 29 | request {} 30 | } 31 | "; 32 | 33 | const string client_proto = @" 34 | .package { 35 | type 0 : integer 36 | session 1 : integer 37 | } 38 | "; 39 | 40 | private SpRpc server; 41 | private SpRpc client; 42 | 43 | public void Run () { 44 | SpTypeManager server_tm = SpTypeManager.Import (server_proto); 45 | 46 | server = SpRpc.Create (server_tm, "package"); 47 | 48 | client = SpRpc.Create (client_proto, "package"); 49 | client.Attach (server_tm); 50 | 51 | TestFoobar (); 52 | TestFoo (); 53 | TestBar (); 54 | TestBlackhole (); 55 | } 56 | 57 | private void TestFoobar () { 58 | Util.Log ("client request foobar"); 59 | 60 | SpObject foobar_request = new SpObject (); 61 | foobar_request.Insert ("what", "foo"); 62 | SpStream req = client.Request ("foobar", foobar_request, 1); 63 | 64 | Util.Assert (req.Length == 11); 65 | Util.Log ("request foobar size = " + req.Length); 66 | 67 | req.Position = 0; 68 | SpRpcResult dispatch_result = server.Dispatch (req); 69 | Util.Assert (dispatch_result.Arg["what"].AsString ().Equals ("foo")); 70 | Util.DumpObject (dispatch_result.Arg); 71 | 72 | Util.Log ("server response"); 73 | 74 | SpObject foobar_response = new SpObject (); 75 | foobar_response.Insert ("ok", true); 76 | SpStream resp = server.Response (dispatch_result.Session, foobar_response); 77 | 78 | Util.Assert (resp.Length == 7); 79 | Util.Log ("response package size = " + resp.Length); 80 | 81 | Util.Log ("client dispatch"); 82 | 83 | resp.Position = 0; 84 | dispatch_result = client.Dispatch (resp); 85 | Util.Assert (dispatch_result.Arg["ok"].AsBoolean () == true); 86 | Util.DumpObject (dispatch_result.Arg); 87 | } 88 | 89 | private void TestFoo () { 90 | SpStream req = client.Request ("foo", null, 2); 91 | 92 | Util.Assert (req.Length == 4); 93 | Util.Log ("request foo size = " + req.Length); 94 | 95 | req.Position = 0; 96 | SpRpcResult dispatch_result = server.Dispatch (req); 97 | 98 | SpObject foobar_response = new SpObject (); 99 | foobar_response.Insert ("ok", false); 100 | SpStream resp = server.Response (dispatch_result.Session, foobar_response); 101 | 102 | Util.Assert (resp.Length == 7); 103 | Util.Log ("response package size = " + resp.Length); 104 | 105 | Util.Log ("client dispatch"); 106 | 107 | resp.Position = 0; 108 | dispatch_result = client.Dispatch (resp); 109 | Util.Assert (dispatch_result.Arg["ok"].AsBoolean () == false); 110 | Util.DumpObject (dispatch_result.Arg); 111 | } 112 | 113 | private void TestBar () { 114 | SpStream req = client.Request ("bar"); 115 | 116 | Util.Assert (req.Length == 3); 117 | Util.Log ("request bar size = " + req.Length); 118 | 119 | req.Position = 0; 120 | server.Dispatch (req); 121 | } 122 | 123 | private void TestBlackhole () { 124 | SpStream req = client.Request ("blackhole"); 125 | Util.Assert (req.Length == 3); 126 | Util.Log ("request blackhole size = " + req.Length); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /Assets/test/TestUnit.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.IO; 3 | 4 | public class TestUnit { 5 | 6 | SpTypeManager manager; 7 | 8 | private void TestStr (string s) { 9 | SpObject obj = new SpObject (SpObject.ArgType.Table, "a", s); 10 | 11 | Util.Log ("------------------TestStr----------------------------"); 12 | Util.Log (s); 13 | 14 | Util.Log ("Encode"); 15 | SpStream encode_stream = new SpStream (2); 16 | bool ret = manager.Codec.Encode ("ss", obj, encode_stream); 17 | Util.Assert (ret == false); 18 | encode_stream = new SpStream (encode_stream.Position); 19 | ret = manager.Codec.Encode ("ss", obj, encode_stream); 20 | Util.Assert (ret == true); 21 | encode_stream.Position = 0; 22 | Util.DumpStream (encode_stream); 23 | 24 | Util.Log ("Pack"); 25 | encode_stream.Position = 0; 26 | SpStream pack_stream = new SpStream (); 27 | SpPacker.Pack (encode_stream, pack_stream); 28 | pack_stream.Position = 0; 29 | Util.DumpStream (pack_stream); 30 | 31 | Util.Log ("Unpack"); 32 | pack_stream.Position = 0; 33 | SpStream unpack_stream = new SpStream (); 34 | SpPacker.Unpack (pack_stream, unpack_stream); 35 | unpack_stream.Position = 0; 36 | Util.DumpStream (unpack_stream); 37 | 38 | Util.Log ("Decode"); 39 | unpack_stream.Position = 0; 40 | SpObject dobj = manager.Codec.Decode ("ss", unpack_stream); 41 | string ds = dobj["a"].AsString (); 42 | Util.Log (ds); 43 | Util.Assert (s == ds); 44 | } 45 | 46 | private void TestNest () { 47 | SpObject clist = new SpObject (SpObject.ArgType.Table, 48 | "character", 49 | new SpObject (SpObject.ArgType.Array, 50 | new SpObject (SpObject.ArgType.Table, 51 | "id", 52 | 1, 53 | "attribute", 54 | new SpObject (SpObject.ArgType.Table, 55 | "level", 56 | 1, 57 | "templateId", 58 | 1001, 59 | "ability", 60 | new SpObject (SpObject.ArgType.Table, 61 | "hp", 2530, 62 | "att", 2310 63 | ) 64 | ) 65 | ), 66 | new SpObject (SpObject.ArgType.Table, 67 | "id", 68 | 2, 69 | "attribute", 70 | new SpObject (SpObject.ArgType.Table, 71 | "level", 72 | 1, 73 | "templateId", 74 | 1002, 75 | "ability", 76 | new SpObject (SpObject.ArgType.Table, 77 | "hp", 1320, 78 | "att", 2090 79 | ) 80 | ) 81 | ) 82 | ) 83 | ); 84 | 85 | Util.Log ("------------------TEST CHARACTER----------------------------"); 86 | Util.DumpObject (clist); 87 | 88 | Util.Log ("Encode"); 89 | SpStream encode_stream = new SpStream (); 90 | manager.Codec.Encode ("clist", clist, encode_stream); 91 | encode_stream.Position = 0; 92 | Util.DumpStream (encode_stream); 93 | 94 | Util.Log ("Pack"); 95 | encode_stream.Position = 0; 96 | SpStream pack_stream = new SpStream (); 97 | SpPacker.Pack (encode_stream, pack_stream); 98 | pack_stream.Position = 0; 99 | Util.DumpStream (pack_stream); 100 | 101 | Util.Log ("Unpack"); 102 | pack_stream.Position = 0; 103 | SpStream unpack_stream = new SpStream (); 104 | SpPacker.Unpack (pack_stream, unpack_stream); 105 | unpack_stream.Position = 0; 106 | Util.DumpStream (unpack_stream); 107 | 108 | Util.Log ("Decode"); 109 | unpack_stream.Position = 0; 110 | SpObject dobj = manager.Codec.Decode ("clist", unpack_stream); 111 | Util.DumpObject (dobj); 112 | } 113 | 114 | public void Run () { 115 | 116 | string proto = @" 117 | .ss { 118 | a 0 : string 119 | } 120 | 121 | .ability { 122 | hp 0 : integer 123 | att 1 : integer 124 | } 125 | 126 | .attribute { 127 | templateId 0 : integer 128 | level 1 : integer 129 | ability 2 : ability 130 | } 131 | 132 | .character { 133 | id 0 : integer 134 | attribute 1 : attribute 135 | } 136 | 137 | .clist { 138 | character 0 : *character(id) 139 | } 140 | 141 | "; 142 | manager = SpTypeManager.Import (proto); 143 | 144 | 145 | 146 | TestStr ("12345678");/* 147 | TestNest (); 148 | 149 | TestStr (""); 150 | TestStr ("123"); 151 | TestStr ("123456"); 152 | TestStr ("12345678"); 153 | TestStr ("12345678123"); 154 | TestStr ("12345678123456"); 155 | TestStr ("1234567812345678"); 156 | TestStr ("12345678123456781234567812345678"); 157 | TestStr ("123456781234567812345678123456781"); 158 | TestStr ("123456781234567812345678123456781234567"); */ 159 | } 160 | 161 | private void CheckObj (SpObject obj) { 162 | Util.DumpObject (obj); 163 | Util.Assert (obj["person"][10000]["id"].AsInt () == 10000); 164 | Util.Assert (obj["person"][10000]["name"].AsString ().Equals ("Alice")); 165 | Util.Assert (obj["person"][10000]["phone"][0]["type"].AsInt () == 1); 166 | Util.Assert (obj["person"][10000]["phone"][0]["number"].AsString ().Equals ("123456789")); 167 | Util.Assert (obj["person"][10000]["phone"][1]["type"].AsInt () == 2); 168 | Util.Assert (obj["person"][10000]["phone"][1]["number"].AsString ().Equals ("87654321")); 169 | Util.Assert (obj["person"][20000]["id"].AsInt () == 20000); 170 | Util.Assert (obj["person"][20000]["name"].AsString ().Equals ("Bob")); 171 | Util.Assert (obj["person"][20000]["phone"][0]["type"].AsInt () == 3); 172 | Util.Assert (obj["person"][20000]["phone"][0]["number"].AsString ().Equals ("01234567890")); 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /Assets/test/Util.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using System; 4 | using UnityEngine; 5 | 6 | public class Util { 7 | public static void DumpStream (SpStream stream) { 8 | string str = ""; 9 | 10 | byte[] buf = new byte[16]; 11 | int count; 12 | 13 | while ((count = stream.Read (buf, 0, buf.Length)) > 0) { 14 | str += DumpLine (buf, count); 15 | } 16 | 17 | Log (str); 18 | } 19 | 20 | private static string DumpLine (byte[] buf, int count) { 21 | string str = ""; 22 | 23 | for (int i = 0; i < count; i++) { 24 | str += ((i < count) ? String.Format ("{0:X2}", buf[i]) : " "); 25 | str += ((i > 0) && (i < count - 1) && ((i + 1) % 8 == 0) ? " " : " "); 26 | } 27 | str += "\n"; 28 | 29 | return str; 30 | } 31 | 32 | public static void DumpObject (SpObject obj) { 33 | Log (DumpObject (obj, 0)); 34 | } 35 | 36 | private static string DumpObject (SpObject obj, int tab) { 37 | string str = ""; 38 | 39 | if (obj != null) { 40 | if (obj.IsTable ()) { 41 | str = GetTab (tab) + "\n"; 42 | foreach (KeyValuePair entry in obj.AsTable ()) { 43 | str += GetTab (tab + 1) + "\n"; 44 | str += DumpObject (entry.Value, tab + 1); 45 | } 46 | } 47 | else if (obj.Value == null) { 48 | str = GetTab (tab) + "\n"; 49 | } 50 | else { 51 | str = GetTab (tab) + obj.Value.ToString () + "\n"; 52 | } 53 | } 54 | 55 | return str; 56 | } 57 | 58 | private static string GetTab(int n) { 59 | string str = ""; 60 | for (int i = 0; i < n; i++) 61 | str += "\t"; 62 | return str; 63 | } 64 | 65 | public static void Log (object obj) { 66 | Debug.Log (obj); 67 | } 68 | 69 | public static void Assert(bool condition) { 70 | if (condition == false) 71 | throw new Exception(); 72 | } 73 | 74 | public static string GetFullPath (string path) { 75 | return Application.dataPath + "/" + path; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | m_SpeedOfSound: 347 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_DSPBufferSize: 0 12 | m_DisableAudio: 0 13 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | m_Gravity: {x: 0, y: -9.81000042, z: 0} 7 | m_DefaultMaterial: {fileID: 0} 8 | m_BounceThreshold: 2 9 | m_SleepVelocity: .150000006 10 | m_SleepAngularVelocity: .140000001 11 | m_MaxAngularVelocity: 7 12 | m_MinPenetrationForPenalty: .00999999978 13 | m_SolverIterationCount: 6 14 | m_RaycastsHitTriggers: 1 15 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 16 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_WebSecurityEmulationEnabled: 0 10 | m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d 11 | m_DefaultBehaviorMode: 1 12 | m_SpritePackerMode: 0 13 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_LegacyDeferred: 11 | m_Mode: 1 12 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 13 | m_AlwaysIncludedShaders: 14 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 15 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 16 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 17 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 18 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 19 | - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} 20 | m_PreloadedShaders: [] 21 | m_LightmapStripping: 0 22 | m_LightmapKeepPlain: 1 23 | m_LightmapKeepDirCombined: 1 24 | m_LightmapKeepDirSeparate: 1 25 | m_LightmapKeepDynamic: 1 26 | m_FogStripping: 0 27 | m_FogKeepLinear: 1 28 | m_FogKeepExp: 1 29 | m_FogKeepExp2: 1 30 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | m_Axes: 7 | - serializedVersion: 3 8 | m_Name: Horizontal 9 | descriptiveName: 10 | descriptiveNegativeName: 11 | negativeButton: left 12 | positiveButton: right 13 | altNegativeButton: a 14 | altPositiveButton: d 15 | gravity: 3 16 | dead: .00100000005 17 | sensitivity: 3 18 | snap: 1 19 | invert: 0 20 | type: 0 21 | axis: 0 22 | joyNum: 0 23 | - serializedVersion: 3 24 | m_Name: Vertical 25 | descriptiveName: 26 | descriptiveNegativeName: 27 | negativeButton: down 28 | positiveButton: up 29 | altNegativeButton: s 30 | altPositiveButton: w 31 | gravity: 3 32 | dead: .00100000005 33 | sensitivity: 3 34 | snap: 1 35 | invert: 0 36 | type: 0 37 | axis: 0 38 | joyNum: 0 39 | - serializedVersion: 3 40 | m_Name: Fire1 41 | descriptiveName: 42 | descriptiveNegativeName: 43 | negativeButton: 44 | positiveButton: left ctrl 45 | altNegativeButton: 46 | altPositiveButton: mouse 0 47 | gravity: 1000 48 | dead: .00100000005 49 | sensitivity: 1000 50 | snap: 0 51 | invert: 0 52 | type: 0 53 | axis: 0 54 | joyNum: 0 55 | - serializedVersion: 3 56 | m_Name: Fire2 57 | descriptiveName: 58 | descriptiveNegativeName: 59 | negativeButton: 60 | positiveButton: left alt 61 | altNegativeButton: 62 | altPositiveButton: mouse 1 63 | gravity: 1000 64 | dead: .00100000005 65 | sensitivity: 1000 66 | snap: 0 67 | invert: 0 68 | type: 0 69 | axis: 0 70 | joyNum: 0 71 | - serializedVersion: 3 72 | m_Name: Fire3 73 | descriptiveName: 74 | descriptiveNegativeName: 75 | negativeButton: 76 | positiveButton: left cmd 77 | altNegativeButton: 78 | altPositiveButton: mouse 2 79 | gravity: 1000 80 | dead: .00100000005 81 | sensitivity: 1000 82 | snap: 0 83 | invert: 0 84 | type: 0 85 | axis: 0 86 | joyNum: 0 87 | - serializedVersion: 3 88 | m_Name: Jump 89 | descriptiveName: 90 | descriptiveNegativeName: 91 | negativeButton: 92 | positiveButton: space 93 | altNegativeButton: 94 | altPositiveButton: 95 | gravity: 1000 96 | dead: .00100000005 97 | sensitivity: 1000 98 | snap: 0 99 | invert: 0 100 | type: 0 101 | axis: 0 102 | joyNum: 0 103 | - serializedVersion: 3 104 | m_Name: Mouse X 105 | descriptiveName: 106 | descriptiveNegativeName: 107 | negativeButton: 108 | positiveButton: 109 | altNegativeButton: 110 | altPositiveButton: 111 | gravity: 0 112 | dead: 0 113 | sensitivity: .100000001 114 | snap: 0 115 | invert: 0 116 | type: 1 117 | axis: 0 118 | joyNum: 0 119 | - serializedVersion: 3 120 | m_Name: Mouse Y 121 | descriptiveName: 122 | descriptiveNegativeName: 123 | negativeButton: 124 | positiveButton: 125 | altNegativeButton: 126 | altPositiveButton: 127 | gravity: 0 128 | dead: 0 129 | sensitivity: .100000001 130 | snap: 0 131 | invert: 0 132 | type: 1 133 | axis: 1 134 | joyNum: 0 135 | - serializedVersion: 3 136 | m_Name: Mouse ScrollWheel 137 | descriptiveName: 138 | descriptiveNegativeName: 139 | negativeButton: 140 | positiveButton: 141 | altNegativeButton: 142 | altPositiveButton: 143 | gravity: 0 144 | dead: 0 145 | sensitivity: .100000001 146 | snap: 0 147 | invert: 0 148 | type: 1 149 | axis: 2 150 | joyNum: 0 151 | - serializedVersion: 3 152 | m_Name: Horizontal 153 | descriptiveName: 154 | descriptiveNegativeName: 155 | negativeButton: 156 | positiveButton: 157 | altNegativeButton: 158 | altPositiveButton: 159 | gravity: 0 160 | dead: .189999998 161 | sensitivity: 1 162 | snap: 0 163 | invert: 0 164 | type: 2 165 | axis: 0 166 | joyNum: 0 167 | - serializedVersion: 3 168 | m_Name: Vertical 169 | descriptiveName: 170 | descriptiveNegativeName: 171 | negativeButton: 172 | positiveButton: 173 | altNegativeButton: 174 | altPositiveButton: 175 | gravity: 0 176 | dead: .189999998 177 | sensitivity: 1 178 | snap: 0 179 | invert: 1 180 | type: 2 181 | axis: 1 182 | joyNum: 0 183 | - serializedVersion: 3 184 | m_Name: Fire1 185 | descriptiveName: 186 | descriptiveNegativeName: 187 | negativeButton: 188 | positiveButton: joystick button 0 189 | altNegativeButton: 190 | altPositiveButton: 191 | gravity: 1000 192 | dead: .00100000005 193 | sensitivity: 1000 194 | snap: 0 195 | invert: 0 196 | type: 0 197 | axis: 0 198 | joyNum: 0 199 | - serializedVersion: 3 200 | m_Name: Fire2 201 | descriptiveName: 202 | descriptiveNegativeName: 203 | negativeButton: 204 | positiveButton: joystick button 1 205 | altNegativeButton: 206 | altPositiveButton: 207 | gravity: 1000 208 | dead: .00100000005 209 | sensitivity: 1000 210 | snap: 0 211 | invert: 0 212 | type: 0 213 | axis: 0 214 | joyNum: 0 215 | - serializedVersion: 3 216 | m_Name: Fire3 217 | descriptiveName: 218 | descriptiveNegativeName: 219 | negativeButton: 220 | positiveButton: joystick button 2 221 | altNegativeButton: 222 | altPositiveButton: 223 | gravity: 1000 224 | dead: .00100000005 225 | sensitivity: 1000 226 | snap: 0 227 | invert: 0 228 | type: 0 229 | axis: 0 230 | joyNum: 0 231 | - serializedVersion: 3 232 | m_Name: Jump 233 | descriptiveName: 234 | descriptiveNegativeName: 235 | negativeButton: 236 | positiveButton: joystick button 3 237 | altNegativeButton: 238 | altPositiveButton: 239 | gravity: 1000 240 | dead: .00100000005 241 | sensitivity: 1000 242 | snap: 0 243 | invert: 0 244 | type: 0 245 | axis: 0 246 | joyNum: 0 247 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshLayers: 5 | m_ObjectHideFlags: 0 6 | Built-in Layer 0: 7 | name: Default 8 | cost: 1 9 | editType: 2 10 | Built-in Layer 1: 11 | name: Not Walkable 12 | cost: 1 13 | editType: 0 14 | Built-in Layer 2: 15 | name: Jump 16 | cost: 2 17 | editType: 2 18 | User Layer 0: 19 | name: 20 | cost: 1 21 | editType: 3 22 | User Layer 1: 23 | name: 24 | cost: 1 25 | editType: 3 26 | User Layer 2: 27 | name: 28 | cost: 1 29 | editType: 3 30 | User Layer 3: 31 | name: 32 | cost: 1 33 | editType: 3 34 | User Layer 4: 35 | name: 36 | cost: 1 37 | editType: 3 38 | User Layer 5: 39 | name: 40 | cost: 1 41 | editType: 3 42 | User Layer 6: 43 | name: 44 | cost: 1 45 | editType: 3 46 | User Layer 7: 47 | name: 48 | cost: 1 49 | editType: 3 50 | User Layer 8: 51 | name: 52 | cost: 1 53 | editType: 3 54 | User Layer 9: 55 | name: 56 | cost: 1 57 | editType: 3 58 | User Layer 10: 59 | name: 60 | cost: 1 61 | editType: 3 62 | User Layer 11: 63 | name: 64 | cost: 1 65 | editType: 3 66 | User Layer 12: 67 | name: 68 | cost: 1 69 | editType: 3 70 | User Layer 13: 71 | name: 72 | cost: 1 73 | editType: 3 74 | User Layer 14: 75 | name: 76 | cost: 1 77 | editType: 3 78 | User Layer 15: 79 | name: 80 | cost: 1 81 | editType: 3 82 | User Layer 16: 83 | name: 84 | cost: 1 85 | editType: 3 86 | User Layer 17: 87 | name: 88 | cost: 1 89 | editType: 3 90 | User Layer 18: 91 | name: 92 | cost: 1 93 | editType: 3 94 | User Layer 19: 95 | name: 96 | cost: 1 97 | editType: 3 98 | User Layer 20: 99 | name: 100 | cost: 1 101 | editType: 3 102 | User Layer 21: 103 | name: 104 | cost: 1 105 | editType: 3 106 | User Layer 22: 107 | name: 108 | cost: 1 109 | editType: 3 110 | User Layer 23: 111 | name: 112 | cost: 1 113 | editType: 3 114 | User Layer 24: 115 | name: 116 | cost: 1 117 | editType: 3 118 | User Layer 25: 119 | name: 120 | cost: 1 121 | editType: 3 122 | User Layer 26: 123 | name: 124 | cost: 1 125 | editType: 3 126 | User Layer 27: 127 | name: 128 | cost: 1 129 | editType: 3 130 | User Layer 28: 131 | name: 132 | cost: 1 133 | editType: 3 134 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshLayers: 5 | m_ObjectHideFlags: 0 6 | Built-in Layer 0: 7 | name: Default 8 | cost: 1 9 | editType: 2 10 | Built-in Layer 1: 11 | name: Not Walkable 12 | cost: 1 13 | editType: 0 14 | Built-in Layer 2: 15 | name: Jump 16 | cost: 2 17 | editType: 2 18 | User Layer 0: 19 | name: 20 | cost: 1 21 | editType: 3 22 | User Layer 1: 23 | name: 24 | cost: 1 25 | editType: 3 26 | User Layer 2: 27 | name: 28 | cost: 1 29 | editType: 3 30 | User Layer 3: 31 | name: 32 | cost: 1 33 | editType: 3 34 | User Layer 4: 35 | name: 36 | cost: 1 37 | editType: 3 38 | User Layer 5: 39 | name: 40 | cost: 1 41 | editType: 3 42 | User Layer 6: 43 | name: 44 | cost: 1 45 | editType: 3 46 | User Layer 7: 47 | name: 48 | cost: 1 49 | editType: 3 50 | User Layer 8: 51 | name: 52 | cost: 1 53 | editType: 3 54 | User Layer 9: 55 | name: 56 | cost: 1 57 | editType: 3 58 | User Layer 10: 59 | name: 60 | cost: 1 61 | editType: 3 62 | User Layer 11: 63 | name: 64 | cost: 1 65 | editType: 3 66 | User Layer 12: 67 | name: 68 | cost: 1 69 | editType: 3 70 | User Layer 13: 71 | name: 72 | cost: 1 73 | editType: 3 74 | User Layer 14: 75 | name: 76 | cost: 1 77 | editType: 3 78 | User Layer 15: 79 | name: 80 | cost: 1 81 | editType: 3 82 | User Layer 16: 83 | name: 84 | cost: 1 85 | editType: 3 86 | User Layer 17: 87 | name: 88 | cost: 1 89 | editType: 3 90 | User Layer 18: 91 | name: 92 | cost: 1 93 | editType: 3 94 | User Layer 19: 95 | name: 96 | cost: 1 97 | editType: 3 98 | User Layer 20: 99 | name: 100 | cost: 1 101 | editType: 3 102 | User Layer 21: 103 | name: 104 | cost: 1 105 | editType: 3 106 | User Layer 22: 107 | name: 108 | cost: 1 109 | editType: 3 110 | User Layer 23: 111 | name: 112 | cost: 1 113 | editType: 3 114 | User Layer 24: 115 | name: 116 | cost: 1 117 | editType: 3 118 | User Layer 25: 119 | name: 120 | cost: 1 121 | editType: 3 122 | User Layer 26: 123 | name: 124 | cost: 1 125 | editType: 3 126 | User Layer 27: 127 | name: 128 | cost: 1 129 | editType: 3 130 | User Layer 28: 131 | name: 132 | cost: 1 133 | editType: 3 134 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | m_Gravity: {x: 0, y: -9.81000042} 7 | m_DefaultMaterial: {fileID: 0} 8 | m_VelocityIterations: 8 9 | m_PositionIterations: 3 10 | m_VelocityThreshold: 1 11 | m_MaxLinearCorrection: .200000003 12 | m_MaxAngularCorrection: 8 13 | m_MaxTranslationSpeed: 100 14 | m_MaxRotationSpeed: 360 15 | m_BaumgarteScale: .200000003 16 | m_BaumgarteTimeOfImpactScale: .75 17 | m_TimeToSleep: .5 18 | m_LinearSleepTolerance: .00999999978 19 | m_AngularSleepTolerance: 2 20 | m_RaycastsHitTriggers: 1 21 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 22 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!129 &1 4 | PlayerSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 6 7 | AndroidProfiler: 0 8 | defaultScreenOrientation: 4 9 | targetDevice: 2 10 | targetGlesGraphics: 1 11 | targetIOSGraphics: -1 12 | targetResolution: 0 13 | accelerometerFrequency: 60 14 | companyName: DefaultCompany 15 | productName: sproto-u3d 16 | cloudProjectId: 17 | defaultCursor: {fileID: 0} 18 | cursorHotspot: {x: 0, y: 0} 19 | m_ShowUnitySplashScreen: 1 20 | defaultScreenWidth: 1024 21 | defaultScreenHeight: 768 22 | defaultScreenWidthWeb: 960 23 | defaultScreenHeightWeb: 600 24 | m_RenderingPath: 1 25 | m_MobileRenderingPath: 1 26 | m_ActiveColorSpace: 0 27 | m_MTRendering: 1 28 | m_MobileMTRendering: 0 29 | m_UseDX11: 1 30 | m_Stereoscopic3D: 0 31 | iosShowActivityIndicatorOnLoading: -1 32 | androidShowActivityIndicatorOnLoading: -1 33 | iosAppInBackgroundBehavior: 0 34 | displayResolutionDialog: 1 35 | allowedAutorotateToPortrait: 1 36 | allowedAutorotateToPortraitUpsideDown: 1 37 | allowedAutorotateToLandscapeRight: 1 38 | allowedAutorotateToLandscapeLeft: 1 39 | useOSAutorotation: 1 40 | use32BitDisplayBuffer: 1 41 | disableDepthAndStencilBuffers: 0 42 | defaultIsFullScreen: 1 43 | defaultIsNativeResolution: 1 44 | runInBackground: 0 45 | captureSingleScreen: 0 46 | Override IPod Music: 0 47 | Prepare IOS For Recording: 0 48 | submitAnalytics: 1 49 | usePlayerLog: 1 50 | bakeCollisionMeshes: 0 51 | forceSingleInstance: 0 52 | resizableWindow: 0 53 | useMacAppStoreValidation: 0 54 | gpuSkinning: 0 55 | xboxPIXTextureCapture: 0 56 | xboxEnableAvatar: 0 57 | xboxEnableKinect: 0 58 | xboxEnableKinectAutoTracking: 0 59 | xboxEnableFitness: 0 60 | visibleInBackground: 0 61 | macFullscreenMode: 2 62 | d3d9FullscreenMode: 1 63 | d3d11FullscreenMode: 1 64 | xboxSpeechDB: 0 65 | xboxEnableHeadOrientation: 0 66 | xboxEnableGuest: 0 67 | xboxOneResolution: 0 68 | ps3SplashScreen: {fileID: 0} 69 | videoMemoryForVertexBuffers: 0 70 | psp2PowerMode: 0 71 | psp2AcquireBGM: 1 72 | m_SupportedAspectRatios: 73 | 4:3: 1 74 | 5:4: 1 75 | 16:10: 1 76 | 16:9: 1 77 | Others: 1 78 | bundleIdentifier: com.Company.ProductName 79 | bundleVersion: 1.0 80 | preloadedAssets: [] 81 | metroEnableIndependentInputSource: 0 82 | metroEnableLowLatencyPresentationAPI: 0 83 | xboxOneDisableKinectGpuReservation: 0 84 | productGUID: 65c23f9df46eb4ec6970f107da231f53 85 | AndroidBundleVersionCode: 1 86 | AndroidMinSdkVersion: 9 87 | AndroidPreferredInstallLocation: 1 88 | aotOptions: 89 | apiCompatibilityLevel: 2 90 | iPhoneStrippingLevel: 0 91 | iPhoneScriptCallOptimization: 0 92 | ForceInternetPermission: 0 93 | ForceSDCardPermission: 0 94 | CreateWallpaper: 0 95 | APKExpansionFiles: 0 96 | preloadShaders: 0 97 | StripUnusedMeshComponents: 0 98 | iPhoneSdkVersion: 988 99 | iPhoneTargetOSVersion: 22 100 | uIPrerenderedIcon: 0 101 | uIRequiresPersistentWiFi: 0 102 | uIStatusBarHidden: 1 103 | uIExitOnSuspend: 0 104 | uIStatusBarStyle: 0 105 | iPhoneSplashScreen: {fileID: 0} 106 | iPhoneHighResSplashScreen: {fileID: 0} 107 | iPhoneTallHighResSplashScreen: {fileID: 0} 108 | iPhone47inSplashScreen: {fileID: 0} 109 | iPhone55inPortraitSplashScreen: {fileID: 0} 110 | iPhone55inLandscapeSplashScreen: {fileID: 0} 111 | iPadPortraitSplashScreen: {fileID: 0} 112 | iPadHighResPortraitSplashScreen: {fileID: 0} 113 | iPadLandscapeSplashScreen: {fileID: 0} 114 | iPadHighResLandscapeSplashScreen: {fileID: 0} 115 | iOSLaunchScreenType: 0 116 | iOSLaunchScreenPortrait: {fileID: 0} 117 | iOSLaunchScreenLandscape: {fileID: 0} 118 | iOSLaunchScreenBackgroundColor: 119 | serializedVersion: 2 120 | rgba: 0 121 | iOSLaunchScreenFillPct: 100 122 | iOSLaunchScreenSize: 100 123 | iOSLaunchScreenCustomXibPath: 124 | AndroidTargetDevice: 0 125 | AndroidSplashScreenScale: 0 126 | AndroidKeystoreName: 127 | AndroidKeyaliasName: 128 | AndroidTVCompatibility: 1 129 | AndroidIsGame: 1 130 | androidEnableBanner: 1 131 | m_AndroidBanners: 132 | - width: 320 133 | height: 180 134 | banner: {fileID: 0} 135 | androidGamepadSupportLevel: 0 136 | resolutionDialogBanner: {fileID: 0} 137 | m_BuildTargetIcons: [] 138 | m_BuildTargetBatching: [] 139 | webPlayerTemplate: APPLICATION:Default 140 | m_TemplateCustomTags: {} 141 | actionOnDotNetUnhandledException: 1 142 | enableInternalProfiler: 0 143 | logObjCUncaughtExceptions: 1 144 | enableCrashReportAPI: 0 145 | locationUsageDescription: 146 | XboxTitleId: 147 | XboxImageXexPath: 148 | XboxSpaPath: 149 | XboxGenerateSpa: 0 150 | XboxDeployKinectResources: 0 151 | XboxSplashScreen: {fileID: 0} 152 | xboxEnableSpeech: 0 153 | xboxAdditionalTitleMemorySize: 0 154 | xboxDeployKinectHeadOrientation: 0 155 | xboxDeployKinectHeadPosition: 0 156 | ps3TitleConfigPath: 157 | ps3DLCConfigPath: 158 | ps3ThumbnailPath: 159 | ps3BackgroundPath: 160 | ps3SoundPath: 161 | ps3NPAgeRating: 12 162 | ps3TrophyCommId: 163 | ps3NpCommunicationPassphrase: 164 | ps3TrophyPackagePath: 165 | ps3BootCheckMaxSaveGameSizeKB: 128 166 | ps3TrophyCommSig: 167 | ps3SaveGameSlots: 1 168 | ps3TrialMode: 0 169 | ps3VideoMemoryForAudio: 0 170 | ps3EnableVerboseMemoryStats: 0 171 | ps3UseSPUForUmbra: 0 172 | ps3EnableMoveSupport: 1 173 | ps3DisableDolbyEncoding: 0 174 | ps4NPAgeRating: 12 175 | ps4NPTitleSecret: 176 | ps4NPTrophyPackPath: 177 | ps4ParentalLevel: 1 178 | ps4ContentID: ED1633-NPXX51362_00-0000000000000000 179 | ps4Category: 0 180 | ps4MasterVersion: 01.00 181 | ps4AppVersion: 01.00 182 | ps4AppType: 0 183 | ps4ParamSfxPath: 184 | ps4VideoOutPixelFormat: 0 185 | ps4VideoOutResolution: 4 186 | ps4PronunciationXMLPath: 187 | ps4PronunciationSIGPath: 188 | ps4BackgroundImagePath: 189 | ps4StartupImagePath: 190 | ps4SaveDataImagePath: 191 | ps4BGMPath: 192 | ps4ShareFilePath: 193 | ps4NPtitleDatPath: 194 | ps4RemotePlayKeyAssignment: -1 195 | ps4EnterButtonAssignment: 1 196 | ps4ApplicationParam1: 0 197 | ps4ApplicationParam2: 0 198 | ps4ApplicationParam3: 0 199 | ps4ApplicationParam4: 0 200 | ps4Passcode: CVp7yTMhuNYSNABBSgfJNG0WWUaG33Pb 201 | ps4pnSessions: 1 202 | ps4pnPresence: 1 203 | ps4pnFriends: 1 204 | ps4pnGameCustomData: 1 205 | playerPrefsSupport: 0 206 | monoEnv: 207 | psp2Splashimage: {fileID: 0} 208 | psp2NPTrophyPackPath: 209 | psp2NPSupportGBMorGJP: 0 210 | psp2NPAgeRating: 12 211 | psp2NPCommsID: 212 | psp2NPCommunicationsID: 213 | psp2NPCommsPassphrase: 214 | psp2NPCommsSig: 215 | psp2ParamSfxPath: 216 | psp2ManualPath: 217 | psp2LiveAreaGatePath: 218 | psp2LiveAreaBackroundPath: 219 | psp2LiveAreaPath: 220 | psp2LiveAreaTrialPath: 221 | psp2PatchChangeInfoPath: 222 | psp2PatchOriginalPackage: 223 | psp2PackagePassword: 224 | psp2KeystoneFile: 225 | psp2DRMType: 0 226 | psp2StorageType: 0 227 | psp2MediaCapacity: 0 228 | psp2DLCConfigPath: 229 | psp2ThumbnailPath: 230 | psp2BackgroundPath: 231 | psp2SoundPath: 232 | psp2TrophyCommId: 233 | psp2TrophyPackagePath: 234 | psp2PackagedResourcesPath: 235 | psp2SaveDataQuota: 10240 236 | psp2ParentalLevel: 1 237 | psp2ShortTitle: Not Set 238 | psp2ContentID: IV0000-ABCD12345_00-0123456789ABCDEF 239 | psp2Category: 0 240 | psp2MasterVersion: 01.00 241 | psp2AppVersion: 01.00 242 | psp2TVBootMode: 0 243 | psp2EnterButtonAssignment: 2 244 | psp2TVDisableEmu: 0 245 | psp2AllowTwitterDialog: 1 246 | psp2Upgradable: 0 247 | psp2HealthWarning: 0 248 | psp2UseLibLocation: 0 249 | psp2InfoBarOnStartup: 0 250 | psp2InfoBarColor: 0 251 | psmSplashimage: {fileID: 0} 252 | spritePackerPolicy: 253 | scriptingDefineSymbols: {} 254 | metroPackageName: sproto-u3d 255 | metroPackageLogo: 256 | metroPackageLogo140: 257 | metroPackageLogo180: 258 | metroPackageLogo240: 259 | metroPackageVersion: 260 | metroCertificatePath: 261 | metroCertificatePassword: 262 | metroCertificateSubject: 263 | metroCertificateIssuer: 264 | metroCertificateNotAfter: 0000000000000000 265 | metroApplicationDescription: sproto-u3d 266 | metroStoreTileLogo80: 267 | metroStoreTileLogo: 268 | metroStoreTileLogo140: 269 | metroStoreTileLogo180: 270 | metroStoreTileWideLogo80: 271 | metroStoreTileWideLogo: 272 | metroStoreTileWideLogo140: 273 | metroStoreTileWideLogo180: 274 | metroStoreTileSmallLogo80: 275 | metroStoreTileSmallLogo: 276 | metroStoreTileSmallLogo140: 277 | metroStoreTileSmallLogo180: 278 | metroStoreSmallTile80: 279 | metroStoreSmallTile: 280 | metroStoreSmallTile140: 281 | metroStoreSmallTile180: 282 | metroStoreLargeTile80: 283 | metroStoreLargeTile: 284 | metroStoreLargeTile140: 285 | metroStoreLargeTile180: 286 | metroStoreSplashScreenImage: 287 | metroStoreSplashScreenImage140: 288 | metroStoreSplashScreenImage180: 289 | metroPhoneAppIcon: 290 | metroPhoneAppIcon140: 291 | metroPhoneAppIcon240: 292 | metroPhoneSmallTile: 293 | metroPhoneSmallTile140: 294 | metroPhoneSmallTile240: 295 | metroPhoneMediumTile: 296 | metroPhoneMediumTile140: 297 | metroPhoneMediumTile240: 298 | metroPhoneWideTile: 299 | metroPhoneWideTile140: 300 | metroPhoneWideTile240: 301 | metroPhoneSplashScreenImage: 302 | metroPhoneSplashScreenImage140: 303 | metroPhoneSplashScreenImage240: 304 | metroTileShortName: 305 | metroCommandLineArgsFile: 306 | metroTileShowName: 0 307 | metroMediumTileShowName: 0 308 | metroLargeTileShowName: 0 309 | metroWideTileShowName: 0 310 | metroDefaultTileSize: 1 311 | metroTileForegroundText: 1 312 | metroTileBackgroundColor: {r: 0, g: 0, b: 0, a: 1} 313 | metroSplashScreenBackgroundColor: {r: 0, g: 0, b: 0, a: 1} 314 | metroSplashScreenUseBackgroundColor: 0 315 | platformCapabilities: {} 316 | metroFTAName: 317 | metroFTAFileTypes: [] 318 | metroProtocolName: 319 | metroCompilationOverrides: 1 320 | blackberryDeviceAddress: 321 | blackberryDevicePassword: 322 | blackberryTokenPath: 323 | blackberryTokenExires: 324 | blackberryTokenAuthor: 325 | blackberryTokenAuthorId: 326 | blackberryCskPassword: 327 | blackberrySaveLogPath: 328 | blackberrySharedPermissions: 0 329 | blackberryCameraPermissions: 0 330 | blackberryGPSPermissions: 0 331 | blackberryDeviceIDPermissions: 0 332 | blackberryMicrophonePermissions: 0 333 | blackberryGamepadSupport: 0 334 | blackberryBuildId: 0 335 | blackberryLandscapeSplashScreen: {fileID: 0} 336 | blackberryPortraitSplashScreen: {fileID: 0} 337 | blackberrySquareSplashScreen: {fileID: 0} 338 | tizenProductDescription: 339 | tizenProductURL: 340 | tizenCertificatePath: 341 | tizenCertificatePassword: 342 | tizenGPSPermissions: 0 343 | tizenMicrophonePermissions: 0 344 | stvDeviceAddress: 345 | stvProductDescription: 346 | stvProductAuthor: 347 | stvProductAuthorEmail: 348 | stvProductLink: 349 | stvProductCategory: 0 350 | XboxOneProductId: 351 | XboxOneUpdateKey: 352 | XboxOneSandboxId: 353 | XboxOneContentId: 354 | XboxOneTitleId: 355 | XboxOneSCId: 356 | XboxOneGameOsOverridePath: 357 | XboxOnePackagingOverridePath: 358 | XboxOneAppManifestOverridePath: 359 | XboxOnePackageEncryption: 0 360 | XboxOneDescription: 361 | XboxOneIsContentPackage: 0 362 | XboxOneEnableGPUVariability: 0 363 | XboxOneSockets: {} 364 | XboxOneSplashScreen: {fileID: 0} 365 | XboxOneAllowedProductIds: [] 366 | XboxOnePersistentLocalStorageSize: 0 367 | intPropertyNames: 368 | - WebGL::ScriptingBackend 369 | - WebGL::audioCompressionFormat 370 | - WebGL::exceptionSupport 371 | - WebGL::memorySize 372 | - iOS::Architecture 373 | - iOS::ScriptingBackend 374 | WebGL::ScriptingBackend: 1 375 | WebGL::audioCompressionFormat: 4 376 | WebGL::exceptionSupport: 0 377 | WebGL::memorySize: 256 378 | iOS::Architecture: 2 379 | iOS::ScriptingBackend: 0 380 | boolPropertyNames: 381 | - WebGL::dataCaching 382 | WebGL::dataCaching: 0 383 | stringPropertyNames: 384 | - WebGL::emscriptenArgs 385 | - WebGL::template 386 | WebGL::emscriptenArgs: 387 | WebGL::template: APPLICATION:Default 388 | firstStreamedLevelWithResources: 0 389 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 3 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Fastest 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | blendWeights: 1 18 | textureQuality: 1 19 | anisotropicTextures: 0 20 | antiAliasing: 0 21 | softParticles: 0 22 | softVegetation: 0 23 | vSyncCount: 0 24 | lodBias: .300000012 25 | maximumLODLevel: 0 26 | particleRaycastBudget: 4 27 | excludedTargetPlatforms: [] 28 | - serializedVersion: 2 29 | name: Fast 30 | pixelLightCount: 0 31 | shadows: 0 32 | shadowResolution: 0 33 | shadowProjection: 1 34 | shadowCascades: 1 35 | shadowDistance: 20 36 | blendWeights: 2 37 | textureQuality: 0 38 | anisotropicTextures: 0 39 | antiAliasing: 0 40 | softParticles: 0 41 | softVegetation: 0 42 | vSyncCount: 0 43 | lodBias: .400000006 44 | maximumLODLevel: 0 45 | particleRaycastBudget: 16 46 | excludedTargetPlatforms: [] 47 | - serializedVersion: 2 48 | name: Simple 49 | pixelLightCount: 1 50 | shadows: 1 51 | shadowResolution: 0 52 | shadowProjection: 1 53 | shadowCascades: 1 54 | shadowDistance: 20 55 | blendWeights: 2 56 | textureQuality: 0 57 | anisotropicTextures: 1 58 | antiAliasing: 0 59 | softParticles: 0 60 | softVegetation: 0 61 | vSyncCount: 0 62 | lodBias: .699999988 63 | maximumLODLevel: 0 64 | particleRaycastBudget: 64 65 | excludedTargetPlatforms: [] 66 | - serializedVersion: 2 67 | name: Good 68 | pixelLightCount: 2 69 | shadows: 2 70 | shadowResolution: 1 71 | shadowProjection: 1 72 | shadowCascades: 2 73 | shadowDistance: 40 74 | blendWeights: 2 75 | textureQuality: 0 76 | anisotropicTextures: 1 77 | antiAliasing: 0 78 | softParticles: 0 79 | softVegetation: 1 80 | vSyncCount: 1 81 | lodBias: 1 82 | maximumLODLevel: 0 83 | particleRaycastBudget: 256 84 | excludedTargetPlatforms: [] 85 | - serializedVersion: 2 86 | name: Beautiful 87 | pixelLightCount: 3 88 | shadows: 2 89 | shadowResolution: 2 90 | shadowProjection: 1 91 | shadowCascades: 2 92 | shadowDistance: 70 93 | blendWeights: 4 94 | textureQuality: 0 95 | anisotropicTextures: 2 96 | antiAliasing: 2 97 | softParticles: 1 98 | softVegetation: 1 99 | vSyncCount: 1 100 | lodBias: 1.5 101 | maximumLODLevel: 0 102 | particleRaycastBudget: 1024 103 | excludedTargetPlatforms: [] 104 | - serializedVersion: 2 105 | name: Fantastic 106 | pixelLightCount: 4 107 | shadows: 2 108 | shadowResolution: 2 109 | shadowProjection: 1 110 | shadowCascades: 4 111 | shadowDistance: 150 112 | blendWeights: 4 113 | textureQuality: 0 114 | anisotropicTextures: 2 115 | antiAliasing: 2 116 | softParticles: 1 117 | softVegetation: 1 118 | vSyncCount: 1 119 | lodBias: 2 120 | maximumLODLevel: 0 121 | particleRaycastBudget: 4096 122 | excludedTargetPlatforms: [] 123 | m_PerPlatformDefaultQuality: 124 | Android: 2 125 | BlackBerry: 2 126 | FlashPlayer: 3 127 | GLES Emulation: 3 128 | PS3: 3 129 | PS4: 3 130 | PSM: 3 131 | PSP2: 3 132 | Samsung TV: 2 133 | Standalone: 3 134 | Tizen: 2 135 | WP8: 3 136 | Web: 3 137 | Windows Store Apps: 3 138 | XBOX360: 3 139 | XboxOne: 3 140 | iPhone: 2 141 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | tags: 6 | - 7 | Builtin Layer 0: Default 8 | Builtin Layer 1: TransparentFX 9 | Builtin Layer 2: Ignore Raycast 10 | Builtin Layer 3: 11 | Builtin Layer 4: Water 12 | Builtin Layer 5: UI 13 | Builtin Layer 6: 14 | Builtin Layer 7: 15 | User Layer 8: 16 | User Layer 9: 17 | User Layer 10: 18 | User Layer 11: 19 | User Layer 12: 20 | User Layer 13: 21 | User Layer 14: 22 | User Layer 15: 23 | User Layer 16: 24 | User Layer 17: 25 | User Layer 18: 26 | User Layer 19: 27 | User Layer 20: 28 | User Layer 21: 29 | User Layer 22: 30 | User Layer 23: 31 | User Layer 24: 32 | User Layer 25: 33 | User Layer 26: 34 | User Layer 27: 35 | User Layer 28: 36 | User Layer 29: 37 | User Layer 30: 38 | User Layer 31: 39 | m_SortingLayers: 40 | - name: Default 41 | userID: 0 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: .0199999996 7 | Maximum Allowed Timestep: .333333343 8 | m_TimeScale: 1 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | sproto-u3d 2 | ========== 3 | 4 | example showing how to use [sproto-cs](https://github.com/jintiao/sproto-cs) in unity3d 5 | -------------------------------------------------------------------------------- /benchmark: -------------------------------------------------------------------------------- 1 | cpu : 2.66GHz Intel Core i7 2 | mem : 8 GB 1067 MHz DDR3 3 | platform : OS X 10.9.5 4 | ide : Unity 4.5.2 5 | 6 | Encode: 20.4341501464844 s 7 | Pack: 4.5742958984375 s 8 | EncodeAndPack: 26.1116420898437 s 9 | Unpack: 4.53784399414062 s 10 | Decode: 32.3203901367188 s 11 | UnpackAndDecode: 37.2077700195313 s 12 | --------------------------------------------------------------------------------