Skip to content

Commit

Permalink
Release 11.4.1
Browse files Browse the repository at this point in the history
UnityAidas committed May 10, 2024
1 parent d7674e6 commit 6f074eb
Showing 13 changed files with 168 additions and 15 deletions.
8 changes: 8 additions & 0 deletions com.unity.asset-store-tools/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog
All notable changes to this package will be documented in this file.

## [11.4.1] - 2024-05-10

### Exporter Changes
- Fixed an issue with bundled plugin folder contents not being exported

### Other
- Miscellaneous internal changes

## [11.4.0] - 2024-01-23

### Uploader Changes
3 changes: 2 additions & 1 deletion com.unity.asset-store-tools/Editor/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Unity.AssetStoreTools.Editor.Tests.asmdef")]
[assembly: InternalsVisibleTo("ab-builder")]
[assembly: InternalsVisibleTo("ab-builder")]
[assembly: InternalsVisibleTo("Inspector-Editor")]
14 changes: 13 additions & 1 deletion com.unity.asset-store-tools/Editor/Exporter/PackageExporter.cs
Original file line number Diff line number Diff line change
@@ -15,6 +15,8 @@ internal abstract class PackageExporter
protected const string ProgressBarStepGatheringFiles = "Gathering files...";
protected const string ProgressBarStepCompressingPackage = "Compressing package...";

private static readonly string[] PluginFolderExtensions = { "androidlib", "bundle", "plugin", "framework", "xcframework" };

public static async Task<ExportResult> ExportPackage(ExporterSettings exportSettings)
{
if (!IsSettingsValid(exportSettings, out Exception e))
@@ -68,7 +70,7 @@ protected string[] GetAssetPaths(string rootPath)
return paths.ToArray();
}

protected string GetAssetGuid(string assetPath, bool hiddenSearch)
protected string GetAssetGuid(string assetPath, bool generateForPlugin, bool hiddenSearch)
{
// Skip meta files as they do not have guids
if (assetPath.EndsWith(".meta"))
@@ -89,6 +91,11 @@ protected string GetAssetGuid(string assetPath, bool hiddenSearch)
if (guid != string.Empty)
return guid;

// Some special folders (e.g. SomeName.framework) do not have meta files inside them.
// Their contents should be exported with any arbitrary GUID so that Unity Importer could pick them up
if (generateForPlugin && PathBelongsToPlugin(assetPath))
return GUID.Generate().ToString();

// Files in hidden folders (e.g. Samples~) are not part of the Asset Database,
// therefore GUIDs need to be scraped from the .meta file.
// Note: only do this for custom exporter since the native exporter
@@ -117,6 +124,11 @@ protected string GetAssetGuid(string assetPath, bool hiddenSearch)
return string.Empty;
}

private bool PathBelongsToPlugin(string assetPath)
{
return PluginFolderExtensions.Any(extension => assetPath.ToLower().Contains($".{extension}/"));
}

