Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@
"name": "Attach to Unity",
"type": "vstuc",
"request": "attach"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug Unity Editor",
"program": "/Applications/Unity/Hub/Editor/2022.3.38f1/Unity.app/Contents/MacOS/Unity",
"args": [
"-projectPath",
"${workspaceFolder}",
"-logfile",
"/tmp/unity-log.txt"
],
"cwd": "${workspaceFolder}",
"env": {},
"stopOnEntry": false,
"initCommands": [
"settings set target.inline-breakpoint-strategy always"
],
"postRunCommands": [
"process handle -p true -s false -n false SIGXCPU SIGPIPE"
]
}
]
}
10 changes: 6 additions & 4 deletions Assets/Rivet/Editor/Task.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using UnityEditor;
using Unity.VisualScripting.YamlDotNet.Serialization.ObjectGraphVisitors;

namespace Rivet.Editor
{
Expand All @@ -11,10 +12,10 @@ public class RivetTask : IDisposable
public enum LogType { STDOUT, STDERR }

// Events
public event Action<string, LogType> TaskLog;
public event Action<JObject> TaskOk;
public event Action<string> TaskError;
public event Action<JObject> TaskOutput;
public event Action<string, LogType>? TaskLog;
public event Action<JObject>? TaskOk;
public event Action<string>? TaskError;
public event Action<JObject>? TaskOutput;

// Config
private string _name;
Expand Down Expand Up @@ -90,6 +91,7 @@ private void HandleOnOutputEvent(string eventJson)

private void OnLogEvent(string log)
{
RivetLogger.Log($"TaskLog is null: {TaskLog == null}");
TaskLog?.Invoke(log, LogType.STDOUT);
}

Expand Down
28 changes: 27 additions & 1 deletion Assets/Rivet/Editor/TaskManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,33 @@ private void OnTaskLog(string message, RivetTask.LogType type)
RivetTask.LogType.STDERR => LogType.STDERR,
_ => LogType.META
};
AddLogLine(message, logType);

// Strip [stdout] and [stderr] prefixes
message = StripLogPrefix(message);

// Filter out Unity stack traces
if (!IsUnityStackTrace(message))
{
AddLogLine(message, logType);
}
}

private string StripLogPrefix(string message)
{
if (message.StartsWith("[stdout] "))
{
return message.Substring(9);
}
else if (message.StartsWith("[stderr] "))
{
return message.Substring(9);
}
return message;
}

private bool IsUnityStackTrace(string message)
{
return (message.Contains(" (at ") && message.EndsWith(")")) || message.StartsWith("UnityEngine.");
}

public void AddLogLine(string message, LogType type)
Expand Down
2 changes: 1 addition & 1 deletion Assets/Rivet/Editor/UI/Dock/Tabs/Develop.uxml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</ui:Instance>
<ui:VisualElement name="PlayBody" style="flex-grow: 0; flex-shrink: 0;">
<ui:Label tabindex="-1" text="Test your game on this machine." parse-escape-sequences="true" display-tooltip-when-elided="true" style="overflow: hidden; white-space: normal; margin-bottom: 6px;" />
<ui:DropdownField choices="Run Client &amp; Server,Run Client Only,Run Server Only" index="0" name="TypeDropdown" label="Type" style="height: 19px; margin-bottom: 4px;" />
<ui:DropdownField choices="Run Client &amp; Server,Run Client Only,Run Server Only" index="2" name="TypeDropdown" label="Type" style="height: 19px; margin-bottom: 4px;" />
<ui:SliderInt label="Client Count" high-value="8" low-value="1" direction="Horizontal" show-input-field="true" name="PlayerCountSlider" />
<ui:VisualElement name="ButtonRow" style="flex-grow: 1; flex-direction: row; margin-bottom: 4px;">
<ui:Instance template="IconButton" name="StartButton" style="flex-grow: 1; display: flex;">
Expand Down
19 changes: 19 additions & 0 deletions Assets/Rivet/Editor/UI/Dock/Tabs/DevelopController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ void InitUI()
_lgsRestart.RegisterCallback<ClickEvent>(ev => { OnLocalGameServerStart(); });
_lgsShowLogs.RegisterCallback<ClickEvent>(ev => GameServerWindow.ShowGameServer());

