Skip to content

Commit 730fc4d

Browse files
authored
Merge branch 'develop' into singleton-removal-network-object
2 parents 2b7aeeb + c876ad9 commit 730fc4d

File tree

132 files changed

+22116
-783
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+22116
-783
lines changed

.yamato/_triggers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{% metadata_file .yamato/project.metafile %}
22
---
3-
43
develop_nightly_trigger:
54
name: Develop Branch Nightly Trigger
65
triggers:
@@ -20,6 +19,7 @@ develop_nightly_trigger:
2019
pull_request_trigger:
2120
name: Pull Request Trigger on {{ test_editors.first }} (master, develop, & release branches)
2221
dependencies:
22+
- .yamato/project-standards.yml#standards_{{ projects.first.name }}
2323
{% for project in projects -%}
2424
{% for package in project.packages -%}
2525
- .yamato/project-tests.yml#validate_{{ package.name }}_{{ test_platforms.first.name }}_{{ test_editors.first }}

.yamato/project-standards.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% metadata_file .yamato/project.metafile %}
2+
---
3+
standards_{{ projects.first.name }}:
4+
name: Standards Check {{ projects.first.name }}
5+
agent:
6+
type: Unity::VM
7+
image: desktop/logging-testing-linux:stable
8+
flavor: b1.small
9+
commands:
10+
- dotnet --version
11+
- $HOME/.dotnet/tools/dotnet-format --version
12+
- python3 --version
13+
- pip install unity-downloader-cli --upgrade --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple
14+
- unity-downloader-cli -u {{ test_editors.first }} -c editor --wait --fast
15+
- .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath {{ projects.first.path }} -quit
16+
- ./standards.py --tool-path $HOME/.dotnet/tools/dotnet-format --project-path {{ projects.first.path }} --yamato

com.unity.multiplayer.mlapi/Editor/NetworkManagerEditor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class NetworkManagerEditor : UnityEditor.Editor
3636
private SerializedProperty m_TimeResyncIntervalProperty;
3737
private SerializedProperty m_EnableNetworkVariableProperty;
3838
private SerializedProperty m_EnsureNetworkVariableLengthSafetyProperty;
39-
private SerializedProperty m_ForceSamePrefabsProperty;
39+
private SerializedProperty m_ForceSamePrefabsProperty;
4040
private SerializedProperty m_EnableSceneManagementProperty;
4141
private SerializedProperty m_RecycleNetworkIdsProperty;
4242
private SerializedProperty m_NetworkIdRecycleDelayProperty;
@@ -112,7 +112,7 @@ private void Initialize()
112112
m_EnableTimeResyncProperty = m_NetworkConfigProperty.FindPropertyRelative("EnableTimeResync");
113113
m_TimeResyncIntervalProperty = m_NetworkConfigProperty.FindPropertyRelative("TimeResyncInterval");
114114
m_EnableNetworkVariableProperty = m_NetworkConfigProperty.FindPropertyRelative("EnableNetworkVariable");
115-
m_EnsureNetworkVariableLengthSafetyProperty = m_NetworkConfigProperty.FindPropertyRelative("EnsureNetworkVariableLengthSafety");
115+
m_EnsureNetworkVariableLengthSafetyProperty = m_NetworkConfigProperty.FindPropertyRelative("EnsureNetworkVariableLengthSafety");
116116
m_ForceSamePrefabsProperty = m_NetworkConfigProperty.FindPropertyRelative("ForceSamePrefabs");
117117
m_EnableSceneManagementProperty = m_NetworkConfigProperty.FindPropertyRelative("EnableSceneManagement");
118118
m_RecycleNetworkIdsProperty = m_NetworkConfigProperty.FindPropertyRelative("RecycleNetworkIds");
@@ -133,7 +133,7 @@ private void CheckNullProperties()
133133
m_RunInBackgroundProperty = serializedObject.FindProperty(nameof(NetworkManager.RunInBackground));
134134
m_LogLevelProperty = serializedObject.FindProperty(nameof(NetworkManager.LogLevel));
135135
m_NetworkConfigProperty = serializedObject.FindProperty(nameof(NetworkManager.NetworkConfig));
136-
136+
137137
// NetworkConfig properties
138138
m_PlayerPrefabProperty = m_NetworkConfigProperty.FindPropertyRelative(nameof(NetworkConfig.PlayerPrefab));
139139
m_ProtocolVersionProperty = m_NetworkConfigProperty.FindPropertyRelative("ProtocolVersion");

com.unity.multiplayer.mlapi/Runtime/Core/NetworkBehaviour.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,6 @@ public virtual void OnGainedOwnership() { }
385385
/// </summary>
386386
public virtual void OnLostOwnership() { }
387387

388-
#region NetworkVariable
389-
390388
private bool m_VarInit = false;
391389

392390
private readonly List<HashSet<int>> m_ChannelMappedNetworkVariableIndexes = new List<HashSet<int>>();
@@ -999,8 +997,6 @@ internal static void SetNetworkVariableData(List<INetworkVariable> networkVariab
999997
}
1000998
}
1001999

