Add Custom Enviroment Option (Need to fix Lighting issue))

This commit is contained in:
xpeng
2022-12-05 23:15:03 +01:00
parent 6992599d72
commit d8e8fa4ddb
39 changed files with 1895 additions and 175 deletions
@@ -0,0 +1,73 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class AssetBundleManager : MonoBehaviour
{
public static AssetBundleManager Instance { get; private set; }
private Dictionary<string, AssetBundle> assetBundles = new Dictionary<string, AssetBundle>();
private void Awake()
{
if (Instance == null)
{
Instance = this;
}
else
{
Destroy(gameObject);
}
}
public T LoadAsset<T>(string assetBundleFolder, string assetBundleName) where T : Object
{
UnloadAllAssetBundles();
LoadAssetBundle(assetBundleFolder, assetBundleName);
if (assetBundles.ContainsKey(assetBundleName))
{
string rootAssetPath = assetBundles[assetBundleName].GetAllAssetNames()[0];
return assetBundles[assetBundleName].LoadAsset<T>(rootAssetPath);
}
return null;
}
public void LoadAssetBundle(string assetBundleFolder, string assetBundleName)
{
if (!assetBundles.ContainsKey(assetBundleName))
{
AssetBundle assetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, assetBundleFolder, assetBundleName));
assetBundles.Add(assetBundleName, assetBundle);
}
}
public void UnloadAssetBundle(string assetBundleName)
{
if (assetBundles.ContainsKey(assetBundleName))
{
assetBundles[assetBundleName].Unload(true);
assetBundles.Remove(assetBundleName);
}
}
public void UnloadAllAssetBundles()
{
foreach (var assetBundle in assetBundles)
{
assetBundle.Value.Unload(true);
}
assetBundles.Clear();
}
public List<FileInfo> GetAssetBundleFiles(string assetBundleFolder)
{
var path = Path.Combine(Application.streamingAssetsPath, assetBundleFolder);
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
var dir = new DirectoryInfo(path);
var files = new List<FileInfo>(dir.GetFiles("*.abf"));
return files;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 43e8e49893eca1e4690cb1e220f45035
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: