using UnityEngine; using UnityEditor; using System.Collections.Generic; public class NpcResourcesBuilder : ResourcesBuilder { public void BuildNpc(string modelName, string outName = null, int type = -1, bool isHighMesh = false) { if (modelName.Contains("A_Zs")) { return; } BuildAnimationClip1(modelName); BuildAnimatorController(modelName, outName, type); var showConfigs = ActorShowConfig.GetValues(); NPCConfig _npcModel = null; foreach (var _item in showConfigs) { for (int i = 0; i < _item.showNpcs.Length; i++) { if (_item.showNpcs[i] == 0) { continue; } _npcModel = NPCConfig.Get(_item.showNpcs[i]); if (_npcModel == null) { continue; } if (_npcModel.MODE.Equals(outName)) { BuildBossShowAnimatorController(outName); break; } } } var realmConfigs = RealmConfig.GetValues(); foreach (var _realmConfig in realmConfigs) { _npcModel = NPCConfig.Get(_realmConfig.BossID); if (_npcModel == null) { continue; } if (_npcModel.MODE.Equals(modelName)) { BuildRealmAnimatorController(modelName); break; } } BuildPrefab(modelName, outName, isHighMesh); } public void BuildPrefab(string modelName, string outName, bool isHighMesh = false) { if (!IsBuildPrefab) { return; } BuildPrefab(modelName, modelName, InstanceResourcesLoader.raceSuffix, outName, isHighMesh); } public void BuildAnimationClip1(string modelName) { if (!IsBuildAnimationClip) { return; } BuildAnimationClip(modelName); } public void BuildAnimatorController(string modelName, string outName = null, int type = -1) { if (!IsBuildAnimatorController && !IsBuildAnimatorUIController) { return; } if (type <= 0) { BuildAnimatorController(modelName, "Temple_AnimatorController_Mob", "animatorBuildConfig", outName); } else if (type == 1) { BuildAnimatorController(modelName, "Temple_AnimatorController_Pet", "animatorBuildConfig", outName); } else if (type == 2) { BuildAnimatorController(modelName, "Temple_AnimatorController_Horse", "animatorBuildConfig", outName); } else if (type == 3) { BuildAnimatorController(modelName, "Temple_AnimatorController_Guard", "animatorBuildConfig", outName); } if (ResourcesBuilder.IsBuildAnimatorUIController) { BuildAnimatorController(modelName, "Temple_AnimatorController_UI", "animatorBuildConfig", outName); } } public void BuildBossShowAnimatorController(string modelName) { if (!IsBuildAnimatorController) { return; } BuildAnimatorController(modelName, "Temple_AnimatorController_BossShow", "animatorBuildConfig_BossShow"); } public void BuildRealmAnimatorController(string modelName) { if (!IsBuildAnimatorController) { return; } BuildAnimatorController(modelName, "Temple_AnimatorController_Realm", "animatorBuildConfig_Realm"); } protected override void OnSetupRenderer(string resPath, string resName, ref Renderer _renderer) { string _texturePath = string.Format("Assets/ART/Role/{0}/Materials/{1}.png", resPath, resName); string _materialPath = string.Format("Assets/ART/Role/{0}/Materials/{1}.mat", resPath, resName); // 设置为不产生阴影并且不接受阴影 _renderer.receiveShadows = false; _renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; // 设置材质 _renderer.sharedMaterial = AssetDatabase.LoadAssetAtPath(_materialPath); _renderer.sharedMaterial.shader = Shader.Find("Character/Normal Monster"); Texture _texture = AssetDatabase.LoadAssetAtPath(_texturePath); _renderer.sharedMaterial.SetTexture("_MainTex", _texture); } }