Compare commits

..

7 Commits

Author SHA1 Message Date
hevinci
b421e7d2f8 Update CHANGELOG.md 2024-07-31 12:06:23 +08:00
hevinci
0e7c14abde Update package.json 2024-07-31 12:06:15 +08:00
hevinci
caf072ed9b Update DefaultBuildinFileSystemBuild.cs 2024-07-31 12:02:07 +08:00
hevinci
51f2709956 Update EditorTools.cs 2024-07-31 12:01:29 +08:00
hevinci
6680a6450b fix #325
适配unity2019引擎
2024-07-24 10:12:42 +08:00
hevinci
dc119b26c7 fix #321 2024-07-19 12:02:43 +08:00
hevinci
2cbfca4f3b update extension sample
着色器变种文件增加内部排序
2024-07-15 18:51:32 +08:00
8 changed files with 96 additions and 34 deletions

View File

@@ -2,6 +2,13 @@
All notable changes to this package will be documented in this file.
## [2.2.2-preview] - 2024-07-31
### Fixed
- (#321) 修复了在Unity2022里编辑器下离线模式运行失败的问题。
- (#325) 修复了在Unity2019里编译报错问题。
## [2.2.1-preview] - 2024-07-10
统一了所有PlayMode的初始化逻辑EditorSimulateMode和OfflinePlayMode初始化不再主动加载资源清单

View File

@@ -3,6 +3,6 @@ namespace YooAsset.Editor
{
public interface IBuildPipeline
{
public BuildResult Run(BuildParameters buildParameters, bool enableLog);
BuildResult Run(BuildParameters buildParameters, bool enableLog);
}
}

View File

@@ -559,6 +559,21 @@ namespace YooAsset.Editor
{
return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式
}
/// <summary>
/// 移除路径里的后缀名
/// </summary>
public static string RemoveExtension(string str)
{
if (string.IsNullOrEmpty(str))
return str;
int index = str.LastIndexOf('.');
if (index == -1)
return str;
else
return str.Remove(index); //"assets/config/test.unity3d" --> "assets/config/test"
}
/// <summary>
/// 获取项目工程路径

View File

@@ -5,7 +5,7 @@ using UnityEngine;
namespace YooAsset
{
internal class DefaultBuildinFileSystemBuild : UnityEditor.Build.IPreprocessBuildWithReport
public class DefaultBuildinFileSystemBuild : UnityEditor.Build.IPreprocessBuildWithReport
{
public int callbackOrder { get { return 0; } }
@@ -35,7 +35,7 @@ namespace YooAsset
CreateBuildinCatalogFile(subDirectory.Name, subDirectory.FullName);
}
}
/// <summary>
/// 生成包裹的内置资源目录文件
/// </summary>
@@ -90,7 +90,8 @@ namespace YooAsset
foreach (var fileInfo in fileInfos)
{
if (fileInfo.Extension == ".meta" || fileInfo.Extension == ".version" ||
fileInfo.Extension == ".hash" || fileInfo.Extension == ".bytes")
fileInfo.Extension == ".hash" || fileInfo.Extension == ".bytes" ||
fileInfo.Extension == ".json")
continue;
string fileName = fileInfo.Name;
@@ -109,8 +110,12 @@ namespace YooAsset
FileUtility.CreateFileDirectory(saveFilePath);
UnityEditor.AssetDatabase.CreateAsset(buildinFileCatalog, saveFilePath);
UnityEditor.EditorUtility.SetDirty(buildinFileCatalog);
#if UNITY_2019
UnityEditor.AssetDatabase.SaveAssets();
UnityEditor.AssetDatabase.Refresh();
#else
UnityEditor.AssetDatabase.SaveAssetIfDirty(buildinFileCatalog);
#endif
Debug.Log($"Succeed to save buildin file catalog : {saveFilePath}");
}
}

View File

