Skip to content

Commit f28e0df

Browse files
Fixed Linux-Specific Settings
1 parent 2e5a037 commit f28e0df

13 files changed

Lines changed: 173 additions & 47 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ Assets/Example Avatar - USED FOR MATE ENGINE
157157
ProjectSettings/Packages
158158
UserSettings/Layouts
159159
uWindowCapture.log
160+
build.sh
160161

161162
# External native libraries - build them by yourself
162163
Assets/MATE\ ENGINE\ -\ Packages/StandaloneFileBrowser/Plugins/Linux/x86_64/

Assets/AddressableAssetsData/AddressableAssetSettings.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ MonoBehaviour:
1515
m_DefaultGroup: da47376fc21048246a6d81428534a2ed
1616
m_currentHash:
1717
serializedVersion: 2
18-
Hash: b1c16fe75ab887cf37dd059ada7c374e
18+
Hash: 485e4d1cc5e1f84c04f97bf7be8dbac5
1919
m_OptimizeCatalogSize: 0
2020
m_BuildRemoteCatalog: 0
2121
m_CatalogRequestsTimeout: 0

Assets/Editor/CliBuilder.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using UnityEditor;
2+
using UnityEditor.Build.Reporting;
3+
using UnityEngine;
4+
5+
public static class CliBuilder
6+
{
7+
public static void Build()
8+
{
9+
var options = new BuildPlayerOptions
10+
{
11+
scenes = new[] { "Assets/MATE ENGINE - Scenes/Mate Engine Main.unity"},
12+
locationPathName = "~/Desktop/MateEngineX/MateEngineX.x86_64",
13+
target = BuildTarget.StandaloneLinux64,
14+
options = BuildOptions.CompressWithLz4HC
15+
};
16+
17+
BuildReport report = BuildPipeline.BuildPlayer(options);
18+
BuildSummary summary = report.summary;
19+
20+
if (summary.result == BuildResult.Succeeded)
21+
Debug.Log($"Build succeeded → {summary.totalSize / 1048576f:F1} MB");
22+
else
23+
{
24+
Debug.LogError("Build failed!");
25+
EditorApplication.Exit(1);
26+
}
27+
}
28+
}

