少年修仙传客户端基础资源
client_Wu Xijin
2018-10-21 6f8ed2e37f8762fb3501a671d0dca40bcd68edae
Assets/Editor/Actor/NpcResourcesBuilder.cs
@@ -1,103 +1,142 @@
using UnityEngine;
using UnityEditor;
using TableConfig;
using System.Collections.Generic;
public class NpcResourcesBuilder : ResourcesBuilder
{
    public void BuildNpc(string modelName)
    {
        if (modelName.Contains("A_Zs"))
        {
            return;
        }
        BuildAnimationClip1(modelName);
        BuildAnimatorController(modelName);
        var showConfigs = ConfigManager.Instance.GetAllValues<ActorShowConfig>();
        NPCConfig _npcModel = null;
        foreach (var _item in showConfigs)
        {
            for (int i = 0; i < _item.showNpcs.Length; i++)
            {
                _npcModel = ConfigManager.Instance.GetTemplate<NPCConfig>(_item.showNpcs[i]);
                if (_npcModel == null)
                {
                    continue;
                }
                if (_npcModel.MODE.Equals(modelName))
                {
                    BuildBossShowAnimatorController(modelName);
                    break;
                }
            }
        }
        BuildPrefab(modelName);
    }
    public void BuildPrefab(string modelName)
    {
        if (!IsBuildPrefab)
        {
            return;
        }
        BuildPrefab(modelName, modelName, InstanceResourcesLoader.raceSuffix);
    }
    public void BuildAnimationClip1(string modelName)
    {
        if (!IsBuildAnimationClip)
        {
            return;
        }
        BuildAnimationClip(modelName);
    }
    public void BuildAnimatorController(string modelName)
    {
        if (!IsBuildAnimatorController)
        {
            return;
        }
        if (modelName.Contains("B_Cw"))
        {
            BuildAnimatorController(modelName, "Temple_AnimatorController_Pet", "animatorBuildConfig");
        }
        else
        {
            BuildAnimatorController(modelName, "Temple_AnimatorController_Mob", "animatorBuildConfig");
        }
    }
    public void BuildBossShowAnimatorController(string modelName)
    {
        if (!IsBuildAnimatorController)
        {
            return;
        }
        BuildAnimatorController(modelName, "Temple_AnimatorController_BossShow", "animatorBuildConfig_BossShow");
    }
    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<Material>(_materialPath);
        _renderer.sharedMaterial.shader = Shader.Find("Character/Normal Monster");
        Texture _texture = AssetDatabase.LoadAssetAtPath<Texture>(_texturePath);
        _renderer.sharedMaterial.SetTexture("_MainTex", _texture);
    }
using UnityEngine;
using UnityEditor;
using TableConfig;
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 = Config.Instance.GetAllValues<ActorShowConfig>();
        NPCConfig _npcModel = null;
        foreach (var _item in showConfigs)
        {
            for (int i = 0; i < _item.showNpcs.Length; i++)
            {
                if(_item.showNpcs[i] == 0)
                {
                    continue;
                }
                _npcModel = Config.Instance.Get<NPCConfig>(_item.showNpcs[i]);
                if (_npcModel == null)
                {
                    continue;
                }
                if (_npcModel.MODE.Equals(modelName))
                {
                    BuildBossShowAnimatorController(modelName);
                    break;
                }
            }
        }
        var realmConfigs = Config.Instance.GetAllValues<RealmConfig>();
        foreach (var _realmConfig in realmConfigs)
        {
            _npcModel = Config.Instance.Get<NPCConfig>(_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);
        }
        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<Material>(_materialPath);
        _renderer.sharedMaterial.shader = Shader.Find("Character/Normal Monster");
        Texture _texture = AssetDatabase.LoadAssetAtPath<Texture>(_texturePath);
        _renderer.sharedMaterial.SetTexture("_MainTex", _texture);
    }
}