少年修仙传客户端代码仓库
hch
2025-03-19 6770e1eb64c4282def45adb824b14b2a407fdd30
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class SceneLoader
{
 
    public static GameObject LoadCreateRole(string name)
    {
        GameObject prefab = null;
        if (AssetSource.sceneFromEditor)
        {
#if UNITY_EDITOR
            var path = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath, "Scene/CreateRole/", name, ".prefab");
            prefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path);
#endif
        }
        else
        {
            var assetInfo = new AssetInfo("maps/createrole", name);
            prefab = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo) as GameObject;
        }
 
        if (prefab == null)
        {
            DebugEx.LogErrorFormat("SceneLoader.LoadCreateRole() => 加载不到资源: {0}.", name);
        }
 
        return prefab;
    }
 
    public static Texture2D LoadTexture(string folder, string name)
    {
        Texture2D texture2D = null;
        if (AssetSource.sceneFromEditor)
        {
#if UNITY_EDITOR
            var path = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath, "Scene/", folder, "/", name, ".jpg");
            texture2D = UnityEditor.AssetDatabase.LoadAssetAtPath<Texture2D>(path);
#endif
        }
        else
        {
            var assetInfo = new AssetInfo(StringUtility.Contact("maps/", folder).ToLower(), name);
            texture2D = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo) as Texture2D;
        }
 
        if (texture2D == null)
        {
            DebugEx.LogErrorFormat("SceneLoader.LoadTexture() => 加载不到资源: {0}.", name);
        }
 
        return texture2D;
    }
 
 
}