Assets/Editor/CliBuilder.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/MATE ENGINE - Scenes/Mate Engine Main.unity

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11895,7 +11895,7 @@ Light:
1189511895
serializedVersion: 11
1189611896
m_Type: 2
1189711897
m_Color: {r: 1, g: 0.26999998, b: 0.96203995, a: 1}
11898-
m_Intensity: 1.0879185e-15
11898+
m_Intensity: 1.0344242e-15
1189911899
m_Range: 0.5
1190011900
m_SpotAngle: 30
1190111901
m_InnerSpotAngle: 21.80208
@@ -45156,7 +45156,7 @@ Light:
4515645156
serializedVersion: 11
4515745157
m_Type: 2
4515845158
m_Color: {r: 0, g: 0.44799995, b: 1, a: 1}
45159-
m_Intensity: 2.175837e-15
45159+
m_Intensity: 2.0688483e-15
4516045160
m_Range: 1
4516145161
m_SpotAngle: 30
4516245162
m_InnerSpotAngle: 21.80208
@@ -54453,7 +54453,7 @@ Light:
5445354453
serializedVersion: 11
5445454454
m_Type: 2
5445554455
m_Color: {r: 0, g: 0.44799995, b: 1, a: 1}
54456-
m_Intensity: 1.6318778e-15
54456+
m_Intensity: 1.5516362e-15
5445754457
m_Range: 1
5445854458
m_SpotAngle: 30
5445954459
m_InnerSpotAngle: 21.80208
@@ -54803,6 +54803,7 @@ Transform:
5480354803
m_ConstrainProportionsScale: 0
5480454804
m_Children:
5480554805
- {fileID: 9167954367735630932}
54806+
- {fileID: 1481612163}
5480654807
- {fileID: 1520083670}
5480754808
- {fileID: 222295048}
5480854809
- {fileID: 763844365}
@@ -55847,6 +55848,50 @@ CanvasRenderer:
5584755848
m_PrefabAsset: {fileID: 0}
5584855849
m_GameObject: {fileID: 1470580897}
5584955850
m_CullTransparentMesh: 1
55851+
--- !u!1 &1481612161
55852+
GameObject:
55853+
m_ObjectHideFlags: 0
55854+
m_CorrespondingSourceObject: {fileID: 0}
55855+
m_PrefabInstance: {fileID: 0}
55856+
m_PrefabAsset: {fileID: 0}
55857+
serializedVersion: 6
55858+
m_Component:
55859+
- component: {fileID: 1481612163}
55860+
- component: {fileID: 1481612162}
55861+
m_Layer: 0
55862+
m_Name: MoveToPrimaryScreen
55863+
m_TagString: Untagged
55864+
m_Icon: {fileID: 0}
55865+
m_NavMeshLayer: 0
55866+
m_StaticEditorFlags: 0
55867+
m_IsActive: 1
55868+
--- !u!114 &1481612162
55869+
MonoBehaviour:
55870+
m_ObjectHideFlags: 0
55871+
m_CorrespondingSourceObject: {fileID: 0}
55872+
m_PrefabInstance: {fileID: 0}
55873+
m_PrefabAsset: {fileID: 0}
55874+
m_GameObject: {fileID: 1481612161}
55875+
m_Enabled: 1
55876+
m_EditorHideFlags: 0
55877+
m_Script: {fileID: 11500000, guid: 7a308ed2892fe6669b596aa4f44cffa9, type: 3}
55878+
m_Name:
55879+
m_EditorClassIdentifier: Assembly-CSharp::MoveToPrimaryScreen
55880+
--- !u!4 &1481612163
55881+
Transform:
55882+
m_ObjectHideFlags: 0
55883+
m_CorrespondingSourceObject: {fileID: 0}
55884+
m_PrefabInstance: {fileID: 0}
55885+
m_PrefabAsset: {fileID: 0}
55886+
m_GameObject: {fileID: 1481612161}
55887+
serializedVersion: 2
55888+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
55889+
m_LocalPosition: {x: 0, y: 0, z: 0}
55890+
m_LocalScale: {x: 1, y: 1, z: 1}
55891+
m_ConstrainProportionsScale: 0
55892+
m_Children: []
55893+
m_Father: {fileID: 1395823394}
55894+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
5585055895
--- !u!1 &1481612526
5585155896
GameObject:
5585255897
m_ObjectHideFlags: 0
@@ -56225,7 +56270,6 @@ GameObject:
5622556270
- component: {fileID: 1520083671}
5622656271
- component: {fileID: 1520083672}
5622756272
- component: {fileID: 1520083673}
56228-
- component: {fileID: 1520083674}
5622956273
m_Layer: 0
5623056274
m_Name: EventSystem
5623156275
m_TagString: Untagged
@@ -56299,7 +56343,7 @@ MonoBehaviour:
5629956343
actions:
5630056344
- label: Move To Main Monitor
5630156345
type: 2
56302-
handlerObject: {fileID: 1520083667}
56346+
handlerObject: {fileID: 1481612161}
5630356347
toggleField: enableWindowSittingToggle
5630456348
methodName: Action
5630556349
- label: Enable Dancing
@@ -56351,7 +56395,7 @@ MonoBehaviour:
5635156395
type: 2
5635256396
handlerObject: {fileID: 9167954367735630936}
5635356397
toggleField: enableWindowSittingToggle
56354-
methodName: ForceStopDragging
56398+
methodName: QueryMonitors
5635556399
--- !u!114 &1520083672
5635656400
MonoBehaviour:
5635756401
m_ObjectHideFlags: 0
@@ -56376,18 +56420,6 @@ MonoBehaviour:
5637656420
m_Script: {fileID: 11500000, guid: 498b9399151c1e99fb6dfab00b5fa900, type: 3}
5637756421
m_Name:
5637856422
m_EditorClassIdentifier: Assembly-CSharp::TrayIndicator
56379-
--- !u!114 &1520083674
56380-
MonoBehaviour:
56381-
m_ObjectHideFlags: 0
56382-
m_CorrespondingSourceObject: {fileID: 0}
56383-
m_PrefabInstance: {fileID: 0}
56384-
m_PrefabAsset: {fileID: 0}
56385-
m_GameObject: {fileID: 1520083667}
56386-
m_Enabled: 1
56387-
m_EditorHideFlags: 0
56388-
m_Script: {fileID: 11500000, guid: 7a308ed2892fe6669b596aa4f44cffa9, type: 3}
56389-
m_Name:
56390-
m_EditorClassIdentifier: Assembly-CSharp::MoveToMainMonitor
5639156423
--- !u!1 &1554093025
5639256424
GameObject:
5639356425
m_ObjectHideFlags: 0
@@ -167430,7 +167462,7 @@ MonoBehaviour:
167430167462
groupID: ambi_lights
167431167463
exclusiveTags:
167432167464
- lights
167433-
fadeCurrentValue: 5.4395926e-16
167465+
fadeCurrentValue: 5.172121e-16
167434167466
fadeTarget: 0
167435167467
isFading: 1
167436167468
hasYSet: 0
@@ -167454,7 +167486,7 @@ MonoBehaviour:
167454167486
groupID: ambi_lights
167455167487
exclusiveTags:
167456167488
- lights
167457-
fadeCurrentValue: 5.4395926e-16
167489+
fadeCurrentValue: 5.172121e-16
167458167490
fadeTarget: 0
167459167491
isFading: 1
167460167492
hasYSet: 0
@@ -167478,7 +167510,7 @@ MonoBehaviour:
167478167510
groupID: ambi_lights
167479167511
exclusiveTags:
167480167512
- lights
167481-
fadeCurrentValue: 5.4395926e-16
167513+
fadeCurrentValue: 5.172121e-16
167482167514
fadeTarget: 0
167483167515
isFading: 1
167484167516
hasYSet: 0
@@ -197626,6 +197658,7 @@ MonoBehaviour:
197626197658
m_Script: {fileID: 11500000, guid: f20133451b8bf43c9809426b8c4c4c16, type: 3}
197627197659
m_Name:
197628197660
m_EditorClassIdentifier: Assembly-CSharp::X11.X11Manager
197661+
isDragging: 0
197629197662
--- !u!224 &9169863018140061722
197630197663
RectTransform:
197631197664
m_ObjectHideFlags: 0

