1
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BITFALL.Cosmetic;
|
||||
using BITKit;
|
||||
using BITKit.IO;
|
||||
using BITKit.Modification;
|
||||
using BITKit.UX;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
@@ -29,20 +31,43 @@ namespace BITFALL.UX
|
||||
|
||||
Rebuild();
|
||||
}
|
||||
private async void Rebuild()
|
||||
private void Rebuild()
|
||||
{
|
||||
_cosmeticsContainer.Clear();
|
||||
|
||||
var modified = _cosmeticService.Modified.Values.ToArray();
|
||||
|
||||
foreach (var cosmetic in _cosmeticService.Cosmetics)
|
||||
{
|
||||
var assetHandle = YooAssets.LoadAssetAsync(cosmetic.AddressablePath);
|
||||
await assetHandle;
|
||||
assetHandle.WaitForAsyncComplete();
|
||||
if(destroyCancellationToken.IsCancellationRequested) return;
|
||||
|
||||
var so = assetHandle.AssetObject.As<AssetableCosmetic>();
|
||||
var instance =new UXContainer(_cosmeticsContainer.Create(cosmeticsTemplate)) ;
|
||||
instance.icon.style.backgroundImage = new StyleBackground(so.Icon);
|
||||
instance.contextLabel.text = so.name;
|
||||
|
||||
if(modified.Contains(cosmetic))
|
||||
{
|
||||
instance.visualElement.AddToClassList("--toggled");
|
||||
}
|
||||
|
||||
instance.button.clicked += () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
_cosmeticService.Add(so.Type, cosmetic);
|
||||
}
|
||||
catch (NotRequireModifyException e)
|
||||
{
|
||||
Alert.Print("需要前置",e.Message);
|
||||
}
|
||||
catch (IncompatibleModifyException e)
|
||||
{
|
||||
Alert.Print("不兼容的修改",e.Message);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user