少年修仙传客户端代码仓库
client_Hale
2019-04-11 9f89e3be35da42eb9ccb44e6589d62f320aa444c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using UnityEngine;
 
 
#if UNITY_EDITOR
using UnityEditor;
#endif
 
public class AnimatorControllerLoader
{
 
    public static readonly string controllerSuffix = "AnimatorController_";
    public static readonly string controllerUISuffix = "AnimatorController_UI_";
    public static readonly string controllerShowSuffix = "AnimatorController_Show_";
    public static readonly string controllerRealmSuffix = "AnimatorController_Realm_";
 
    public static AnimationClip LoadAnimationClip(string name, string clipName)
    {
 
        AnimationClip _animationClip = null;
        if (AssetSource.mobFromEditor)
        {
#if UNITY_EDITOR
            string _resourcesPath = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
                                                          "mob/",
                                                          name,
                                                          "/AnimationClips/",
                                                          clipName,
                                                          ".anim");
 
            _animationClip = AssetDatabase.LoadAssetAtPath<AnimationClip>(_resourcesPath);
 
#endif
        }
        else
        {
            string _bundleName = StringUtility.Contact(ResourcesPath.MOB_FOLDER_NAME,
                                           ResourcesPath.MOB_SUFFIX,
                                           name);
 
            string _assetName = clipName;
            AssetInfo _assetInfo = new AssetInfo(_bundleName, _assetName);
 
            _animationClip = AssetBundleUtility.Instance.Sync_LoadAsset(_assetInfo) as AnimationClip;
        }
 
        if (_animationClip == null)
        {
            DebugEx.LogErrorFormat("LoadAnimationClip.Load() => 加载不到资源: {0} => {1}.", name, clipName);
        }
 
        return _animationClip;
    }
 
    public static RuntimeAnimatorController Load(string suffix, int id)
    {
        RuntimeAnimatorController _controller = null;
        ModelResConfig _modelRes = ModelResConfig.Get(id);
        string _name = _modelRes.ResourcesName;
        if (_name.IndexOf('/') != -1)
        {
            _name = _name.Substring(0, _modelRes.ResourcesName.IndexOf('/'));
        }
 
        if (AssetSource.mobFromEditor)
        {
#if UNITY_EDITOR
 
            string _resourcesPath = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
                                                          "mob/",
                                                          _name,
                                                          "/",
                                                          suffix,
                                                          _name,
                                                          ".controller");
 
            _controller = AssetDatabase.LoadAssetAtPath<RuntimeAnimatorController>(_resourcesPath);
 
#endif
        }
        else
        {
            string _bundleName = StringUtility.Contact(ResourcesPath.MOB_FOLDER_NAME,
                                                       ResourcesPath.MOB_SUFFIX,
                                                       _name);
 
            string _assetName = StringUtility.Contact(suffix, _name);
            AssetInfo _assetInfo = new AssetInfo(_bundleName, _assetName);
 
            _controller = AssetBundleUtility.Instance.Sync_LoadAsset(_assetInfo) as RuntimeAnimatorController;
        }
 
        if (_controller == null)
        {
            DebugEx.LogErrorFormat("AnimatorControllerLoader.Load() => 加载不到资源: {0}_{1}.", suffix, _name);
        }
 
        return _controller;
    }
 
    public static RuntimeAnimatorController LoadMobController(string suffix, string _name)
    {
        RuntimeAnimatorController _controller = null;
        if (AssetSource.mobFromEditor)
        {
#if UNITY_EDITOR
            string _resourcesPath = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
                                                          "mob/",
                                                         _name,
                                                          "/",
                                                          suffix,
                                                          _name,
                                                          ".controller");
            _controller = AssetDatabase.LoadAssetAtPath<RuntimeAnimatorController>(_resourcesPath);
 
#endif
        }
        else
        {
            string _bundleName = StringUtility.Contact(ResourcesPath.MOB_FOLDER_NAME,
                                           ResourcesPath.MOB_SUFFIX,
                                           _name.ToLower());
 
            string _assetName = StringUtility.Contact(suffix, _name);
            AssetInfo _assetInfo = new AssetInfo(_bundleName, _assetName);
 
            _controller = AssetBundleUtility.Instance.Sync_LoadAsset(_assetInfo) as RuntimeAnimatorController;
        }
 
        if (_controller == null)
        {
            DebugEx.LogErrorFormat("AnimatorControllerLoader.Load() => 加载不到资源: {0}.", _name);
        }
 
        return _controller;
    }
}