Skip to content

Commit

Permalink
Merge branch 'release/v0.9.0' into 'main'
Browse files Browse the repository at this point in the history
chore: Merge release v0.9.0 into main

See merge request elympics/unity-sdk-package!220
  • Loading branch information
Dawid Sygocki committed Aug 30, 2023
2 parents 29e1e6e + 891b5af commit 51efbc0
Show file tree
Hide file tree
Showing 194 changed files with 5,645 additions and 599 deletions.
3 changes: 2 additions & 1 deletion .conventional-changelog-context.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"repoUrl": "https://github.com/Elympics/Unity-SDK",
"host": "https://github.com",
"owner": "Elympics",
"repository": "Unity-SDK"
"repository": "Unity-SDK",
"isPatch": true
}
7 changes: 2 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
root = false


[*]
indent_style = space
charset = utf-8
Expand All @@ -13,7 +10,7 @@ indent_size = 2
[*.sh]
end_of_line = lf

[*.asmdef,*.js,*.jslib]
[{*.asmdef,*.js,*.jslib}]
indent_size = 4

[*.cs]
Expand Down Expand Up @@ -254,7 +251,7 @@ dotnet_naming_rule.non_private_fields_rule.severity = warning

## ReSharper
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_accessibilities = *
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds =
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds =
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_applicable_kinds = unity_serialised_field
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_required_modifiers = instance

Expand Down
4 changes: 2 additions & 2 deletions .scripts/ci/bump_version_and_generate_changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ fi

echo "Running changelog generation..."

node ./.scripts/ci/update_version.js ../../package.json ../../Runtime/AssemblyInfo.cs "$BRANCH_VERSION"
node ./.scripts/ci/update_version.js ../../package.json ../../Editor/AssemblyInfo.cs "$BRANCH_VERSION"
node ./.scripts/ci/update_version.js "$BRANCH_VERSION" ../../package.json \
../../Runtime/AssemblyInfo.cs ../../Editor/AssemblyInfo.cs ../../Tests/Runtime/AssemblyInfo.cs

echo "Version updated"
echo "Generating changelog..."
Expand Down
49 changes: 26 additions & 23 deletions .scripts/ci/update_version.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
const fs = require('fs')
const path = require('path')
const fs = require('fs');
const path = require('path');

function usage() {
console.log("Usage: node bump_package.js ./path/to/package.json ./path/to/Runtime/AssemblyInfo.cs [version]")
console.log("[version] must be in format X.Y.Z")
console.log("Usage: node bump_package.js ./path/to/package.json ./path/to/Runtime/AssemblyInfo.cs [version]");
console.log("[version] must be in format X.Y.Z");
}

function isCorrectVersion(string) {
return /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(string)
return /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(string);
}