@@ -11,8 +11,10 @@ using UnityEditor;
public class ShaderVariantCollectionManifest
{
[Serializable]
public class ShaderVariantElement
public class ShaderVariantElement : IComparable<ShaderVariantElement>
{
public string SortValue { private set; get; }
/// <summary>
/// Pass type to use in this variant.
/// </summary>
@@ -22,11 +24,31 @@ public class ShaderVariantCollectionManifest
/// Array of shader keywords to use in this variant.
/// </summary>
public string[] Keywords;
public void MakeSortValue()
{
string combineKeyword = string.Empty;
for (int i = 0; i < Keywords.Length; i++)
{
if (i == 0)
combineKeyword = Keywords[0];
else
combineKeyword = $"{combineKeyword}+{Keywords[0]}";
}
SortValue = $"{PassType}+{combineKeyword}";
}
public int CompareTo(ShaderVariantElement other)
{
return SortValue.CompareTo(other.SortValue);
}
}
[Serializable]
public class ShaderVariantInfo : IComparable<ShaderVariantInfo>
{
public string SortValue { private set; get; }
/// <summary>
/// 着色器资源路径.
/// </summary>
@@ -47,11 +69,13 @@ public class ShaderVariantCollectionManifest
/// </summary>
public List<ShaderVariantElement> ShaderVariantElements = new List<ShaderVariantElement>(1000);
public void MakeSortValue()
{
SortValue = AssetPath + "+" + ShaderName;
}
public int CompareTo(ShaderVariantInfo other)
{
string thisStr = AssetPath + "+" +ShaderName;
string otherStr = other.AssetPath + "+" + other.ShaderName;
return thisStr.CompareTo(otherStr);
return SortValue.CompareTo(other.SortValue);
}
}
@@ -76,10 +100,15 @@ public class ShaderVariantCollectionManifest
/// </summary>
public void AddShaderVariant(string assetPath, string shaderName, PassType passType, string[] keywords)
{
// 排序Keyword列表
List<string> temper = new List<string>(keywords);
temper.Sort();
var info = GetOrCreateShaderVariantInfo(assetPath, shaderName);
ShaderVariantElement element = new ShaderVariantElement();
element.PassType = passType;
element.Keywords = keywords;
element.Keywords = temper.ToArray();
element.MakeSortValue();
info.ShaderVariantElements.Add(element);
info.ShaderVariantCount++;
}
@@ -91,6 +120,7 @@ public class ShaderVariantCollectionManifest
ShaderVariantInfo newInfo = new ShaderVariantInfo();
newInfo.AssetPath = assetPath;
newInfo.ShaderName = shaderName;
newInfo.MakeSortValue();
ShaderVariantInfos.Add(newInfo);
return newInfo;
}
@@ -150,6 +180,11 @@ public class ShaderVariantCollectionManifest
// 重新排序
manifest.ShaderVariantInfos.Sort();
foreach (var shaderVariantInfo in manifest.ShaderVariantInfos)
{
shaderVariantInfo.ShaderVariantElements.Sort();
}
return manifest;
}
}

View File

@@ -21,8 +21,8 @@ public static class ShaderVariantCollector
WaitingDone,
}
private const float WaitMilliseconds = 1000f;
private const float SleepMilliseconds = 2000f;
private const float WaitMilliseconds = 3000f;
private const float SleepMilliseconds = 3000f;
private static string _savePath;
private static string _packageName;
private static int _processMaxNum;

View File

