mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-19 06:40:21 +00:00
Compare commits
7 Commits
2.2.1-prev
...
2.2.2-prev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b421e7d2f8 | ||
|
|
0e7c14abde | ||
|
|
caf072ed9b | ||
|
|
51f2709956 | ||
|
|
6680a6450b | ||
|
|
dc119b26c7 | ||
|
|
2cbfca4f3b |
@@ -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初始化不再主动加载资源清单!
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -559,6 +559,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>
|
||||||
/// 获取项目工程路径
|
/// 获取项目工程路径
|
||||||
|
|||||||
@@ -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; } }
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ namespace YooAsset
|
|||||||
CreateBuildinCatalogFile(subDirectory.Name, subDirectory.FullName);
|
CreateBuildinCatalogFile(subDirectory.Name, subDirectory.FullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成包裹的内置资源目录文件
|
/// 生成包裹的内置资源目录文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -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}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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": {
|
||||||
|
|||||||
Reference in New Issue
Block a user