-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put native configuration in a new settings file Catch UnauthorizedAccessException on windows when deleting files as on Windows you cannot delete a file thats in use, and Unity cannot unload native files
- Loading branch information
1 parent
f05c9be
commit 0408846
Showing
8 changed files
with
137 additions
and
99 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 was deleted.
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
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,48 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
using Newtonsoft.Json; | ||
using UnityEditor; | ||
|
||
namespace NugetForUnity | ||
{ | ||
public class Settings | ||
{ | ||
/// <summary> | ||
/// Gets or sets the mapping from NuGet runtimes folder naming convention to Unity BuildTargets | ||
/// </summary> | ||
public Dictionary<string, List<BuildTarget>> NativeRuntimesMappings { get; set; } | ||
|
||
public void Save(string filepath) | ||
{ | ||
var contents = JsonConvert.SerializeObject(this, new Newtonsoft.Json.Converters.StringEnumConverter()); | ||
File.WriteAllText(filepath, contents, new UTF8Encoding()); | ||
} | ||
|
||
public static Settings Load(string filepath) | ||
{ | ||
var contents = File.ReadAllText(filepath, new UTF8Encoding()); | ||
return JsonConvert.DeserializeObject<Settings>(contents, new Newtonsoft.Json.Converters.StringEnumConverter()); | ||
} | ||
|
||
public static Settings CreateDefault(string filepath) | ||
{ | ||
var settings = new Settings(); | ||
|
||
var nativeRuntimes = new Dictionary<string, List<BuildTarget>> | ||
{ | ||
{ "win7-x64", new List<BuildTarget>() { BuildTarget.StandaloneWindows64 } }, | ||
{ "win7-x86", new List<BuildTarget>() { BuildTarget.StandaloneWindows } }, | ||
{ "win-x64", new List<BuildTarget>() { BuildTarget.StandaloneWindows64 } }, | ||
{ "win-x86", new List<BuildTarget>() { BuildTarget.StandaloneWindows } }, | ||
{ "linux-x64", new List<BuildTarget>() { BuildTarget.StandaloneLinux64 } }, | ||
{ "osc-x64", new List<BuildTarget>() { BuildTarget.StandaloneOSX } } | ||
}; | ||
|
||
settings.NativeRuntimesMappings = nativeRuntimes; | ||
settings.Save(filepath); | ||
|
||
return settings; | ||
} | ||
} | ||
} |
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