120 lines
4.2 KiB
C#
120 lines
4.2 KiB
C#
using System.Collections.Generic;
|
|
using cfg.CharacterCfg;
|
|
using Framework;
|
|
using Gameplay.Utils;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
namespace CharacterBuilder
|
|
{
|
|
public class CharacterBuildData : BaseRoleBuildData
|
|
{
|
|
public readonly DataCharacterAttri mainConfig;
|
|
public readonly List<DataCharacterSkin> skins;
|
|
|
|
|
|
public CharacterBuildData(DataCharacterAttri mainConfig)
|
|
{
|
|
this.mainConfig = mainConfig;
|
|
skins = new List<DataCharacterSkin>();
|
|
errorInfo = null;
|
|
isChecked = false;
|
|
|
|
var skinConfigList = EditorTableManager.instance.tables.SkinCfg.DataList;
|
|
for (int i = 0; i < skinConfigList.Count; i++)
|
|
{
|
|
var cConfig = skinConfigList[i];
|
|
if (cConfig.RoleID == mainConfig.RoleID)
|
|
{
|
|
skins.Add(cConfig);
|
|
}
|
|
}
|
|
|
|
weaponConfig = EditorTableManager.instance.tables.WeaponConfig.Get(mainConfig.WeaponId);
|
|
|
|
emojiExt = new EmojiExtInfo();
|
|
emojiExt.emojiId = mainConfig.DefaultEmojiImgId;
|
|
emojiExt.eyebowsType = mainConfig.EmojiEyeBowsType;
|
|
emojiExt.eyebowsColor = mainConfig.EmojiEyeBowsColor;
|
|
emojiExt.eyesColor = mainConfig.EmojiEyesColor;
|
|
|
|
attackAnimOrder = this.mainConfig.AttackAnimOrder;
|
|
reloadAnimOrder = this.mainConfig.ReloadAnimOrder;
|
|
}
|
|
|
|
public override string CheckAnims(Dictionary<string, AnimationClip> dict)
|
|
{
|
|
for (int i = 0; i < skins.Count; i++)
|
|
{
|
|
var nameId = skins[i].NameID;
|
|
var checkInfo = _CheckAnims(dict, nameId);
|
|
if (!string.IsNullOrEmpty(checkInfo))
|
|
{
|
|
return checkInfo;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public override void RebuildAll(Dictionary<string, AnimationClip> clipDict)
|
|
{
|
|
if (weaponConfig == null)
|
|
{
|
|
Debug.LogError($"对象:{mainConfig.NameRead}未配置武器,取消导出");
|
|
return;
|
|
}
|
|
if (skins.Count == 0)
|
|
{
|
|
Debug.LogError($"对象:{mainConfig.NameRead}未配置皮肤,取消导出");
|
|
return;
|
|
}
|
|
for (int i = 0; i < skins.Count; i++)
|
|
{
|
|
var skinConfig = skins[i];
|
|
var prefabPath = PathEx.GetCharacterSrcModelPath(skinConfig.NameID);
|
|
_Rebuild(clipDict, prefabPath, skinConfig.NameID);
|
|
|
|
// 将展示用模型放入addressable
|
|
var displayPath = PathEx.GetCharacterDisplayModelPath(skinConfig.NameID);
|
|
// 判断资源是否存在
|
|
var displayObj = AssetDatabase.LoadAssetAtPath<GameObject>(displayPath);
|
|
if (displayObj == null)
|
|
{
|
|
Debug.LogError($"对象:{mainConfig.NameRead}的展示模型不存在,请注意检查配表:{displayPath}");
|
|
continue;
|
|
}
|
|
var loadViewTrans = displayObj.transform.GetChild(0);
|
|
loadViewTrans.localScale = Vector3.one;
|
|
// 保存展示模型
|
|
// 设置为dirty
|
|
EditorUtility.SetDirty(displayObj);
|
|
// 保存
|
|
AssetDatabase.SaveAssets();
|
|
_AddToAddressables(displayPath);
|
|
}
|
|
}
|
|
|
|
private void _AddToAddressables(string assetPath)
|
|
{
|
|
#if USE_ADDRESSABLES
|
|
// 获取 AddressableAssetSettings
|
|
var settings = AddressableAssetSettingsDefaultObject.Settings;
|
|
|
|
// 获取或创建一个资源组
|
|
var group = settings.FindGroup("SplitCharacter");
|
|
if (group == null)
|
|
{
|
|
Debug.LogError("找不到资源组:SplitCharacter");
|
|
return;
|
|
}
|
|
// 创建或移动条目
|
|
var guid = AssetDatabase.AssetPathToGUID(assetPath);
|
|
settings.CreateOrMoveEntry(guid, group);
|
|
#endif
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|