@@ -100,12 +100,12 @@ public class BattleRoom
if (_startWaitTimer.Update(Time.deltaTime))
{
// 生成实体
var handle = YooAssets.LoadAssetAsync<GameObject>("player_ship");
handle.Completed += (AssetHandle handle) =>
var assetHandle = YooAssets.LoadAssetAsync<GameObject>("player_ship");
assetHandle.Completed += (AssetHandle handle) =>
{
handle.InstantiateSync(_roomRoot.transform);
};
_handles.Add(handle);
_handles.Add(assetHandle);
_steps = ESteps.SpawnEnemy;
}
}
@@ -117,12 +117,12 @@ public class BattleRoom
Quaternion spawnRotation = Quaternion.identity;
// 生成实体
var handle = YooAssets.LoadAssetAsync<GameObject>(enemyLocation);
handle.Completed += (AssetHandle handle) =>
var assetHandle = YooAssets.LoadAssetAsync<GameObject>(enemyLocation);
assetHandle.Completed += (AssetHandle handle) =>
{
handle.InstantiateSync(spawnPosition, spawnRotation, _roomRoot.transform);
};
_handles.Add(handle);
_handles.Add(assetHandle);
_waveSpawnCount++;
if (_waveSpawnCount >= EnemyCount)
@@ -166,12 +166,12 @@ public class BattleRoom
var msg = message as BattleEventDefine.PlayerDead;
// 创建爆炸效果
var handle = YooAssets.LoadAssetAsync<GameObject>("explosion_player");
handle.Completed += (AssetHandle handle) =>
var assetHandle = YooAssets.LoadAssetAsync<GameObject>("explosion_player");
assetHandle.Completed += (AssetHandle handle) =>
{
handle.InstantiateSync(msg.Position, msg.Rotation, _roomRoot.transform);
};
_handles.Add(handle);
_handles.Add(assetHandle);
_steps = ESteps.GameOver;
BattleEventDefine.GameOver.SendEventMessage();
@@ -181,12 +181,12 @@ public class BattleRoom
var msg = message as BattleEventDefine.EnemyDead;
// 创建爆炸效果
var handle = YooAssets.LoadAssetAsync<GameObject>("explosion_enemy");
handle.Completed += (AssetHandle handle) =>
var assetHandle = YooAssets.LoadAssetAsync<GameObject>("explosion_enemy");
assetHandle.Completed += (AssetHandle handle) =>
{
handle.InstantiateSync(msg.Position, msg.Rotation, _roomRoot.transform);
};
_handles.Add(handle);
_handles.Add(assetHandle);
_totalScore += EnemyScore;
BattleEventDefine.ScoreChange.SendEventMessage(_totalScore);
@@ -196,12 +196,12 @@ public class BattleRoom
var msg = message as BattleEventDefine.AsteroidExplosion;
// 创建爆炸效果
var handle = YooAssets.LoadAssetAsync<GameObject>("explosion_asteroid");
handle.Completed += (AssetHandle handle) =>
var assetHandle = YooAssets.LoadAssetAsync<GameObject>("explosion_asteroid");
assetHandle.Completed += (AssetHandle handle) =>
{
handle.InstantiateSync(msg.Position, msg.Rotation, _roomRoot.transform);
};
_handles.Add(handle);
_handles.Add(assetHandle);
_totalScore += AsteroidScore;
BattleEventDefine.ScoreChange.SendEventMessage(_totalScore);
@@ -211,24 +211,24 @@ public class BattleRoom
var msg = message as BattleEventDefine.PlayerFireBullet;
// 创建子弹实体
var handle = YooAssets.LoadAssetAsync<GameObject>("player_bullet");
handle.Completed += (AssetHandle handle) =>
var assetHandle = YooAssets.LoadAssetAsync<GameObject>("player_bullet");
assetHandle.Completed += (AssetHandle handle) =>
{
handle.InstantiateSync(msg.Position, msg.Rotation, _roomRoot.transform);
};
_handles.Add(handle);
_handles.Add(assetHandle);
}
else if (message is BattleEventDefine.EnemyFireBullet)
{
var msg = message as BattleEventDefine.EnemyFireBullet;
// 创建子弹实体
var handle = YooAssets.LoadAssetAsync<GameObject>("enemy_bullet");
handle.Completed += (AssetHandle handle) =>
var assetHandle = YooAssets.LoadAssetAsync<GameObject>("enemy_bullet");
assetHandle.Completed += (AssetHandle handle) =>
{
handle.InstantiateSync(msg.Position, msg.Rotation, _roomRoot.transform);
};
_handles.Add(handle);
_handles.Add(assetHandle);
}
}
}

View File

@@ -1,7 +1,7 @@
{
"name": "com.tuyoogame.yooasset",
"displayName": "YooAsset",
"version": "2.2.1-preview",
"version": "2.2.2-preview",
"unity": "2019.4",
"description": "unity3d resources management system.",
"author": {