Merge branch 'master' into game-mobTrick

This commit is contained in:
minenice55 2022-06-22 16:23:15 -04:00
commit 1f9b558220
18 changed files with 93 additions and 23 deletions

3
.gitignore vendored
View file

@ -73,3 +73,6 @@ crashlytics-build.properties
# Visual Studio Code
/.vscode/
# Rider
.idea/

View file

@ -0,0 +1,23 @@
namespace Starpelly
{
public static class OS
{
private static readonly OperatingSystem.IOperatingSystem _os;
static OS()
{
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
_os = new OperatingSystem.Windows();
#elif UNITY_STANDALONE_LINUX || UNITY_EDITOR_LINUX
_os = new OperatingSystem.Linux();
#elif UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
_os = new OperatingSystem.MacOS();
#endif
}
public static void ChangeWindowTitle(string newTitle)
{
_os.ChangeWindowTitle(newTitle);
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 36edcede4a1a4ef9bb0902354c3be0d1
timeCreated: 1655775758

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7b17a1aeeb0f43bb805dc7ac03408ebb
timeCreated: 1655775758

View file

@ -0,0 +1,7 @@
namespace Starpelly.OperatingSystem
{
public interface IOperatingSystem
{
public void ChangeWindowTitle(string newTitle);
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8bb82376a44e4330b6398deddb17d282
timeCreated: 1655775758

View file

@ -0,0 +1,16 @@
#if UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
using System.Diagnostics;
namespace Starpelly.OperatingSystem
{
public class Linux : IOperatingSystem
{
public void ChangeWindowTitle(string newTitle)
{
var pid = Process.GetCurrentProcess().Id;
var args = $"search --all --pid {pid} --class '.' set_window --name \"{newTitle}\"";
Process.Start("xdotool", args);
}
}
}
#endif

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9e5d25ae0c3e4256abae4d2e07f7e14b
timeCreated: 1655775758

View file

@ -0,0 +1,10 @@
namespace Starpelly.OperatingSystem
{
public class MacOS : IOperatingSystem
{
public void ChangeWindowTitle(string newTitle)
{
throw new System.NotImplementedException();
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cfc6152d5db74f568b229047970f7889
timeCreated: 1655775758

View file

@ -1,3 +1,4 @@
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
using System;
using System.Runtime.InteropServices;
using System.Text;
@ -5,7 +6,7 @@ using System.Text;
using Starpelly.Common;
using Starpelly.Enums.Windows;
namespace Starpelly.OS
namespace Starpelly.OperatingSystem
{
public class User32
{
@ -53,4 +54,5 @@ namespace Starpelly.OS
public static extern IntPtr GetForegroundWindow();
#endregion
}
}
}
#endif

View file

@ -1,12 +1,13 @@
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
using System;
using System.Runtime.InteropServices;
using Starpelly.Enums.Windows;
using System.Text;
namespace Starpelly.OS
namespace Starpelly.OperatingSystem
{
public class Windows
public class Windows : IOperatingSystem
{
/// <summary>
/// Gets the current title of the game window.
@ -29,7 +30,7 @@ namespace Starpelly.OS
/// Changes the game's window title.
/// </summary>
/// <param name="newTitle">The title the window will be changed to.</param>
public static void ChangeWindowTitle(string newTitle)
public void ChangeWindowTitle(string newTitle)
{
var windowPtr = User32.FindWindow(null, GetActiveWindowTitle());
User32.SetWindowText(windowPtr, newTitle);
@ -136,4 +137,5 @@ namespace Starpelly.OS
#endregion
}
}
}
#endif

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 24f2fe0d29590e64bbf4bc9d4f230b9f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -49,7 +49,7 @@ namespace HeavenStudio
Init();
DontDestroyOnLoad(this.gameObject);
instance = this;
Starpelly.OS.Windows.ChangeWindowTitle($"Heaven Studio DEMO");
Starpelly.OS.ChangeWindowTitle("Heaven Studio DEMO");
}
public static GameObject CreateFade()
@ -99,4 +99,4 @@ namespace HeavenStudio
}
}
}
}

View file

@ -3,9 +3,9 @@
"com.unity.2d.sprite": "1.0.0",
"com.unity.assetbundlebrowser": "https://github.com/Unity-Technologies/AssetBundles-Browser.git",
"com.unity.collab-proxy": "1.15.4",
"com.unity.ide.rider": "2.0.7",
"com.unity.ide.visualstudio": "2.0.12",
"com.unity.ide.vscode": "1.2.4",
"com.unity.ide.rider": "3.0.14",
"com.unity.ide.visualstudio": "2.0.15",
"com.unity.ide.vscode": "1.2.5",
"com.unity.nuget.newtonsoft-json": "2.0.2",
"com.unity.postprocessing": "3.2.1",
"com.unity.test-framework": "1.1.29",

View file

@ -31,16 +31,16 @@
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "2.0.7",
"version": "3.0.14",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.1"
"com.unity.ext.nunit": "1.0.6"
},
"url": "https://packages.unity.com"
},
"com.unity.ide.visualstudio": {
"version": "2.0.12",
"version": "2.0.15",
"depth": 0,
"source": "registry",
"dependencies": {
@ -49,7 +49,7 @@
"url": "https://packages.unity.com"
},
"com.unity.ide.vscode": {
"version": "1.2.4",
"version": "1.2.5",
"depth": 0,
"source": "registry",
"dependencies": {},