com.puzzlescapegames.services 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release-package.yml +22 -0
- package/Editor/DefineSymbolsInstaller.cs +79 -0
- package/Editor/DefineSymbolsInstaller.cs.meta +11 -0
- package/Editor/DefineSymbolsInstallerEditor.cs +21 -0
- package/Editor/DefineSymbolsInstallerEditor.cs.meta +3 -0
- package/Editor/PuzzlescapeGames.Services.Editor.asmdef +17 -0
- package/Editor/PuzzlescapeGames.Services.Editor.asmdef.meta +7 -0
- package/Editor/SymbolsDefinition.cs +99 -0
- package/Editor/SymbolsDefinition.cs.meta +11 -0
- package/Editor.meta +8 -0
- package/README.md +6 -0
- package/README.md.meta +7 -0
- package/Runtime.meta +8 -0
- package/package.json +11 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: Puzzlescape Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish-gpr:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
packages: write
|
|
13
|
+
contents: read
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v3
|
|
16
|
+
- uses: actions/setup-node@v3
|
|
17
|
+
with:
|
|
18
|
+
node-version: '16.x'
|
|
19
|
+
- run: npm install
|
|
20
|
+
- run: npm publish
|
|
21
|
+
env:
|
|
22
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
using PuzzlescapeGames.Extensions;
|
|
2
|
+
using System;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
using UnityEditor;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace PuzzlescapeGames.Services.Editor
|
|
8
|
+
{
|
|
9
|
+
[ CreateAssetMenu( fileName = "DefineSymbolsInstaller", menuName = "Installers/DefineSymbolsInstaller" ) ]
|
|
10
|
+
public sealed class DefineSymbolsInstaller : ScriptableObject
|
|
11
|
+
{
|
|
12
|
+
[ SerializeField ] private Defines _defines;
|
|
13
|
+
|
|
14
|
+
public void UpdateDefineSymbols()
|
|
15
|
+
{
|
|
16
|
+
var allDefines = Enum.GetValues(typeof(Defines))
|
|
17
|
+
.Cast<Defines>()
|
|
18
|
+
.Where(flag => flag != Defines.NONE && flag != Defines.ALL)
|
|
19
|
+
.Select( flag => flag.ToString() )
|
|
20
|
+
.ToArray();
|
|
21
|
+
|
|
22
|
+
var selectedDefines = Enum.GetValues(typeof(Defines))
|
|
23
|
+
.Cast<Defines>()
|
|
24
|
+
.Where(flag => _defines.HasFlag(flag) && flag != Defines.NONE && flag != Defines.ALL)
|
|
25
|
+
.Select( flag => flag.ToString() )
|
|
26
|
+
.ToArray();
|
|
27
|
+
|
|
28
|
+
var unselectedDefines = allDefines.Except(selectedDefines).ToArray();
|
|
29
|
+
|
|
30
|
+
SymbolsDefinition.EnsureScriptingDefineSymbols( selectedDefines );
|
|
31
|
+
for ( int i = 0; i < unselectedDefines.Length; i++ )
|
|
32
|
+
{
|
|
33
|
+
if ( SymbolsDefinition.ContainsDefineSymbol( unselectedDefines[ i ] ) )
|
|
34
|
+
{
|
|
35
|
+
SymbolsDefinition.RemoveDefineSymbols( unselectedDefines[ i ] );
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
[ InitializeOnLoadMethod ]
|
|
41
|
+
private static void OnLoad()
|
|
42
|
+
{
|
|
43
|
+
DefineSymbolsInstaller installer = AssetDatabaseUtils.LoadAsset< DefineSymbolsInstaller >();
|
|
44
|
+
if ( installer != null )
|
|
45
|
+
{
|
|
46
|
+
Debug.Log( "[DefineSymbolsInstaller] Updating Define Symbols." );
|
|
47
|
+
installer.UpdateDefineSymbols();
|
|
48
|
+
}
|
|
49
|
+
else
|
|
50
|
+
{
|
|
51
|
+
Debug.LogError( "[DefineSymbolsInstaller] Asset DefineSymbolsInstaller not found." );
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
[ MenuItem("Tools/Update Define Symbols") ]
|
|
56
|
+
private static void ENABLED_APPSFLYER()
|
|
57
|
+
{
|
|
58
|
+
DefineSymbolsInstaller installer = AssetDatabaseUtils.LoadAsset< DefineSymbolsInstaller >();
|
|
59
|
+
if ( installer != null )
|
|
60
|
+
{
|
|
61
|
+
Debug.Log( "[DefineSymbolsInstaller] Updating Define Symbols." );
|
|
62
|
+
installer.UpdateDefineSymbols();
|
|
63
|
+
}
|
|
64
|
+
else
|
|
65
|
+
{
|
|
66
|
+
Debug.LogError( "[DefineSymbolsInstaller] Asset DefineSymbolsInstaller not found." );
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
[ System.Flags ]
|
|
72
|
+
public enum Defines
|
|
73
|
+
{
|
|
74
|
+
NONE = 0,
|
|
75
|
+
ENABLED_APPSFLYER,
|
|
76
|
+
UNITASK_DOTWEEN_SUPPORT,
|
|
77
|
+
ALL = ~0,
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
using UnityEditor;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace PuzzlescapeGames.Services.Editor
|
|
5
|
+
{
|
|
6
|
+
[CustomEditor(typeof(DefineSymbolsInstaller))]
|
|
7
|
+
public sealed class DefineSymbolsInstallerEditor : UnityEditor.Editor
|
|
8
|
+
{
|
|
9
|
+
public override void OnInspectorGUI()
|
|
10
|
+
{
|
|
11
|
+
DrawDefaultInspector();
|
|
12
|
+
|
|
13
|
+
DefineSymbolsInstaller installer = (DefineSymbolsInstaller)target;
|
|
14
|
+
|
|
15
|
+
if (GUILayout.Button("Update Define Symbols"))
|
|
16
|
+
{
|
|
17
|
+
installer.UpdateDefineSymbols();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "PuzzlescapeGames.Services.Editor",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [
|
|
5
|
+
"GUID:1de137006ee9ba0498bfecb3f78298e2",
|
|
6
|
+
"GUID:0d8beb7f090555447a6cf5ce9e54dbb4"
|
|
7
|
+
],
|
|
8
|
+
"includePlatforms": [],
|
|
9
|
+
"excludePlatforms": [],
|
|
10
|
+
"allowUnsafeCode": false,
|
|
11
|
+
"overrideReferences": false,
|
|
12
|
+
"precompiledReferences": [],
|
|
13
|
+
"autoReferenced": true,
|
|
14
|
+
"defineConstraints": [],
|
|
15
|
+
"versionDefines": [],
|
|
16
|
+
"noEngineReferences": false
|
|
17
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Linq;
|
|
3
|
+
using UnityEditor;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace PuzzlescapeGames.Services.Editor
|
|
7
|
+
{
|
|
8
|
+
public static class SymbolsDefinition
|
|
9
|
+
{
|
|
10
|
+
public static void EnsureScriptingDefineSymbols( params string[] defineSymbols )
|
|
11
|
+
{
|
|
12
|
+
Debug.Log( "[Defines] Try Define" );
|
|
13
|
+
|
|
14
|
+
var currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup;
|
|
15
|
+
|
|
16
|
+
if ( currentTarget == BuildTargetGroup.Unknown )
|
|
17
|
+
{
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup( currentTarget ).Trim();
|
|
22
|
+
var defines = definesString.Split( ';' );
|
|
23
|
+
|
|
24
|
+
bool changed = false;
|
|
25
|
+
|
|
26
|
+
foreach ( var define in defineSymbols )
|
|
27
|
+
{
|
|
28
|
+
if ( defines.Contains( define ) == false )
|
|
29
|
+
{
|
|
30
|
+
if ( definesString.EndsWith( ";", StringComparison.InvariantCulture ) == false )
|
|
31
|
+
{
|
|
32
|
+
definesString += ";";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
definesString += define;
|
|
36
|
+
changed = true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if ( changed )
|
|
41
|
+
{
|
|
42
|
+
Debug.Log( $"[Defines] Refreshed on {currentTarget} with {definesString}" );
|
|
43
|
+
PlayerSettings.SetScriptingDefineSymbolsForGroup( currentTarget, definesString );
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public static void RemoveDefineSymbols( params string[] defineSymbols )
|
|
48
|
+
{
|
|
49
|
+
var currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup;
|
|
50
|
+
|
|
51
|
+
if ( currentTarget == BuildTargetGroup.Unknown )
|
|
52
|
+
{
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup( currentTarget );
|
|
57
|
+
|
|
58
|
+
bool changed = false;
|
|
59
|
+
|
|
60
|
+
foreach ( var define in defineSymbols )
|
|
61
|
+
{
|
|
62
|
+
int index = definesString.IndexOf( define, StringComparison.Ordinal );
|
|
63
|
+
if ( index < 0 )
|
|
64
|
+
continue; //this target does not contain the define
|
|
65
|
+
if ( index > 0 )
|
|
66
|
+
index -= 1; //include the semicolon before the define
|
|
67
|
+
|
|
68
|
+
//else we will remove the semicolon after the define
|
|
69
|
+
|
|
70
|
+
//Remove the word and it's semicolon, or just the word (if listed last in defines)
|
|
71
|
+
int lengthToRemove = Math.Min( define.Length + 1, definesString.Length - index );
|
|
72
|
+
|
|
73
|
+
definesString = definesString.Remove( index, lengthToRemove );
|
|
74
|
+
changed = true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if ( changed )
|
|
78
|
+
{
|
|
79
|
+
Debug.Log( $"[Defines] Refreshed on {currentTarget} with {definesString}" );
|
|
80
|
+
PlayerSettings.SetScriptingDefineSymbolsForGroup( currentTarget, definesString );
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public static bool ContainsDefineSymbol( string define )
|
|
85
|
+
{
|
|
86
|
+
var currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup;
|
|
87
|
+
|
|
88
|
+
if ( currentTarget == BuildTargetGroup.Unknown )
|
|
89
|
+
{
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
var definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup( currentTarget ).Trim();
|
|
94
|
+
var defines = definesString.Split( ';' );
|
|
95
|
+
|
|
96
|
+
return defines.Contains( define );
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
package/Editor.meta
ADDED
package/README.md
ADDED
package/README.md.meta
ADDED
package/Runtime.meta
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name" : "com.puzzlescapegames.services",
|
|
3
|
+
"displayName" : "Puzzlescape Games Services",
|
|
4
|
+
"version" : "1.0.0",
|
|
5
|
+
"author" : "Puzzlescape Games",
|
|
6
|
+
"description" : "Common services.",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Puzzlescape/com.puzzlescapegames.services"
|
|
10
|
+
}
|
|
11
|
+
}
|