1002-
#endregion
1003-
10041000
/// <summary>
10051001
/// Gets the local instance of a object with a given NetworkId
10061002
/// </summary>

com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,8 +1154,6 @@ internal void HandleIncomingData(ulong clientId, NetworkChannel networkChannel,
11541154
return;
11551155
}
11561156

1157-
#region INTERNAL MESSAGE
1158-
11591157
switch (messageType)
11601158
{
11611159
case NetworkConstants.CONNECTION_REQUEST:
@@ -1312,8 +1310,6 @@ internal void HandleIncomingData(ulong clientId, NetworkChannel networkChannel,
13121310
break;
13131311
}
13141312

1315-
#endregion
1316-
13171313
#if !UNITY_2020_2_OR_NEWER
13181314
NetworkProfiler.EndEvent();
13191315
#endif

com.unity.multiplayer.mlapi/Runtime/Messaging/CustomMessageManager.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ internal CustomMessagingManager(NetworkManager networkManager)
2323
m_NetworkManager = networkManager;
2424
}
2525

26-
#region Unnamed
27-
2826
/// <summary>
2927
/// Delegate used for incoming unnamed messages
3028
/// </summary>
@@ -73,10 +71,6 @@ public void SendUnnamedMessage(ulong clientId, NetworkBuffer buffer, NetworkChan
7371
PerformanceDataManager.Increment(ProfilerConstants.UnnamedMessageSent);
7472
}
7573

76-
#endregion
77-
78-
#region Named
79-
8074
/// <summary>
8175
/// Delegate used to handle named messages
8276
/// </summary>
@@ -215,7 +209,5 @@ public void SendNamedMessage(string name, List<ulong> clientIds, Stream stream,
215209
PerformanceDataManager.Increment(ProfilerConstants.NamedMessageSent);
216210
}
217211
}
218-
219-
#endregion
220212
}
221213
}

