mirror of
https://github.com/soarqin/DSP_Mods_TO.git
synced 2025-12-19 21:13:29 +08:00
add XianTu
This commit is contained in:
80
XianTu/AssetsLoader/ABLoad.cs
Normal file
80
XianTu/AssetsLoader/ABLoad.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetsLoader
|
||||
{
|
||||
public abstract class ABLoad : ILoad
|
||||
{
|
||||
protected void Init()
|
||||
{
|
||||
foreach (var text in Ab.GetAllAssetNames())
|
||||
{
|
||||
var flag = text.Contains("prefabs");
|
||||
if (flag)
|
||||
{
|
||||
PrefabPath = text.Substring(0, text.IndexOf("prefabs", StringComparison.OrdinalIgnoreCase));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject LoadPrefab(string path)
|
||||
{
|
||||
var flag = Ab == null;
|
||||
GameObject gameObject;
|
||||
if (flag)
|
||||
{
|
||||
Debug.Log("内嵌的AB包没有找到");
|
||||
gameObject = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag2 = path.Contains("/");
|
||||
if (flag2)
|
||||
{
|
||||
path = Path.Combine(PrefabPath, path);
|
||||
var flag3 = !path.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase);
|
||||
if (flag3)
|
||||
{
|
||||
path += ".prefab";
|
||||
}
|
||||
}
|
||||
gameObject = Ab.LoadAsset<GameObject>(path);
|
||||
}
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
public string LoadText(string path)
|
||||
{
|
||||
var flag = Ab == null;
|
||||
string text;
|
||||
if (flag)
|
||||
{
|
||||
Debug.Log("内嵌的AB包没有找到");
|
||||
text = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag2 = path.Contains("/");
|
||||
if (flag2)
|
||||
{
|
||||
path = Path.Combine(_txtPath, path);
|
||||
var flag3 = !path.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase);
|
||||
if (flag3)
|
||||
{
|
||||
path += ".prefab";
|
||||
}
|
||||
}
|
||||
text = Ab.LoadAsset<TextAsset>(path).text;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
protected string PrefabPath;
|
||||
|
||||
protected AssetBundle Ab;
|
||||
|
||||
private string _txtPath;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user