-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43c4d89
commit f2e7b15
Showing
7 changed files
with
120 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
UnityProject/Assets/Dependencies/JEngine/Editor/JEngineTools/JEngineProjData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace JEngine.Editor | ||
{ | ||
public class JEngineProjData | ||
{ | ||
public string Prefix = ""; | ||
public string EncryptPassword = ""; | ||
public string Version = "0.8.0f6"; | ||
|
||
public int Size() | ||
{ | ||
return (Prefix.AsSpan().Length + EncryptPassword.AsSpan().Length + Version.AsSpan().Length) * 2 + 3; | ||
} | ||
|
||
public void AsBinary(ref Span<byte> data) | ||
{ | ||
if (data.Length < Size()) | ||
throw new Exception("data.Length < Size()"); | ||
|
||
var prefix = MemoryMarshal.Cast<char, byte>(Prefix.AsSpan()); | ||
var encryptPassword = MemoryMarshal.Cast<char, byte>(EncryptPassword.AsSpan()); | ||
var version = MemoryMarshal.Cast<char, byte>(Version.AsSpan()); | ||
|
||
data[0] = (byte)prefix.Length; | ||
prefix.CopyTo(data.Slice(1)); | ||
data[prefix.Length + 1] = (byte)encryptPassword.Length; | ||
encryptPassword.CopyTo(data.Slice(prefix.Length + 2)); | ||
data[prefix.Length + encryptPassword.Length + 2] = (byte)version.Length; | ||
version.CopyTo(data.Slice(prefix.Length + encryptPassword.Length + 3)); | ||
} | ||
|
||
public void FromBinary(ref Span<byte> data) | ||
{ | ||
var prefixLength = data[0]; | ||
Prefix = MemoryMarshal.Cast<byte, char>(data.Slice(1, prefixLength)).ToString(); | ||
var encryptPasswordLength = data[prefixLength + 1]; | ||
EncryptPassword = MemoryMarshal.Cast<byte, char>(data.Slice(prefixLength + 2, encryptPasswordLength)) | ||
.ToString(); | ||
var versionLength = data[prefixLength + encryptPasswordLength + 2]; | ||
Version = MemoryMarshal | ||
.Cast<byte, char>(data.Slice(prefixLength + encryptPasswordLength + 3, versionLength)).ToString(); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
UnityProject/Assets/Dependencies/JEngine/Editor/JEngineTools/JEngineProjData.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters