|
@@ -141,7 +141,7 @@ namespace GFGGame
|
|
|
{
|
|
|
var roleTf = sceneObj.transform.Find(ROLE_OBJ_NAME);
|
|
|
parentObj = parentObj == null ? roleTf.gameObject : parentObj;
|
|
|
- string res = HEAD_DEFAULT_RES_NAME;
|
|
|
+ string resPath = ResPathUtil.GetDressUpPath(HEAD_DEFAULT_RES_NAME);
|
|
|
|
|
|
Transform transform_t = parentObj.transform.Find(HEAD_SPRITE_NAME);
|
|
|
if (show)
|
|
@@ -151,7 +151,7 @@ namespace GFGGame
|
|
|
transform_t.gameObject.SetActive(true);
|
|
|
return;
|
|
|
}
|
|
|
- AddSpriteObj(res, "png", HEAD_SPRITE_NAME, parentObj, 1, needSetMask);
|
|
|
+ AddSpriteObj(resPath, "png", HEAD_SPRITE_NAME, parentObj, 1, needSetMask);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -198,7 +198,7 @@ namespace GFGGame
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- AddSpriteObj(BODY_DEFAULT_RES_NAME, extPng, BODY_SPRITE_NAME, parentObj, 0, needSetMask);
|
|
|
+ AddSpriteObj(ResPathUtil.GetDressUpPath(BODY_DEFAULT_RES_NAME), extPng, BODY_SPRITE_NAME, parentObj, 0, needSetMask);
|
|
|
if (removeBodyAni)
|
|
|
{
|
|
|
parentObj.transform.SetPositionAndRotation(new Vector3(), new Quaternion());
|
|
@@ -222,30 +222,13 @@ namespace GFGGame
|
|
|
assetDisposer.resPath = resPath;
|
|
|
}
|
|
|
|
|
|
- public static string GetDressUpItemLayerRes(ItemCfg itemCfg, int layerId)
|
|
|
- {
|
|
|
- string res = itemCfg.res;
|
|
|
- switch (layerId)
|
|
|
- {
|
|
|
- case 1:
|
|
|
- res = itemCfg.resLayer1 == "n" ? res : string.Format("{0}_{1}", res, itemCfg.resLayer1);
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- res = itemCfg.resLayer2 == "n" ? res : string.Format("{0}_{1}", res, itemCfg.resLayer2);
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- res = itemCfg.resLayer3 == "n" ? res : string.Format("{0}_{1}", res, itemCfg.resLayer3);
|
|
|
- break;
|
|
|
- }
|
|
|
- return res;
|
|
|
- }
|
|
|
-
|
|
|
private static void updateLayerRes(ItemCfg itemCfg, GameObject parentObj, int layerId, bool needSetMask, bool showAni = true)
|
|
|
{
|
|
|
|
|
|
ItemTypeCfg typeCfg = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType);
|
|
|
|
|
|
- string res = GetDressUpItemLayerRes(itemCfg, layerId);
|
|
|
+ string res = ResPathUtil.GetDressUpItemLayerRes(itemCfg, layerId);
|
|
|
+ string resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
|
|
|
int sortingOrder = typeCfg.defaultLayer;
|
|
|
if (layerId == 2)
|
|
|
{
|
|
@@ -266,7 +249,7 @@ namespace GFGGame
|
|
|
if (DressUpMenuItemCfg1Array.Instance.CheckIsDefaultType(itemCfg.subType))
|
|
|
{
|
|
|
//默认类型的部件需要先添加静态图,防止加载动画有延迟,出现光头
|
|
|
- spriteObj = AddSpriteObj(res, ext, spritObjName, parentObj, sortingOrder, needSetMask);
|
|
|
+ spriteObj = AddSpriteObj(resPath, ext, spritObjName, parentObj, sortingOrder, needSetMask);
|
|
|
}
|
|
|
|
|
|
GameObject addAniObj = null;
|
|
@@ -292,7 +275,7 @@ namespace GFGGame
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(assetDisposer.resPath))
|
|
|
{
|
|
|
- string resPath = ResPathUtil.GetDressUpPath(res, ext);
|
|
|
+ string resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
|
|
|
if (assetDisposer.resPath == resPath)
|
|
|
{
|
|
|
TryRemoveObj(parentObj, spritObjName);
|
|
@@ -308,16 +291,15 @@ namespace GFGGame
|
|
|
if (spriteObj == null && addAniObj == null)
|
|
|
{
|
|
|
//如果两个都没有,就添加静态图
|
|
|
- spriteObj = AddSpriteObj(res, ext, spritObjName, parentObj, sortingOrder, needSetMask);
|
|
|
+ spriteObj = AddSpriteObj(resPath, ext, spritObjName, parentObj, sortingOrder, needSetMask);
|
|
|
}
|
|
|
objName = string.Format(FORMAT_EFFECT_OBJ_NAME, itemCfg.subType, layerId);
|
|
|
TryRemoveObj(parentObj, objName);
|
|
|
TryAddEffectObj(res, objName, parentObj, sortingOrder, addAniObj != null);
|
|
|
}
|
|
|
|
|
|
- private static GameObject AddSpriteObj(string res, string ext, string objName, GameObject parentObj, int sortingOrder, bool needSetMask)
|
|
|
+ private static GameObject AddSpriteObj(string resPath, string ext, string objName, GameObject parentObj, int sortingOrder, bool needSetMask)
|
|
|
{
|
|
|
- string resPath = ResPathUtil.GetDressUpPath(res, ext);
|
|
|
if (!VEngine.Versions.Contains(resPath))
|
|
|
{
|
|
|
return null;
|
|
@@ -341,7 +323,7 @@ namespace GFGGame
|
|
|
spr = gameObj.AddComponent<SpriteRenderer>();
|
|
|
}
|
|
|
float tx, ty;
|
|
|
- LoadSpritePos(res, out tx, out ty);
|
|
|
+ LoadSpritePos(resPath, out tx, out ty);
|
|
|
gameObj.transform.localPosition = new Vector3(tx, ty, gameObj.transform.localPosition.z);
|
|
|
Sprite sp = GFGAsset.Load<Sprite>(resPath);
|
|
|
spr.sprite = sp;
|
|
@@ -485,9 +467,9 @@ namespace GFGGame
|
|
|
return gameObj;
|
|
|
}
|
|
|
|
|
|
- public static void LoadSpritePos(string res, out float tx, out float ty)
|
|
|
+ public static void LoadSpritePos(string resPath, out float tx, out float ty)
|
|
|
{
|
|
|
- string resPath = ResPathUtil.GetDressUpPath(res, "bytes");
|
|
|
+ resPath = resPath.Replace(".png", ".bytes");
|
|
|
if (VEngine.Versions.Contains(resPath))
|
|
|
{
|
|
|
var asset = GFGAsset.Load<TextAsset>(resPath);
|