refactor(fix-system): 重构身体模块材质加载为Addressables异步流程
Made-with: Cursor
This commit is contained in:
@@ -15,7 +15,7 @@ MonoBehaviour:
|
||||
m_DefaultGroup: 09546aca93a801441859af2a811fe53b
|
||||
m_currentHash:
|
||||
serializedVersion: 2
|
||||
Hash: 00000000000000000000000000000000
|
||||
Hash: 0ff7da4bd5a9dda38dc01b11d13a8daf
|
||||
m_OptimizeCatalogSize: 0
|
||||
m_BuildRemoteCatalog: 0
|
||||
m_BundleLocalCatalog: 0
|
||||
|
||||
@@ -32,6 +32,16 @@ MonoBehaviour:
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: 2ad11187b3f2b9b4783d2891314b18cc
|
||||
m_Address: Material/HighlightMaterial
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: 191da4688baf1ea4aa8964e324d9d4a0
|
||||
m_Address: Material/AlarmMaterial
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
m_ReadOnly: 0
|
||||
m_Settings: {fileID: 11400000, guid: 77169ce22e430f64fb36c771815a4a7b, type: 2}
|
||||
m_SchemaSet:
|
||||
|
||||
@@ -5,5 +5,8 @@
|
||||
public const string EyeCoverOpenA = "Sprite/视觉模块盖子[视觉模块盖子打开A]";
|
||||
public const string EyeCoverOpenB = "Sprite/视觉模块盖子[视觉模块盖子打开B]";
|
||||
public const string EyeCoverClose = "Sprite/视觉模块盖子[视觉模块盖子关闭]";
|
||||
|
||||
public const string HighlightMaterial = "Material/HighlightMaterial";
|
||||
public const string AlarmMaterial = "Material/AlarmMaterial";
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,6 @@ namespace AibisDream.FixSystem
|
||||
private SpriteRenderer _cutSpriteRenderer;
|
||||
private SpriteRenderer _cutTextRenderer; // 添加cutText的SpriteRenderer引用
|
||||
|
||||
private CutLine _cutLine;
|
||||
|
||||
[Header("CutText闪烁效果")] private float cutTextFlickerThreshold = 0.4f; // 开始闪烁的阈值
|
||||
private float cutTextFlickerInterval = 0.1f; // 闪烁间隔
|
||||
private bool isCutTextFlickering = false; // 是否正在闪烁
|
||||
@@ -48,6 +46,7 @@ namespace AibisDream.FixSystem
|
||||
{
|
||||
// 获取组件索引
|
||||
InitReference();
|
||||
StartCoroutine(LoadMaterial());
|
||||
}
|
||||
|
||||
protected virtual void InitReference()
|
||||
@@ -71,9 +70,25 @@ namespace AibisDream.FixSystem
|
||||
_cutTextRenderer =
|
||||
_cutSpriteRenderer.transform.Find("Cut Text")?.GetComponent<SpriteRenderer>();
|
||||
}
|
||||
}
|
||||
|
||||
_highlightMaterial = Resources.Load<Material>("Materials/HighlightMaterial");
|
||||
_alarmMaterial = Resources.Load<Material>("Materials/AlarmMaterial");
|
||||
private IEnumerator LoadMaterial()
|
||||
{
|
||||
// 异步加载材质
|
||||
var highlightHandle = ResourceSystem.LoadAsync<Material>(FixAssetRef.HighlightMaterial);
|
||||
var alarmHandle = ResourceSystem.LoadAsync<Material>(FixAssetRef.AlarmMaterial);
|
||||
yield return highlightHandle;
|
||||
yield return alarmHandle;
|
||||
|
||||
if (highlightHandle.Status == UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationStatus.Succeeded)
|
||||
_highlightMaterial = highlightHandle.Result;
|
||||
else
|
||||
Debug.LogError("[BodyModule] Failed to load HighlightMaterial");
|
||||
|
||||
if (alarmHandle.Status == UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationStatus.Succeeded)
|
||||
_alarmMaterial = alarmHandle.Result;
|
||||
else
|
||||
Debug.LogError("[BodyModule] Failed to load AlarmMaterial");
|
||||
}
|
||||
|
||||
#region 插槽功能
|
||||
@@ -244,66 +259,6 @@ namespace AibisDream.FixSystem
|
||||
}
|
||||
}
|
||||
|
||||
// public void EnableCut()
|
||||
// {
|
||||
// // 打开或获取CutLine
|
||||
// ShowCutLine();
|
||||
// _cutLine.OnCuttingDown += OnCuttingDown;
|
||||
// _cutting = true;
|
||||
|
||||
// EnumEventSystem.Global.Send(EventEnum.CutStart);
|
||||
// }
|
||||
|
||||
// private void OnCut()
|
||||
// {
|
||||
// Vector2 mousePos = CommonUtil.GetMouseWorldPos(Input.mousePosition);
|
||||
// _cutLine.DetectLineClick(mousePos, clickRadius);
|
||||
// }
|
||||
|
||||
// private void OnCuttingDown()
|
||||
// {
|
||||
// _cutLine.OnCuttingDown -= OnCuttingDown;
|
||||
// _cutting = false;
|
||||
// // 模块脱落
|
||||
// _cutLine.HideLine();
|
||||
// _bodyModuleSystem.RemoveModule(this);
|
||||
// ActionKit.Sequence()
|
||||
// .Delay(0.8f)
|
||||
// .DOTween(() => transform.DOMoveY(ConstRef.TweenEndY,
|
||||
// (transform.position.y - ConstRef.TweenEndY) / (ConstRef.FallSpeed * 0.6f))
|
||||
// .SetEase(Ease.InQuad))
|
||||
// .Callback(() => DialogController.Instance?.StartDialogNode($"{data.moduleName}CutDown"))
|
||||
// .Callback(() => EnumEventSystem.Global.Send(EventEnum.CutEnd))
|
||||
// .Start(this, () => Destroy(gameObject));
|
||||
// }
|
||||
|
||||
// private void ShowCutLine()
|
||||
// {
|
||||
// // 切割线不存在,就新建一个
|
||||
// if (!_cutLine)
|
||||
// {
|
||||
// var prefab = ResourceKit.LoadAssetSync<GameObject>(ConstRef.CutLinePrefabName);
|
||||
// var cutLineObj = Instantiate(prefab, transform);
|
||||
// _cutLine = cutLineObj.GetComponent<CutLine>();
|
||||
// }
|
||||
|
||||
// // 对切割线进行初始化
|
||||
// var shapePoints = new List<Vector2>();
|
||||
// _targetSpriteRenderer.sprite.GetPhysicsShape(0, shapePoints);
|
||||
// if (shapePoints.Count <= 0)
|
||||
// {
|
||||
// Debug.LogWarning($"{name} has no shape");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // 本地坐标转世界坐标
|
||||
// var shapePointsV3 = shapePoints
|
||||
// .Select(item => _targetSpriteRenderer.transform.TransformPoint(item))
|
||||
// .ToList();
|
||||
|
||||
// _cutLine.Init(shapePointsV3, clickRadius);
|
||||
// }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using AibisDream.Kit;
|
||||
using DG.Tweening;
|
||||
using TMPro;
|
||||
|
||||
Reference in New Issue
Block a user