Assets/MATE ENGINE - Scripts/APIs/LinuxSpecificSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ private void DrawWindow(int windowId)
247247
ShowWindow(false);
248248
}
249249
GUILayout.EndHorizontal();
250+
251+
GUILayout.EndHorizontal();
250252

251253
GUILayout.EndVertical();
252254

Assets/MATE ENGINE - Scripts/APIs/PulseAudioManager.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,15 @@ private enum PaEncoding
180180

181181
private readonly object _programsLock = new();
182182

183+
private PaSinkInputInfoCbT _cachedSinkInputCb;
184+
183185
private Thread _mainloopThread;
184186
private volatile bool _running;
185187

186188
private void OnEnable()
187189
{
188190
Instance = this;
191+
_cachedSinkInputCb = OnSinkInputInfo;
189192
Init();
190193
}
191194

@@ -263,8 +266,7 @@ public void GetPlayingAudioPrograms(Action<List<AudioProgram>> onComplete)
263266
}
264267

265268
callbackRunning = true;
266-
var cb = new PaSinkInputInfoCbT(OnSinkInputInfo);
267-
IntPtr op = pa_context_get_sink_input_info_list(_context, cb, IntPtr.Zero);
269+
IntPtr op = pa_context_get_sink_input_info_list(_context, _cachedSinkInputCb, IntPtr.Zero);
268270

