mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-09 08:38:43 +08:00
[unity] Improved binary vs json file detection upon skeleton import checks, should fix a reported (potentially asian locale related) issue. Closes #1867.
This commit is contained in:
parent
1057889c21
commit
1d2df65008
@ -167,11 +167,14 @@ namespace Spine.Unity {
|
||||
}
|
||||
|
||||
public static bool IsJsonFile (TextAsset file) {
|
||||
string fileText = file.text;
|
||||
byte[] content = file.bytes;
|
||||
const int maxCharsToCheck = 256;
|
||||
int numCharsToCheck = Math.Min(fileText.Length, maxCharsToCheck);
|
||||
for (int i = 0; i < numCharsToCheck; ++i) {
|
||||
char c = fileText[i];
|
||||
int numCharsToCheck = Math.Min(content.Length, maxCharsToCheck);
|
||||
int i = 0;
|
||||
if (content.Length >= 3 && content[0] == 0xEF && content[1] == 0xBB && content[2] == 0xBF) // skip potential BOM
|
||||
i = 3;
|
||||
for (; i < numCharsToCheck; ++i) {
|
||||
char c = (char)content[i];
|
||||
if (char.IsWhiteSpace(c))
|
||||
continue;
|
||||
return c == '{';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user