몬스터용 데이터파이프라인 개선
애니메이션 컨트롤러 및 모델 설정 기능 추가 몬스터용 애니메이션 컨트롤러 생성
This commit is contained in:
@@ -26,13 +26,20 @@ namespace Northbound.Editor
|
||||
monsterDataComponent.ApplyMonsterData();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(monsterData.meshPath))
|
||||
var animationController = prefab.GetComponent<MonsterAnimationController>();
|
||||
if (animationController == null)
|
||||
{
|
||||
animationController = prefab.AddComponent<MonsterAnimationController>();
|
||||
Debug.Log($"[MonsterPrefabSetup] Added MonsterAnimationController component");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(monsterData.modelPath))
|
||||
{
|
||||
RemoveOldModel(prefab);
|
||||
|
||||
if (monsterData.meshPath.ToLower().EndsWith(".fbx"))
|
||||
if (monsterData.modelPath.ToLower().EndsWith(".fbx"))
|
||||
{
|
||||
GameObject fbxModel = AssetDatabase.LoadAssetAtPath<GameObject>(monsterData.meshPath);
|
||||
GameObject fbxModel = AssetDatabase.LoadAssetAtPath<GameObject>(monsterData.modelPath);
|
||||
if (fbxModel != null)
|
||||
{
|
||||
GameObject fbxInstance = GameObject.Instantiate(fbxModel);
|
||||
@@ -42,11 +49,23 @@ namespace Northbound.Editor
|
||||
fbxInstance.transform.localRotation = Quaternion.identity;
|
||||
fbxInstance.transform.localScale = Vector3.one;
|
||||
|
||||
Debug.Log($"[MonsterPrefabSetup] Applied FBX model: {monsterData.meshPath}");
|
||||
Debug.Log($"[MonsterPrefabSetup] Applied FBX model: {monsterData.modelPath}");
|
||||
|
||||
Avatar modelAvatar = fbxModel.GetComponent<Animator>()?.avatar;
|
||||
|
||||
if (modelAvatar != null)
|
||||
{
|
||||
Animator prefabAnimator = prefab.GetComponent<Animator>();
|
||||
if (prefabAnimator != null)
|
||||
{
|
||||
prefabAnimator.avatar = modelAvatar;
|
||||
Debug.Log($"[MonsterPrefabSetup] Applied Avatar: {modelAvatar.name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[MonsterPrefabSetup] Could not load FBX model: {monsterData.meshPath}");
|
||||
Debug.LogWarning($"[MonsterPrefabSetup] Could not load FBX model: {monsterData.modelPath}");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -54,34 +73,34 @@ namespace Northbound.Editor
|
||||
var meshFilter = prefab.GetComponent<MeshFilter>();
|
||||
if (meshFilter != null)
|
||||
{
|
||||
Mesh mesh = AssetDatabase.LoadAssetAtPath<Mesh>(monsterData.meshPath);
|
||||
Mesh mesh = AssetDatabase.LoadAssetAtPath<Mesh>(monsterData.modelPath);
|
||||
if (mesh != null)
|
||||
{
|
||||
meshFilter.sharedMesh = mesh;
|
||||
Debug.Log($"[MonsterPrefabSetup] Applied mesh: {monsterData.meshPath}");
|
||||
Debug.Log($"[MonsterPrefabSetup] Applied mesh: {monsterData.modelPath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[MonsterPrefabSetup] Could not load mesh: {monsterData.meshPath}");
|
||||
Debug.LogWarning($"[MonsterPrefabSetup] Could not load mesh: {monsterData.modelPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(monsterData.animatorControllerPath))
|
||||
if (!string.IsNullOrEmpty(monsterData.animationControllerPath))
|
||||
{
|
||||
Animator animator = prefab.GetComponent<Animator>();
|
||||
if (animator != null)
|
||||
{
|
||||
RuntimeAnimatorController controller = AssetDatabase.LoadAssetAtPath<RuntimeAnimatorController>(monsterData.animatorControllerPath);
|
||||
RuntimeAnimatorController controller = AssetDatabase.LoadAssetAtPath<RuntimeAnimatorController>(monsterData.animationControllerPath);
|
||||
if (controller != null)
|
||||
{
|
||||
animator.runtimeAnimatorController = controller;
|
||||
Debug.Log($"[MonsterPrefabSetup] Applied Animator Controller: {monsterData.animatorControllerPath}");
|
||||
Debug.Log($"[MonsterPrefabSetup] Applied Animator Controller: {monsterData.animationControllerPath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[MonsterPrefabSetup] Could not load Animator Controller: {monsterData.animatorControllerPath}");
|
||||
Debug.LogWarning($"[MonsterPrefabSetup] Could not load Animator Controller: {monsterData.animationControllerPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user