mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 11:47:38 +02:00
editor input locking fix (#175)
* fix keyboard input locking * add build date auto-generation script
This commit is contained in:
88
Assets/Scripts/AppInfo.cs
Normal file
88
Assets/Scripts/AppInfo.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using System;
|
||||
|
||||
public static class AppInfo {
|
||||
//--- AutoGenerated.begin
|
||||
public const string Version = "0.0.961";
|
||||
public static readonly DateTime Date = new DateTime(2022, 10, 13, 16, 09, 43, 581, DateTimeKind.Utc);
|
||||
//--- AutoGenerated.end
|
||||
}
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
/// Increase Build Number Automatically
|
||||
/// </summary>
|
||||
public class BuildNumberUpdater : UnityEditor.Build.IPreprocessBuild
|
||||
{
|
||||
private static readonly char[] LineDelimiter = {'\n', '\r'};
|
||||
|
||||
/// <summary> File name where info is stored </summary>
|
||||
private const string AppInfoFileName = "AppInfo.cs";
|
||||
|
||||
public int callbackOrder {
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
void UnityEditor.Build.IPreprocessBuild.OnPreprocessBuild(UnityEditor.BuildTarget target, string path) {
|
||||
var scriptPath = GetScriptPath(AppInfoFileName);
|
||||
var version = IncVersion();
|
||||
var time = DateTime.UtcNow;
|
||||
string date = "new DateTime(" + time.ToString("yyyy, MM, dd, HH, mm, ss, fff") + ", DateTimeKind.Utc)";
|
||||
|
||||
UnityEngine.Debug.LogFormat(
|
||||
"OnPreprocessBuild. Modify AppInfo in file={0}, set version={1} and current DateTime",
|
||||
scriptPath, version);
|
||||
|
||||
var text = System.IO.File.ReadAllText(scriptPath);
|
||||
text = ReplaceText(text, " Version = ", "\"" + version + "\";");
|
||||
text = ReplaceText(text, " Date = ", date + ";");
|
||||
System.IO.File.WriteAllText(scriptPath, text);
|
||||
}
|
||||
|
||||
private static string ReplaceText(string text, string field, string newValue) {
|
||||
int v1 = text.IndexOf(field, StringComparison.Ordinal);
|
||||
int v2 = text.IndexOfAny(LineDelimiter, v1);
|
||||
if (v1 < 0 || v2 < 0)
|
||||
throw new Exception("Undefined field=" + field);
|
||||
return text.Substring(0, v1 + field.Length) + newValue + text.Substring(v2);
|
||||
}
|
||||
|
||||
private static string IncVersion() {
|
||||
var bundleVersionSplit = UnityEditor.PlayerSettings.bundleVersion.Split('.');
|
||||
int major = 0;
|
||||
int minor = 0;
|
||||
int subVersion = 0;
|
||||
if (bundleVersionSplit.Length >= 1)
|
||||
int.TryParse(bundleVersionSplit[0], out major);
|
||||
if (bundleVersionSplit.Length >= 2)
|
||||
int.TryParse(bundleVersionSplit[1], out minor);
|
||||
if (bundleVersionSplit.Length >= 3)
|
||||
int.TryParse(bundleVersionSplit[2], out subVersion);
|
||||
++subVersion;
|
||||
string version = string.Format("{0}.{1}.{2}", major, minor, subVersion);
|
||||
var bundleVersionCode = (major * 100000) + (minor * 1000) + subVersion;
|
||||
|
||||
UnityEditor.PlayerSettings.bundleVersion = version;
|
||||
UnityEditor.PlayerSettings.Android.bundleVersionCode = bundleVersionCode;
|
||||
UnityEditor.PlayerSettings.macOS.buildNumber = bundleVersionCode.ToString();
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
private static string GetScriptPath(string fileName) {
|
||||
var assets = UnityEditor.AssetDatabase.FindAssets(System.IO.Path.GetFileNameWithoutExtension(fileName));
|
||||
string scriptPath = null;
|
||||
foreach (var asset in assets) {
|
||||
var path = UnityEditor.AssetDatabase.GUIDToAssetPath(asset);
|
||||
if (path.EndsWith(".cs")) {
|
||||
scriptPath = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(scriptPath))
|
||||
throw new Exception("No asset file with name '" + AppInfoFileName + "' found");
|
||||
|
||||
return scriptPath;
|
||||
}
|
||||
}
|
||||
#endif
|
11
Assets/Scripts/AppInfo.cs.meta
Normal file
11
Assets/Scripts/AppInfo.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83e98af10f553934381dd35ab8fe3e57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -11,6 +11,8 @@ namespace HeavenStudio
|
||||
{
|
||||
public static GlobalGameManager instance { get; set; }
|
||||
|
||||
public static string buildTime = "00/00/0000 00:00:00";
|
||||
|
||||
public static int loadedScene;
|
||||
public int lastLoadedScene;
|
||||
public static float fadeDuration;
|
||||
@ -61,6 +63,11 @@ namespace HeavenStudio
|
||||
Starpelly.OS.ChangeWindowTitle("Heaven Studio DEMO");
|
||||
QualitySettings.maxQueuedFrames = 1;
|
||||
PlayerInput.InitInputControllers();
|
||||
#if UNITY_EDITOR
|
||||
buildTime = "(EDITOR) " + System.DateTime.UtcNow.ToString("dd/MM/yyyy hh:mm:ss");
|
||||
#else
|
||||
buildTime = AppInfo.Date.ToString("dd/MM/yyyy hh:mm:ss");
|
||||
#endif
|
||||
}
|
||||
|
||||
public static GameObject CreateFade()
|
||||
|
@ -12,8 +12,8 @@ namespace HeavenStudio.Editor
|
||||
[SerializeField] protected GameObject dialog;
|
||||
public void ForceState(bool onoff = false)
|
||||
{
|
||||
Editor.instance.canSelect = onoff;
|
||||
Editor.instance.inAuthorativeMenu = !onoff;
|
||||
Editor.instance.canSelect = !onoff;
|
||||
Editor.instance.inAuthorativeMenu = onoff;
|
||||
dialog.SetActive(onoff);
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ namespace HeavenStudio.Editor
|
||||
[Header("Components")]
|
||||
[SerializeField] private Timeline Timeline;
|
||||
[SerializeField] private TMP_Text GameEventSelectorTitle;
|
||||
[SerializeField] private TMP_Text BuildDateDisplay;
|
||||
|
||||
[Header("Toolbar")]
|
||||
[SerializeField] private Button NewBTN;
|
||||
@ -123,6 +124,8 @@ namespace HeavenStudio.Editor
|
||||
|
||||
Tooltip.AddTooltip(EditorSettingsBTN.gameObject, "Editor Settings <color=#adadad>[Ctrl+Shift+O]</color>");
|
||||
UpdateEditorStatus(true);
|
||||
|
||||
BuildDateDisplay.text = GlobalGameManager.buildTime;
|
||||
}
|
||||
|
||||
public void LateUpdate()
|
||||
|
@ -1,14 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using HeavenStudio.Editor.Track;
|
||||
|
||||
using TMPro;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class SettingsDialog : Dialog
|
||||
{
|
||||
[SerializeField] private TMP_Text BuildDateDisplay;
|
||||
private void Start() {}
|
||||
|
||||
public void SwitchSettingsDialog()
|
||||
@ -22,6 +19,8 @@ namespace HeavenStudio.Editor
|
||||
Editor.instance.canSelect = false;
|
||||
Editor.instance.inAuthorativeMenu = true;
|
||||
dialog.SetActive(true);
|
||||
|
||||
BuildDateDisplay.text = GlobalGameManager.buildTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user