So somehow the costumes are not showing up. Instead of the portrait being in the scene already, I'm instantiating it. It's instantiated as I can see it in the hierarchy but it's now showing in the scene.

This is the code of where I equip/unequip (sync) the costumes:
public void Equip(EquipmentDefinition equipItem)
{
if (equipItem == null) return;
if (equipment.TryGetValue(equipItem.type, out apPortrait portrait))
{
TryUnequip(equipItem.type);
portrait = InstantiatePortrait(equipItem.prefab, equipItem.syncAnimation);
// modify sorting order
}
else
{
var newPortrait = InstantiatePortrait(equipItem.prefab, equipItem.syncAnimation);
equipment.Add(equipItem.type, newPortrait);
}
apPortrait InstantiatePortrait(apPortrait prefab, bool syncAnimation)
{
var newPortrait = Object.Instantiate(prefab);
newPortrait.transform.parent = _characterGroup;
newPortrait.transform.localPosition = Vector3.zero;
newPortrait.Synchronize(_mainCharacter, syncAnimation, false, false, true, SYNC_BONE_OPTION.MatchFromRoot);
return newPortrait;
}
}
[Button]
public bool TryUnequip(EquipType type)
{
if (equipment.TryGetValue(type, out apPortrait portrait))
{
if (portrait != null)
{
portrait.Unsynchronize();
portrait.transform.parent = null;
Object.Destroy(portrait.gameObject);
return true;
}
}
return false;
}
Dunno what other info I should include. Do tell me if you need any other to diagnose if this is a package problem or a me problem. Thank you.
Hi!
Depending on how you configure the scene, the answer may vary slightly, but we recommend checking two parts first.
First, let's take a look at the code related to "Instantiate".
Looking at the code in the "var newPortrait = Object.Instantiate(prefab);" section, it seems to Instantiate "prefab of type apPortrait".
Since apPortrait is a Component, not a GameObject, if you want to Instantiate it, modify it as follows.
GameObject newGameObj = GameObject.Instantiate<GameObject>(prefab.gameObject);
apPortrait newPortrait = newGameObj.GetComponent<apPortrait>();
Second, make sure to initialize right after “Instantiate”.
Most functions of apPortrait can be called after the initialization process.
Initialization is usually done automatically, so you don’t have to worry about it, but if you want to call a function right after creating a character with Instantiate, you need to initialize it yourself.
Initialize by adding code such as “newPortrait.Initialize();” right after Instantiate.
You can see the manual related to initialization at the following link.
https://rainyrizzle.github.io/en/AdvancedManual/AD_InitializeScript.html
As above, we have answered some parts of the script, but we cannot know exactly whether it works properly with only the information you have provided.
Please review the above answer, modify it appropriately, test it, and if the problem is not solved, please leave a comment for us.
We would appreciate it if you could also provide us with the error log from the Console tab.
Thanks!