269271
if (op == IntPtr.Zero)
270272
{
@@ -304,14 +306,11 @@ private IEnumerator WaitForOperation(IntPtr op, Action onComplete)
304306
[MonoPInvokeCallback(typeof(PaSinkInputInfoCbT))]
305307
private void OnSinkInputInfo(IntPtr context, IntPtr info, int eol, IntPtr userdata)
306308
{
307-
if (eol != 0)
309+
if (eol != 0 || info == IntPtr.Zero)
308310
{
309311
return;
310312
}
311313

312-
if (info == IntPtr.Zero)
313-
return;
314-
315314
try
316315
{
317316
var sinkInput = Marshal.PtrToStructure<PaSinkInputInfo>(info);
@@ -336,7 +335,7 @@ private AudioProgram ParseSinkInputProperties(PaSinkInputInfo sinkInput)
336335
var volumes = new List<double>();
337336
for (int i = 0; i < sinkInput.volume.channels; i++)
338337
{
339-
volumes.Add(sinkInput.volume.values[i] / 65535f);
338+
volumes.Add(sinkInput.volume.values[i] / 65536.0);
340339
}
341340
var audioProgram = new AudioProgram
342341
{
@@ -389,7 +388,9 @@ private bool IsAudioRelatedNode(string mediaClass)
389388
return false;
390389

391390
// Check for audio playback streams (adjust based on common values like "Audio/Playback" in PipeWire)
392-
return mediaClass.Contains("Audio") || mediaClass.Contains("Stream/SinkInput");
391+
return mediaClass.Contains("Audio") ||
392+
mediaClass.Contains("Stream") ||
393+
mediaClass.Contains("SinkInput");
393394
}
394395

395396
private Dictionary<string, string> ParsePaProplist(IntPtr proplist)

Assets/MATE ENGINE - Scripts/APIs/WindowManager.cs

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class WindowManager : MonoBehaviour, IPointerDownHandler, IPointerUpHandl
3636

3737
private Vector2 initialMousePos;
3838
private Vector2 initialWindowPos;
39-
public bool isDragging;
39+
private bool isDragging;
4040

4141
public IntPtr Display
4242
{
@@ -143,6 +143,8 @@ private void Init()
143143
throw new Exception("Cannot open X11 display");
144144
}
145145

146+
XSetErrorHandler(ShowError);
147+
146148
_rootWindow = XDefaultRootWindow(_display);
147149
_netWmState = XInternAtom(_display, "_NET_WM_STATE", false);
148150
_netWmStateFullscreen = XInternAtom(_display, "_NET_WM_STATE_FULLSCREEN", false);
@@ -151,8 +153,26 @@ private void Init()
151153
_netWmWindowType = XInternAtom(_display, "_NET_WM_WINDOW_TYPE", false);
152154
}
153155

156+
private int ShowError(IntPtr display, IntPtr e)
157+
{
158+
ShowError(LookupError(e) ?? "???");
159+
return 0;
160+
}
161+
154162
private void ShowError(string error) => Debug.LogError(typeof(WindowManager) + ": " + error);
155163

164+
private string LookupError(IntPtr errorEvent)
165+
{
166+
XErrorEvent error = Marshal.PtrToStructure<XErrorEvent>(errorEvent);
167+
if (_display == IntPtr.Zero) return "Display not initialized";
168+
169+
var buffer = new byte[256];
170+
171+
XGetErrorText(_display, error.error_code, buffer, buffer.Length);
172+
173+
return System.Text.Encoding.ASCII.GetString(buffer).TrimEnd('\0');;
174+
}
175+
156176
private void Dispose()
157177
{
158178
running = false;
@@ -175,6 +195,7 @@ private void Dispose()
175195
XSync(_display, false);
176196
XCloseDisplay(_display);
177197
_display = IntPtr.Zero;
198+
XFreeThreads();
178199
}
179200
}
180201
#endregion
@@ -272,8 +293,7 @@ public void QueryMonitors()
272293
return;
273294
}
274295

275-
int major, minor;
276-
if (XRRQueryVersion(_display, out major, out minor) == 0 || major < 1 || (major == 1 && minor < 3))
296+
if (XRRQueryVersion(_display, out var major, out var minor) == 0 || major < 1 || (major == 1 && minor < 3))
277297
{
278298
Debug.LogError("XRandR 1.3+ required for multi-monitor.");
279299
return;
@@ -1442,10 +1462,28 @@ private enum Rotation : ushort
14421462
ReflectX = 1 << 4,
14431463
ReflectY = 1 << 5
14441464
}
1465+
1466+
// Error handler delegate type
1467+
private delegate int XErrorHandler(IntPtr display, IntPtr errorEvent);
1468+
1469+
[StructLayout(LayoutKind.Sequential)]
1470+
private struct XErrorEvent
1471+
{
1472+
public int type;
1473+
public IntPtr display;
1474+
public ulong serial;
1475+
public byte error_code;
1476+
public byte request_code;
1477+
public byte minor_code;
1478+
public IntPtr resourceid;
1479+
}
14451480

14461481
// X11 Library imports
14471482
[DllImport(LibX11)]
14481483
private static extern int XInitThreads();
1484+
1485+
[DllImport(LibX11)]
1486+
private static extern int XFreeThreads();
14491487

14501488
[DllImport(LibX11)]
14511489
private static extern IntPtr XOpenDisplay(string displayName);
@@ -1633,5 +1671,11 @@ private static extern IntPtr XGetImage(IntPtr display, IntPtr drawable, int x, i
16331671
[DllImport(LibX11)]
16341672
private static extern string XGetAtomName(IntPtr display, IntPtr atom);
16351673

1674+
[DllImport(LibX11)]
1675+
private static extern bool XGetErrorText(IntPtr display, int code, byte[] buffer, int size);
1676+
1677+
[DllImport(LibX11)]
1678+
private static extern XErrorHandler XSetErrorHandler(XErrorHandler handler);
1679+
16361680
#endregion
1637-
}
1681+
}

0 commit comments

Comments
 (0)