Skip to content

Commit

Permalink
Merge pull request #61 from PassivePicasso/asynchronous-pipeline-impl…
Browse files Browse the repository at this point in the history
…emenetation

Merge Asynchronous Pipeline update into Master
  • Loading branch information
PassivePicasso authored Oct 17, 2021
2 parents 79eef0a + 4398f84 commit 05ae02e
Show file tree
Hide file tree
Showing 88 changed files with 1,082 additions and 539 deletions.
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
## 4.0.0

### Important

This update is breaking support for .NET 3.5 due to the difficulty in providing functional tools for certain aspects of Unity which are asynchronous.
For people who need .NET 3.5 support, install ThunderKit using the net35compatibility branch which will receive fixes able to be ported upon request

`"com.passivepicasso.thunderkit":"https://github.com/PassivePicasso/ThunderKit.git#net35compatibility",`

This update changes how Manifest assets in the Unity AssetDatabase are managed. You will be asked to run an upgrade process that will update all your Manifests to the new configuration automatically.
Please make sure you back up your projects before updating in case of any problems.

Some games do not have their Unity game version properly identified in their executable. Due to this, ThunderKit will now read the games globalgamemanager file to identify the correct Unity version for the game. Some users may find they need to switch unity versions because of this change, but it is a necessary step to take to avoid unforseen issues.

### Known Issues

* Unity 2021.2.0b7 does not detect package installation or uninstallation automatically requiring the user to manually refresh the Project
This is an issue which appears to be a bug with Unity's AssetDatabase.Refresh call and a bug report will be generated for Unity Technologies to investigate.
This bug may be resolved in newer versions of the Unity 2021.2 beta, however there are no games available to test against which wouldn't introduce factors that could muddle results.
If Unity doesn't appear to import packages installed from Thunderstore, or doesn't appear to fully remove an uninstalled package, refresh your project using the context menu option in the Project window, or on windows press Ctrl+R

* Unity 2021.2.0b7 locks up when importing and loading assemblies from packages or games.
- Work-around: Kill the Unity process after it seems like the import process has stopped loading new assemblies and restart Unity

### Improvements

* Unity 2021.2 beta can now succesfully install packages, however the user must manually refresh the project (Ctrl+R) to complete the installation.

* Pipelines and PipelineJobs now execute asynchronously to support operations which require that Unity take control of processing.

* StageAssemblies previously relied on simply copying assemblies from the project's Library/ScriptAssemblies folder. While fast and convenient this prevented users from taking control of build parameters which may be necessary for their projects. StageAssemblies now allows you to specify Build Targets and Build Target Groups in addition to allowing you to stage debug databases. Due to this change StageAssemblies now builds player assemblies, allowing the utilization of available optimization steps the compilation engine provides.

* Package Installation has been improved to no longer utilize the AssetDatabase to create and place files to avoid edge cases with some versions of Unity that prevent installation. Due to this change Manifest's now have Asset GUIDs assigned by ThunderKit. This change ensures that Manifest's will easily and automatically reference their dependencies, and references to dependencies will continue to work after reinstallation them. This change is not backwards compatible

* Added compiler directives and code to support Unity 2021.2

* Add a utility to assist in migrating Non-ThunderKit modding projects to ThunderKit by updating asset references from Dll references to Script file references. This is available under Tools/ThunderKit/Migration

* Added error messaging for PathReferences and Manifests

### Fixes and Changes

* Fix cases where Progress bars may not update or close as expected
* Fix ManifestIdentities not always being saved during package installation
* Fix issue where somtimes PackageSourceSettings will empty its reference array requiring manual repopulation
* Fix PackageManager not removing Scripting Defines when removing a ThunderKit managed Package

## 3.4.1

## Fixes
Expand Down
8 changes: 0 additions & 8 deletions Editor/BuildAssets/Manifests.meta

This file was deleted.

32 changes: 0 additions & 32 deletions Editor/BuildAssets/Manifests/ThunderKitInstaller.asset

This file was deleted.

8 changes: 0 additions & 8 deletions Editor/BuildAssets/Manifests/ThunderKitInstaller.asset.meta

This file was deleted.

8 changes: 0 additions & 8 deletions Editor/BuildAssets/Pipelines.meta

This file was deleted.

30 changes: 0 additions & 30 deletions Editor/BuildAssets/Pipelines/DeployThunderKitInstaller.asset

This file was deleted.

8 changes: 0 additions & 8 deletions Editor/BuildAssets/UnityPackages.meta

This file was deleted.

18 changes: 0 additions & 18 deletions Editor/BuildAssets/UnityPackages/ThunderKitInstaller.asset

This file was deleted.