com.unity.multiplayer.mlapi/Runtime/Spawning/NetworkSpawnManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ internal NetworkObject CreateLocalNetworkObject(bool softCreate, uint prefabHash
196196
{
197197
// See if there is a valid registered NetworkPrefabOverrideLink associated with the provided prefabHash
198198
GameObject networkPrefabReference = null;
199-
if(NetworkManager.NetworkConfig.NetworkPrefabOverrideLinks.ContainsKey(prefabHash))
199+
if (NetworkManager.NetworkConfig.NetworkPrefabOverrideLinks.ContainsKey(prefabHash))
200200
{
201201
switch (NetworkManager.NetworkConfig.NetworkPrefabOverrideLinks[prefabHash].Override)
202202
{

com.unity.multiplayer.mlapi/Tests/Editor/NetworkManagerMessageSenderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void MessageSenderAssigned()
2121
networkManager.NetworkConfig = new NetworkConfig()
2222
{
2323
// Set the current scene to prevent unexpected log messages which would trigger a failure
24-
RegisteredScenes = new List<string>() {SceneManager.GetActiveScene().name}
24+
RegisteredScenes = new List<string>() { SceneManager.GetActiveScene().name }
2525
};
2626

2727
// Set dummy transport that does nothing

com.unity.multiplayer.mlapi/Tests/Editor/NetworkManagerSceneManagerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void SceneManagerAssigned()
2121
networkManager.NetworkConfig = new NetworkConfig()
2222
{
2323
// Set the current scene to prevent unexpected log messages which would trigger a failure
24-
RegisteredScenes = new List<string>() {SceneManager.GetActiveScene().name}
24+
RegisteredScenes = new List<string>() { SceneManager.GetActiveScene().name }
2525
};
2626

2727
// Set dummy transport that does nothing

com.unity.multiplayer.mlapi/Tests/Runtime/NetworkManagerHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static bool StartNetworkManager(out NetworkManager networkManager, Networ
7575
NetworkManagerObject.NetworkConfig = new Configuration.NetworkConfig
7676
{
7777
EnableSceneManagement = false,
78-
RegisteredScenes = new List<string>(){SceneManager.GetActiveScene().name}
78+
RegisteredScenes = new List<string>() { SceneManager.GetActiveScene().name }
7979
};
8080
unetTransport.ConnectAddress = "127.0.0.1";
8181
unetTransport.ConnectPort = 7777;

standards.py

Lines changed: 77 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,22 @@
33
import os
44
import sys
55
import stat
6+
import glob
67
import argparse
8+
import datetime
9+
710

811
parser = argparse.ArgumentParser()
912

1013
parser.add_argument("--hook", action="store_true")
1114
parser.add_argument("--unhook", action="store_true")
1215
parser.add_argument("--check", action="store_true")
1316
parser.add_argument("--fix", action="store_true")
17+
parser.add_argument("--yamato", action="store_true")
18+
19+
parser.add_argument("--tool-path", default="dotnet-format")
20+
parser.add_argument("--project-path", default="testproject")
21+
parser.add_argument("--project-glob", default="Unity.Multiplayer.MLAPI*.csproj")
1422

1523
if len(sys.argv) == 1:
1624
parser.print_help(sys.stderr)
@@ -23,57 +31,105 @@
2331
hook_exec = f"python3 {os.path.basename(sys.argv[0])} --check"
2432

2533
if args.hook:
26-
print("execute hook")
34+
print("hook: execute")
2735

2836
if os.path.exists(hook_path):
29-
exit(
30-
f"fail: git pre-push hook file already exists: `{hook_path}`\n"
31-
"please make sure to backup and delete the existing pre-push hook file"
32-
)
37+
print(f"hook: git pre-push hook file already exists: `{hook_path}`")
38+
print("hook: please make sure to backup and delete the existing pre-push hook file")
39+
exit("hook: failed")
3340

34-
print("write git pre-push hook file contents")
41+
print("hook: write git pre-push hook file contents")
3542
hook_file = open(hook_path, "w")
3643
hook_file.write(f"#!/bin/sh\n\n{hook_exec}\n")
3744
hook_file.close()
3845

39-
print("make git pre-push hook file executable")
46+
print("hook: make git pre-push hook file executable")
4047
hook_stat = os.stat(hook_path)
4148
os.chmod(hook_path, hook_stat.st_mode | stat.S_IEXEC)
4249

43-
print("succeed: git pre-push hook created!")
50+
print("hook: succeeded")
4451

4552

4653
if args.unhook:
47-
print("execute unhook")
54+
print("unhook: execute")
4855

4956
hook_path = "./.git/hooks/pre-push"
5057
if os.path.isfile(hook_path):
51-
print(f"found `{hook_path}`")
58+
print(f"unhook: found file -> `{hook_path}`")
5259
delete = False
5360
hook_file = open(hook_path, "r")
5461
if hook_exec in hook_file.read():
5562
delete = True
5663
else:
57-
exit(f"fail: existing git pre-push hook file was not created by this script")
64+
print("unhook: existing git pre-push hook file was not created by this script")
65+
exit("unhook: failed")
5866
hook_file.close()
5967
if delete:
6068
os.remove(hook_path)
61-
print(f"delete file: `{hook_path}`")
69+
print(f"unhook: delete file -> `{hook_path}`")
70+
71+
print("unhook: succeeded")
72+
6273

63-
print("succeed: git pre-push hook removed!")
74+
if args.check or args.fix or args.yamato:
75+
glob_match = os.path.join(args.project_path, args.project_glob)
76+
glob_files = glob.glob(glob_match)
77+
print(f"glob: found {len(glob_files)} files matching -> {glob_match}")
78+
79+
if len(glob_files) == 0:
80+
print("glob: no project files found!")
81+
print("glob: \tdid you forget to generate your solution and project files in Unity?")
82+
print("glob: \tdid you double-check --project-path and/or --project-glob arguments?")
83+
exit(f"glob: failed")
84+
85+
any_old = False
86+
for project_file in glob_files:
87+
file_stat = os.stat(project_file)
88+
check_days = 7
89+
modified_time = datetime.datetime.fromtimestamp(file_stat.st_mtime)
90+
days_ago_time = datetime.datetime.now() - datetime.timedelta(days=check_days)
91+
if modified_time < days_ago_time:
92+
any_old = True
93+
print(f"glob: last modified more than {check_days} days ago -> {project_file}")
94+
if any_old:
95+
print(f"glob: some project files are not modified for more than {check_days} days ago")
96+
print("glob: please consider regenerating project files in Unity")
6497

6598

6699
if args.check:
67-
print("execute check")
100+
print("check: execute")
101+
102+
any_error = False
103+
for project_file in glob_files:
104+
print(f"check: project -> {project_file}")
105+
any_error = 0 != os.system(f"{args.tool_path} {project_file} --fix-whitespace --fix-style error --check")
68106

69-
check_exec = os.system("dotnet-format ./testproject/testproject.sln --fix-whitespace --fix-style error --check")
70-
if check_exec != 0:
71-
exit(f"check_exec failed, exit code: {check_exec}")
107+
if any_error:
108+
exit(f"check: failed")
109+
110+
print("check: succeeded")
72111

73112

74113
if args.fix:
75-
print("execute fix")
114+
print("fix: execute")
115+
116+
any_error = False
117+
for project_file in glob_files:
118+
print(f"fix: project -> {project_file}")
119+
any_error = 0 != os.system(f"{args.tool_path} {project_file} --fix-whitespace --fix-style error")
120+
121+
if any_error:
122+
exit(f"fix: failed")
123+
124+
print("fix: succeeded")
125+
126+
if args.yamato:
127+
print("yamato: execute")
128+
129+
for project_file in glob_files:
130+
print(f"yamato: project -> {project_file}")
131+
yamato_exec = os.system(f"{args.tool_path} {project_file} --fix-style error --check")
132+
if yamato_exec != 0:
133+
exit(f"yamato: failed, exit code -> {yamato_exec}")
76134

77-
fix_exec = os.system("dotnet-format ./testproject/testproject.sln --fix-whitespace --fix-style error")
78-
if fix_exec != 0:
79-
exit(f"fix_exec failed, exit code: {fix_exec}")
135+
print("yamato: succeeded")

0 commit comments

Comments
 (0)