-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: - Switching between an asynchronous model `.Net` / `UniTask` - Complete Coroutine base operations for addressables management - Complete UniTask base operations for addressables management
- Loading branch information
Showing
12 changed files
with
348 additions
and
96 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System.Collections.Generic; | ||
using UnityEditor; | ||
|
||
namespace AddressablesMasterDevelopment.Editor | ||
{ | ||
internal static class UseUniTaskAsyncModel | ||
{ | ||
private const string uniTaskSymbol = "USE_UNITASK"; | ||
|
||
|
||
[MenuItem("Tools/Addressables Master/UniTask/On")] | ||
internal static void IncludeToSymbols() | ||
{ | ||
if (DefineActivity()) | ||
{ | ||
EditorUtility.DisplayDialog("UniTask is supported", | ||
"UniTask is already used", "OK"); | ||
} | ||
else | ||
{ | ||
if (EditorUtility.DisplayDialog("Use UniTask Async Model?", | ||
"If UniTask support is enabled then all asynchronous code will use the UniTask async operations", "Yes", "No")) | ||
{ | ||
DefineSymbols(true); | ||
} | ||
} | ||
} | ||
[MenuItem("Tools/Addressables Master/UniTask/Off")] | ||
internal static void ExcludeFromSymbols() | ||
{ | ||
if (!DefineActivity()) | ||
{ | ||
EditorUtility.DisplayDialog("UniTask support is already turned off", | ||
"The .NET default async model is used", "OK"); | ||
} | ||
else | ||
{ | ||
if (EditorUtility.DisplayDialog("Disable UniTask support?", | ||
"This action will cause the use of the standard .NET async model", "Yes", "No")) | ||
{ | ||
DefineSymbols(false); | ||
} | ||
} | ||
} | ||
|
||
private static bool DefineActivity() | ||
{ | ||
BuildTargetGroup currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup; | ||
|
||
List<string> scriptingSymbols = | ||
new List<string>(PlayerSettings.GetScriptingDefineSymbolsForGroup(currentTarget).Split(';')); | ||
|
||
return scriptingSymbols.Contains(uniTaskSymbol); | ||
} | ||
|
||
private static void DefineSymbols(bool state) | ||
{ | ||
BuildTargetGroup currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup; | ||
|
||
List<string> scriptingSymbols = | ||
new List<string>(PlayerSettings.GetScriptingDefineSymbolsForGroup(currentTarget).Split(';')); | ||
|
||
if (state) | ||
{ | ||
if (!scriptingSymbols.Contains(uniTaskSymbol)) scriptingSymbols.Add(uniTaskSymbol); | ||
else return; | ||
} | ||
else | ||
{ | ||
if (scriptingSymbols.Contains(uniTaskSymbol)) scriptingSymbols.Remove(uniTaskSymbol); | ||
else return; | ||
} | ||
|
||
string finalScriptingSymbols = string.Join(";", scriptingSymbols.ToArray()); | ||
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, finalScriptingSymbols); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "inc8877.AddressablesMaster.Editor", | ||
"rootNamespace": "", | ||
"references": [], | ||
"includePlatforms": [ | ||
"Editor" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
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
Oops, something went wrong.