using System;
using System.Collections.Generic;
using UnityEngine;
namespace CustomAssetBundleSystem
{
///
/// Simple JSON catalog structure for remote AssetBundles
/// No Unity Addressables bugs, full control, lightweight
///
[Serializable]
public class RemoteAssetCatalog
{
public string version = "1.0.0";
public long timestamp;
public string baseUrl = "https://addressable.uncaptured.co/AssetBundles/Android";
public List bundles = new List();
[Serializable]
public class BundleEntry
{
public string bundleName; // e.g., "gamescene"
public string fileName; // e.g., "gamescene.bundle"
public string hash; // MD5/CRC for verification
public long size; // File size in bytes
public List scenes; // Scenes contained in this bundle
public List dependencies; // Other bundles this depends on
public string GetFullUrl(string baseUrl)
{
return $"{baseUrl}/{fileName}";
}
}
///
/// Find bundle entry by scene name
///
public BundleEntry FindBundleByScene(string sceneName)
{
foreach (var bundle in bundles)
{
if (bundle.scenes != null && bundle.scenes.Contains(sceneName))
{
return bundle;
}
}
return null;
}
///
/// Find bundle entry by bundle name
///
public BundleEntry FindBundleByName(string bundleName)
{
return bundles.Find(b => b.bundleName == bundleName);
}
///
/// Get all dependencies recursively
///
public List GetAllDependencies(BundleEntry bundle, HashSet visited = null)
{
if (visited == null) visited = new HashSet();
var result = new List();
if (bundle.dependencies == null || bundle.dependencies.Count == 0)
return result;
foreach (var depName in bundle.dependencies)
{
if (visited.Contains(depName)) continue;
visited.Add(depName);
var depBundle = FindBundleByName(depName);
if (depBundle != null)
{
result.Add(depBundle);
result.AddRange(GetAllDependencies(depBundle, visited));
}
}
return result;
}
}
}