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. 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 ## [2.2.1-preview] - 2024-07-10
统一了所有PlayMode的初始化逻辑EditorSimulateMode和OfflinePlayMode初始化不再主动加载资源清单 统一了所有PlayMode的初始化逻辑EditorSimulateMode和OfflinePlayMode初始化不再主动加载资源清单

View File

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

View File

@@ -560,6 +560,21 @@ namespace YooAsset.Editor
return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式 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> /// <summary>
/// 获取项目工程路径 /// 获取项目工程路径
/// </summary> /// </summary>

View File

@@ -5,7 +5,7 @@ using UnityEngine;
namespace YooAsset namespace YooAsset
{ {
internal class DefaultBuildinFileSystemBuild : UnityEditor.Build.IPreprocessBuildWithReport public class DefaultBuildinFileSystemBuild : UnityEditor.Build.IPreprocessBuildWithReport
{ {
public int callbackOrder { get { return 0; } } public int callbackOrder { get { return 0; } }
@@ -90,7 +90,8 @@ namespace YooAsset
foreach (var fileInfo in fileInfos) foreach (var fileInfo in fileInfos)
{ {
if (fileInfo.Extension == ".meta" || fileInfo.Extension == ".version" || if (fileInfo.Extension == ".meta" || fileInfo.Extension == ".version" ||
fileInfo.Extension == ".hash" || fileInfo.Extension == ".bytes") fileInfo.Extension == ".hash" || fileInfo.Extension == ".bytes" ||
fileInfo.Extension == ".json")
continue; continue;
string fileName = fileInfo.Name; string fileName = fileInfo.Name;
@@ -109,8 +110,12 @@ namespace YooAsset
FileUtility.CreateFileDirectory(saveFilePath); FileUtility.CreateFileDirectory(saveFilePath);
UnityEditor.AssetDatabase.CreateAsset(buildinFileCatalog, saveFilePath); UnityEditor.AssetDatabase.CreateAsset(buildinFileCatalog, saveFilePath);
UnityEditor.EditorUtility.SetDirty(buildinFileCatalog);
#if UNITY_2019
UnityEditor.AssetDatabase.SaveAssets(); UnityEditor.AssetDatabase.SaveAssets();
UnityEditor.AssetDatabase.Refresh(); #else
UnityEditor.AssetDatabase.SaveAssetIfDirty(buildinFileCatalog);
#endif
Debug.Log($"Succeed to save buildin file catalog : {saveFilePath}"); Debug.Log($"Succeed to save buildin file catalog : {saveFilePath}");
} }
} }

View File

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

View File

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

View File

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

View File

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