_playTypeDropdown.RegisterValueChangedCallback(ev => UpdatePlayerCountVisibility());

_buildDeployButton.RegisterCallback<ClickEvent>(ev => OnBuildAndDeploy());


// Initial visibility update
UpdatePlayerCountVisibility();
}

public void OnBootstrap()
Expand Down Expand Up @@ -171,6 +177,13 @@ private void OnLocalGameServerStart()
{
Builder.BuildAndRunMultipleDevPlayers(_playerCount.value);
}

// Open game server logs if needed
if (canPlayServer) {
if (!EditorWindow.HasOpenInstances<GameServerWindow>()) {
GameServerWindow.ShowGameServer();
}
}
}

private void OnBuildAndDeploy()
Expand Down Expand Up @@ -215,5 +228,11 @@ private void OnBuildAndDeploy()
["modules"] = deployModules,
});
}

private void UpdatePlayerCountVisibility()
{
bool showPlayerCount = _playTypeDropdown.index == 0 || _playTypeDropdown.index == 1;
_playerCount.style.display = showPlayerCount ? DisplayStyle.Flex : DisplayStyle.None;
}
}
}
2 changes: 1 addition & 1 deletion Assets/Rivet/Editor/UI/Dock/Tabs/Settings.uxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AttributeOverrides element-name="Title" text="Account" />
</ui:Instance>
<ui:VisualElement name="AccountBody" style="flex-grow: 0; flex-shrink: 0;">
<ui:Label tabindex="-1" text="Sign in to Rivet to deploy game servers &amp; moduless. If self-hosting Rivet, update the API endpoint accordingly." parse-escape-sequences="true" display-tooltip-when-elided="true" style="white-space: normal; margin-bottom: 8px;" />
<ui:Label tabindex="-1" text="Sign in to Rivet to deploy game servers &amp; modules. If self-hosting Rivet, update the API endpoint accordingly." parse-escape-sequences="true" display-tooltip-when-elided="true" style="white-space: normal; margin-bottom: 8px;" />
<ui:TextField picking-mode="Ignore" label="API Endpoint" value="https://api.rivet.gg" name="ApiEndpointField" />
<ui:Button text="Sign In to Rivet" parse-escape-sequences="true" display-tooltip-when-elided="true" name="SignInButton" />
<ui:Button text="Sign Out" parse-escape-sequences="true" display-tooltip-when-elided="true" name="SignOutButton" />
Expand Down
2 changes: 2 additions & 0 deletions Assets/Rivet/Editor/Util/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ public static string BuildDevDedicatedServer()
subtarget = (int)StandaloneBuildSubtarget.Server
};

return FindServerExecutablePath(buildPlayerOptions.locationPathName, buildPlayerOptions.target);

// Build the server
RivetLogger.Log("Building dedicated server...");
var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
Expand Down
6 changes: 3 additions & 3 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
"com.unity.ads": "4.4.2",
"com.unity.ai.navigation": "1.1.5",
"com.unity.analytics": "3.8.1",
"com.unity.collab-proxy": "2.4.3",
"com.unity.collab-proxy": "2.5.1",
"com.unity.feature.2d": "2.0.1",
"com.unity.ide.rider": "3.0.31",
"com.unity.ide.visualstudio": "2.0.22",
"com.unity.ide.vscode": "1.2.5",
"com.unity.nuget.newtonsoft-json": "3.2.1",
"com.unity.purchasing": "4.11.0",
"com.unity.test-framework": "1.1.33",
"com.unity.textmeshpro": "3.0.6",
"com.unity.textmeshpro": "3.0.7",
"com.unity.timeline": "1.7.6",
"com.unity.toolchain.macos-arm64-linux-x86_64": "2.0.0",
"com.unity.ugui": "1.0.0",
"com.unity.vectorgraphics": "2.0.0-preview.24",
"com.unity.visualscripting": "1.9.4",
"com.unity.xr.legacyinputhelpers": "2.1.10",
"com.unity.xr.legacyinputhelpers": "2.1.11",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
Expand Down
Loading