refactor(fix-system): 重构身体模块材质加载为Addressables异步流程
Made-with: Cursor
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user