async function main() {
args = process.argv.slice(2);
if (args.length != 3 || !isCorrectVersion(args[2])) {
version = args[0];
packagePath = args[1];
assemblyPaths = args.slice(2);

if (args.length < 3 || !isCorrectVersion(version)) {
usage();
process.exit(1);
}

packagePath = args[0]
assemblyPath = args[1]
version = args[2]

let packageFileName = path.resolve(__dirname, packagePath)
let packageJson = JSON.parse(fs.readFileSync(packageFileName))
packageJson.version = version
fs.writeFileSync(packageFileName, JSON.stringify(packageJson, null, 2))
console.log(`Updated package version to ${version}`)
const packageFileName = path.resolve(__dirname, packagePath);
const packageJson = JSON.parse(fs.readFileSync(packageFileName));
packageJson.version = version;
fs.writeFileSync(packageFileName, JSON.stringify(packageJson, null, 2));
console.log(`Updated package version to ${version}`);

let assemblyFileName = path.resolve(__dirname, assemblyPath)
let assemblyFile = fs.readFileSync(assemblyFileName).toString();
assemblyFile = assemblyFile.replace(/(AssemblyVersion\(\").*(\.[0-9]+\"\))/, `$1${version}$2`)
fs.writeFileSync(assemblyFileName, assemblyFile)
console.log(`Updated Assembly version to ${version}`)
assemblyPaths.forEach(assemblyPath => {
const assemblyFileName = path.resolve(__dirname, assemblyPath);
const assemblyFile = fs.readFileSync(assemblyFileName)
.toString()
.replace(/(AssemblyVersion\(\").*(\.[0-9]+\"\))/, `$1${version}$2`);
fs.writeFileSync(assemblyFileName, assemblyFile);
console.log(`Updated ${assemblyFileName} Assembly version to ${version}`);
});
}

main().catch((error) => {
console.error(error)
process.exitCode = 1
})
console.error(error);
process.exitCode = 1;
});
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## [0.9.0](https://github.com/Elympics/Unity-SDK/compare/v0.8.1...v0.9.0) (2023-08-28)


### Bug Fixes 🪲

* Reduce throttle warnings frequency ([779838e](https://github.com/Elympics/Unity-SDK/commit/779838ef7704e09fc6e3e4ad01bdf0cfcb31eb36))
* Prevent NRE when accessing current ElympicsGameConfig at startup ([c40cdb3](https://github.com/Elympics/Unity-SDK/commit/c40cdb3e67b48d6f91f4427a0dc598a0aba02923))


### Features

* Add ElympicsLobby to "Add GameObject" context menu ([624214b](https://github.com/Elympics/Unity-SDK/commit/624214b01031bc85fc75a20471165119d4f31fb0))
* Introduce RPC ([bcc9129](https://github.com/Elympics/Unity-SDK/commit/bcc9129621dc2e3dfa670210fd7dcbe2120787f6))



## [0.8.1](https://github.com/Elympics/Unity-SDK/compare/v0.8.0...v0.8.1) (2023-07-14)


Expand Down
20 changes: 2 additions & 18 deletions Editor/Communication/UsageStatistics/UsageStatisticsSender.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using System;
using System.Globalization;
using Plugins.Elympics.Plugins.ParrelSync;
using UnityEditor;
using UnityEngine;

namespace Elympics.Editor.Communication.UsageStatistics
{
[InitializeOnLoad]
internal static class UsageStatisticsSender
{
private const string SessionStartKey = "Elympics/SessionStart";
private static readonly TimeSpan ComparisonEpsilon = TimeSpan.FromMinutes(1);

static UsageStatisticsSender()
{
Expand All @@ -22,22 +18,10 @@ static UsageStatisticsSender()

private static void OnAssemblyReload()
{
var currentSessionStart = DateTime.UtcNow - TimeSpan.FromSeconds(EditorApplication.timeSinceStartup);
if (!HasBeenRestarted(currentSessionStart))
if (SessionState.GetBool(SessionStartKey, false))
return;
ElympicsWebIntegration.PostStartEvent();
PlayerPrefs.SetString(SessionStartKey, currentSessionStart.ToString("o", CultureInfo.InvariantCulture));
}

private static bool HasBeenRestarted(DateTime currentSessionStart)
{
var serializedSessionStart = PlayerPrefs.GetString(SessionStartKey) ?? "";
if (!DateTime.TryParse(serializedSessionStart, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind,
out var savedSessionStart))
return true;
if (savedSessionStart - currentSessionStart > ComparisonEpsilon)
return true; // something's wrong - should reset
return currentSessionStart - savedSessionStart > ComparisonEpsilon;
SessionState.SetBool(SessionStartKey, true);
}

private static void OnQuitting() => ElympicsWebIntegration.PostStopEvent();
Expand Down
7 changes: 4 additions & 3 deletions Editor/Elympics.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "Elympics.Editor",
"rootNamespace": "",
"references": [
"GUID:98c20d83c9beb3344bdbd3db8ff8d852"
"GUID:98c20d83c9beb3344bdbd3db8ff8d852",
"GUID:b5112f143ba6a88409acbb72a5e9f0f0"
],
"includePlatforms": [
"Editor"
Expand All @@ -10,8 +12,7 @@
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"Elympics.Newtonsoft.Json.dll",
"ElympicsApiModels-packed.dll"
"Elympics.Newtonsoft.Json.dll"
],
"autoReferenced": true,
"defineConstraints": [],
Expand Down
48 changes: 42 additions & 6 deletions Editor/ElympicsMouseActions.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,58 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;

namespace Elympics
{
public static class ElympicsMouseActions
{
private const string PathToElympicsSystem = "Elympics";
private const string PathToElympicsLobby = "ElympicsLobby";

[MenuItem(ElympicsEditorMenuPaths.MOUSE_ACTION_CREATE_ELYMPICS_SYSTEM, priority = 11)]
[MenuItem(ElympicsEditorMenuPaths.MOUSE_ACTION_CREATE_ELYMPICS_SYSTEM)]
private static void AddElympicsSystemToScene()
{
var elympicsSystemPrefabReference = Resources.Load<GameObject>(PathToElympicsSystem);
const string name = "Elympics System";
if (HasActiveSceneAnyObjectOfType<ElympicsLobbyClient>())
{
Debug.LogError($"{name} cannot be placed in the menu scene. Use a separate game scene.");
return;
}
AddUniquePrefabToScene<GameSceneManager>(PathToElympicsSystem, name);
}

[MenuItem(ElympicsEditorMenuPaths.MOUSE_ACTION_CREATE_ELYMPICS_LOBBY)]
private static void AddElympicsLobbyToScene()
{
const string name = "Elympics Lobby";
if (HasActiveSceneAnyObjectOfType<GameSceneManager>())
{
Debug.LogError($"{name} cannot be placed in the game scene. Use a separate menu scene.");
return;
}
AddUniquePrefabToScene<ElympicsLobbyClient>(PathToElympicsLobby, name);
}

if (elympicsSystemPrefabReference != null)
_ = PrefabUtility.InstantiatePrefab(elympicsSystemPrefabReference);
else
Debug.LogError("Cannot instantiate elympics system - prefab reference is null!");
private static void AddUniquePrefabToScene<T>(string path, string name)
where T : Component
{
if (HasActiveSceneAnyObjectOfType<T>())
{
Debug.LogError($"{name} is already present in the current scene.");
return;
}
var prefabReference = Resources.Load<T>(path);
if (prefabReference == null)
{
Debug.LogError($"Cannot instantiate {name} - prefab reference is null!");
return;
}
var instance = PrefabUtility.InstantiatePrefab(prefabReference.gameObject);
Undo.RegisterCreatedObjectUndo(instance, $"Instantiate {name}");
}

private static bool HasActiveSceneAnyObjectOfType<T>() where T : Object =>
SceneObjectsFinder.FindObjectsOfType<T>(SceneManager.GetActiveScene(), true).Count > 0;
}
}

2 changes: 1 addition & 1 deletion Editor/ElympicsWebIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void OnCompleted(UnityWebRequest webRequest)
public static void PostStartEvent()
{
var gameConfig = ElympicsConfig.LoadCurrentElympicsGameConfig();
PostTelemetryEvent(UsageStatisticsRoutes.Start, new StartRequest { gameId = gameConfig.GameId });
PostTelemetryEvent(UsageStatisticsRoutes.Start, new StartRequest { gameId = gameConfig?.GameId });
}

public static void PostPlayEvent(string mode)
Expand Down
8 changes: 8 additions & 0 deletions Editor/Plugins.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Editor/Plugins/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[*]
generated_code = true
dotnet_analyzer_diagnostic.severity = none
indent_style = unset
end_of_line = unset
charset = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions Editor/Plugins/Mono.Cecil.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
33 changes: 33 additions & 0 deletions Editor/Plugins/Mono.Cecil/Elympics.Mono.Cecil.Pdb.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
33 changes: 33 additions & 0 deletions Editor/Plugins/Mono.Cecil/Elympics.Mono.Cecil.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions Editor/Tools/NetworkedSimulationAnalyzer/ReplayFileManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using MessagePack;
using UnityEditor;

namespace Elympics
Expand Down Expand Up @@ -75,9 +76,7 @@ private static void SerializeServerData(BinaryWriter bw, TickListDisplayer tickL
// snapshots
bw.Write(tickListDisplayer.AllTicksData.Count);
foreach (var entry in tickListDisplayer.AllTicksData)
{
entry.Snapshot.Serialize(bw);
}
MessagePackSerializer.Serialize(bw.BaseStream, entry.Snapshot);
}

private static bool DeserializeServerData(BinaryReader br, TickListDisplayer tickListDisplayer, TickDataDisplayer tickDataDisplayer)
Expand Down Expand Up @@ -127,11 +126,7 @@ private static bool DeserializeServerData(BinaryReader br, TickListDisplayer tic
tickListDisplayer.AllTicksData.Clear();
var count = br.ReadInt32();
for (var i = 0; i < count; i++)
{
var snapshot = new ElympicsSnapshotWithMetadata();
snapshot.Deserialize(br);
tickListDisplayer.AddTick(snapshot);
}
tickListDisplayer.AddTick(MessagePackSerializer.Deserialize<ElympicsSnapshotWithMetadata>(br.BaseStream));

return true;
}
Expand Down

0 comments on commit 51efbc0

Please sign in to comment.