mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +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.
|
||||
|
||||
## [2.2.2-preview] - 2024-07-31
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#321) 修复了在Unity2022里编辑器下离线模式运行失败的问题。
|
||||
- (#325) 修复了在Unity2019里编译报错问题。
|
||||
|
||||
## [2.2.1-preview] - 2024-07-10
|
||||
|
||||
统一了所有PlayMode的初始化逻辑,EditorSimulateMode和OfflinePlayMode初始化不再主动加载资源清单!
|
||||
|
||||
@@ -3,6 +3,6 @@ namespace YooAsset.Editor
|
||||
{
|
||||
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路径格式
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// 获取项目工程路径
|
||||
|
||||
@@ -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}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user