protected virtual void PostExportCleanup()
{
EditorUtility.ClearProgressBar();
Original file line number Diff line number Diff line change
@@ -159,7 +159,7 @@ private Dictionary<string, string> GetPathGuidPairs(string[] exportPaths)

foreach (var assetPath in assetPaths)
{
var guid = GetAssetGuid(assetPath, true);
var guid = GetAssetGuid(assetPath, true, true);
if (string.IsNullOrEmpty(guid))
continue;

Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ private string[] GetGuids(string[] exportPaths, out bool onlyFolders)

foreach (var assetPath in assetPaths)
{
var guid = GetAssetGuid(assetPath, false);
var guid = GetAssetGuid(assetPath, false, false);
if (string.IsNullOrEmpty(guid))
continue;

Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ namespace AssetStoreTools.Uploader
/// </summary>
internal static class AssetStoreAPI
{
public const string ToolVersion = "V6.4.0";
public const string ToolVersion = "V6.4.1";

private const string UnauthSessionId = "26c4202eb475d02864b40827dfff11a14657aa41";
private const string KharmaSessionId = "kharma.sessionid";
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ private static async Task CheckForUpdates(Action<bool, Version, Version> OnUpdat
try
{
var latestVersionStr = latestVersionResult.Response["version"].AsString();
var currentVersionStr = PackageUtility.GetAllLocalPackages().FirstOrDefault(x => x.name == "com.unity.asset-store-tools").version;
var currentVersionStr = PackageUtility.GetAllPackages().FirstOrDefault(x => x.name == "com.unity.asset-store-tools").version;

currentVersion = new Version(currentVersionStr);
latestVersion = new Version(latestVersionStr);
Original file line number Diff line number Diff line change
@@ -32,13 +32,28 @@ public void AddMessage(string msg, IMessageAction clickAction, params UnityEngin
Messages = new List<TestResultMessage>();

var message = new TestResultMessage(msg, clickAction);
if (messageObjects != null)
foreach (var obj in messageObjects)
message.AddMessageObject(obj);

AddMessageObjects(messageObjects, message);
Messages.Add(message);
}

private void AddMessageObjects(Object[] messageObjects, TestResultMessage message)
{
if (messageObjects == null)
return;

foreach (var obj in messageObjects)
{
#if AB_BUILDER
string path = AssetDatabase.GetAssetPath(obj);
message.AppendText($"\nAsset at: {path}");
#else
message.AddMessageObject(obj);
#endif

}
}


public TestResultMessage GetMessage(int index)
{
if (Messages == null || index >= Messages.Count)
@@ -144,6 +159,11 @@ public void OnAfterDeserialize()
}
}

public void AppendText(string value)
{
Text += value;
}

public string GetText()
{
return Text;
Original file line number Diff line number Diff line change
@@ -86,6 +86,9 @@ public ValidationResult RunAllTests(ValidationSettings settings)
test.Result.Result = updatedStatus;

ValidationState.Instance.ChangeResult(test.Id, test.Result);
#if AB_BUILDER
EditorUtility.UnloadUnusedAssetsImmediate();
#endif
}

EditorUtility.UnloadUnusedAssetsImmediate();
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using AssetStoreTools.Validator.Data;
using AssetStoreTools.Validator.TestDefinitions;
using AssetStoreTools.Validator.TestMethods.Utility;
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityObject = UnityEngine.Object;

namespace AssetStoreTools.Validator.TestMethods
Original file line number Diff line number Diff line change
@@ -2,19 +2,23 @@
using AssetStoreTools.Validator.TestDefinitions;
using AssetStoreTools.Validator.TestMethods.Utility;
using System.Collections.Generic;
using System.Text;
using UnityEditor;
using UnityEngine;

namespace AssetStoreTools.Validator.TestMethods
{
internal class CheckNormalMapTextures : ITestScript
{
public const int TextureCacheLimit = 8;

public TestResult Run(ValidationTestConfig config)
{
var result = new TestResult() { Result = TestResult.ResultStatus.Undefined };

var materials = AssetUtility.GetObjectsFromAssets<Material>(config.ValidationPaths, AssetType.Material);
var badTextures = new List<Texture>();
var badPaths = new List<string>();

foreach (var mat in materials)
{
@@ -31,16 +35,42 @@ public TestResult Run(ValidationTestConfig config)
var texturePath = AssetUtility.ObjectToAssetPath(assignedTexture);
var textureImporter = (TextureImporter)AssetUtility.GetAssetImporter(texturePath);
if (textureImporter.textureType != TextureImporterType.NormalMap && !badTextures.Contains(assignedTexture))
badTextures.Add(assignedTexture);
{
if (badTextures.Count < TextureCacheLimit)
{
badTextures.Add(assignedTexture);
}
else
{
string path = AssetDatabase.GetAssetPath(assignedTexture);
badPaths.Add(path);
}
}
}
}
}

EditorUtility.UnloadUnusedAssetsImmediate();
}

if (badTextures.Count == 0)
{
result.Result = TestResult.ResultStatus.Pass;
result.AddMessage("All normal map textures have the correct texture type!");
}
else if(badPaths.Count != 0)
{
foreach (Texture texture in badTextures)
{
string path = AssetDatabase.GetAssetPath(texture);
badPaths.Add(path);
}

string paths = string.Join("\n", badPaths);

result.Result = TestResult.ResultStatus.VariableSeverityIssue;
result.AddMessage("The following textures are not set to type 'Normal Map'", null);
result.AddMessage(paths);
}
else
{
result.Result = TestResult.ResultStatus.VariableSeverityIssue;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AssetStoreTools.Utility;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -127,7 +128,11 @@ public static IEnumerable<string> GetAssetPathsFromAssets(string[] searchPaths,
public static IEnumerable<T> GetObjectsFromAssets<T>(string[] searchPaths, AssetType type) where T : UnityObject
{
var paths = GetAssetPathsFromAssets(searchPaths, type);
#if !AB_BUILDER
var objects = paths.Select(AssetDatabase.LoadAssetAtPath<T>).Where(x => x != null);
#else
var objects = new AssetEnumerator<T>(paths);
#endif
return objects;
}

@@ -227,4 +232,80 @@ public static AssetImporter GetAssetImporter(UnityObject asset)
return GetAssetImporter(ObjectToAssetPath(asset));
}
}

internal class AssetEnumerator<T> : IEnumerator<T>, IEnumerable<T> where T : UnityObject
{
public const int Capacity = 32;

private Queue<string> _pathQueue;
private Queue<T> _loadedAssetQueue;

private T _currentElement;

public AssetEnumerator(IEnumerable<string> paths)
{
_pathQueue = new Queue<string>(paths);
_loadedAssetQueue = new Queue<T>();
}

public bool MoveNext()
{
bool hasPathsButHasNoAssets = _pathQueue.Count != 0 && _loadedAssetQueue.Count == 0;
if (hasPathsButHasNoAssets)
{
LoadMore();
}

bool dequeued = false;
if (_loadedAssetQueue.Count != 0)
{
_currentElement = _loadedAssetQueue.Dequeue();
dequeued = true;
}

return dequeued;
}

private void LoadMore()
{
int limit = Capacity;
while (limit > 0 && _pathQueue.Count != 0)
{
string path = _pathQueue.Dequeue();
T asset = AssetDatabase.LoadAssetAtPath<T>(path);
if (asset != null)
{
_loadedAssetQueue.Enqueue(asset);
limit--;
}
}

// Unload other loose asset references
EditorUtility.UnloadUnusedAssetsImmediate();
}

public void Reset()
{
throw new NotSupportedException("Asset Enumerator cannot be reset.");
}

public T Current => _currentElement;

object IEnumerator.Current => Current;

public void Dispose()
{
// No need to dispose
}

IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return this;
}

public IEnumerator GetEnumerator()
{
return this;
}
}
}
2 changes: 1 addition & 1 deletion com.unity.asset-store-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.unity.asset-store-tools",
"displayName": "Asset Store Tools",
"version": "11.4.0",
"version": "11.4.1",
"unity": "2019.4",
"description": "Whether you're a programmer, game designer, texture artist or 3D modeler, you're welcome to share your creations with everybody in the Unity developer community!",
"type": "tool"

0 comments on commit 6f074eb

Please sign in to comment.