4 changes: 2 additions & 2 deletions Editor/Common/FileIdUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ private static uint Round3Operation(uint a, uint b, uint c, uint d, uint xk, int

public static class FileIdUtil
{
public static int Compute(Type t)
public static long Compute(Type t)
{
string toBeHashed = "s\0\0\0" + t.Namespace + t.Name;

using (HashAlgorithm hash = new MD4())
{
byte[] hashed = hash.ComputeHash(System.Text.Encoding.UTF8.GetBytes(toBeHashed));

int result = 0;
long result = 0;

for (int i = 3; i >= 0; --i)
{
Expand Down
3 changes: 3 additions & 0 deletions Editor/Common/InstallThunderKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class InstallThunderKit
static void IdentifyThunderKit()
{
AddScriptingDefine("thunderkit");
#if UNITY_2021_1_OR_NEWER
EditorPrefs.SetBool("DirectoryMonitoring", false);
#endif
}

static bool IsObsolete(BuildTargetGroup group)
Expand Down
26 changes: 16 additions & 10 deletions Editor/Common/Package/PackageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@
using ThunderKit.Common.Configuration;
using UnityEditor;
using UnityEngine;
using UnityEngine.Networking;

namespace ThunderKit.Common.Package
{
public static class PackageHelper
{
public static void GeneratePackageManifest(string packageName, string outputDir, string modName, string authorAlias, string modVersion, string description = null)
public static void GeneratePackageManifest(string packageName, string outputDir, string displayName, string authorAlias, string modVersion, string description = null)
{
string unityVersion = Application.unityVersion.Substring(0, Application.unityVersion.LastIndexOf("."));
var author = new Author
{
name = authorAlias,
};
var packageManifest = new PackageManagerManifest(author, packageName, ObjectNames.NicifyVariableName(modName), modVersion, unityVersion, description);
var packageManifest = new PackageManagerManifest(author, packageName, ObjectNames.NicifyVariableName(displayName), modVersion, unityVersion, description);
var packageManifestJson = JsonUtility.ToJson(packageManifest);
ScriptingSymbolManager.AddScriptingDefine(packageName);
File.WriteAllText(Path.Combine(outputDir, "package.json"), packageManifestJson);

string fullOutputPath = Path.Combine(outputDir, "package.json");
if (File.Exists(fullOutputPath)) File.Delete(fullOutputPath);
File.WriteAllText(fullOutputPath, packageManifestJson);
}

public static PackageManagerManifest GetPackageManagerManifest(string directory)
Expand Down Expand Up @@ -50,23 +52,27 @@ public static void WriteAssemblyMetaData(string assemblyPath, string metadataPat
/// </summary>
/// <param name="assemblyPath">Path to asset to generate meta file for</param>
/// <param name="metadataPath">Path to write meta file to</param>
public static void WriteAssetMetaData(string assetPath)
public static void WriteAssetMetaData(string assetPath, string guid = null)
{
string guid = GetFileNameHash(assetPath);
string metaData = DefaultAssemblyMetaData(guid);
guid = guid ?? GetFileNameHash(assetPath);
string metaData = DefaultScriptableObjectMetaData(guid);

var metadataPath = $"{assetPath}.meta";
if (File.Exists(metadataPath)) File.Delete(metadataPath);
File.WriteAllText(metadataPath, metaData);

}

public static string GetFileNameHash(string assemblyPath)
{
string shortName = Path.GetFileNameWithoutExtension(assemblyPath);
return GetStringHash(shortName);
}

public static string GetStringHash(string value)
{
using (var md5 = MD5.Create())
{
string shortName = Path.GetFileNameWithoutExtension(assemblyPath);
byte[] shortNameBytes = Encoding.Default.GetBytes(shortName);
byte[] shortNameBytes = Encoding.Default.GetBytes(value);
var shortNameHash = md5.ComputeHash(shortNameBytes);
var guid = new Guid(shortNameHash);
var cleanedGuid = guid.ToString().ToLower().Replace("-", "");
Expand Down
12 changes: 7 additions & 5 deletions Editor/Common/ProgressBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@ namespace ThunderKit.Common.Logging
{
public class ProgressBar : IDisposable
{
public ProgressBar(string title)
public ProgressBar(string title = null)
{
EditorUtility.DisplayProgressBar(title, $"", 0);
Title = title;
}

public string Title { get; }
public string Title { get; private set; }
public string Message { get; private set; }

public void Dispose()
{
EditorUtility.ClearProgressBar();
}

public void Update(string message, string title = null, float progress = 0)
public void Update(string message = null, string title = null, float progress = 0)
{
title = title ?? Title;
EditorUtility.DisplayProgressBar(Title, message, progress);
Title = title ?? Title;
Message = message ?? Message;
EditorUtility.DisplayProgressBar(Title, Message, progress);
}
}
}
2 changes: 1 addition & 1 deletion Editor/Core/Actions/DeletePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using UnityEditor;
using UnityEngine;

namespace ThunderKit.Core.Editor.Actions
namespace ThunderKit.Core.Actions
{
public class DeletePackage : ScriptableObject
{
Expand Down
2 changes: 1 addition & 1 deletion Editor/Core/Actions/SelfDestructingActionAsset.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using UnityEditor.ProjectWindowCallback;

namespace ThunderKit.Core.Editor.Actions
namespace ThunderKit.Core.Actions
{
public class SelfDestructingActionAsset : EndNameEditAction
{
Expand Down
2 changes: 2 additions & 0 deletions Editor/Core/ComposableElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class ComposableElement : ScriptableObject
public bool Errored;
[HideInInspector]
public string ErrorMessage;
[HideInInspector]
public string ErrorStacktrace;

private void Awake()
{
Expand Down
Loading

0 comments on commit 05ae02e

Please sign in to comment.