/** * Serialized constructor. */ public pb_MetaData(SerializationInfo info, StreamingContext context) { _fileId = (string)info.GetValue("_fileId", typeof(string)); _assetBundlePath = (pb_AssetBundlePath)info.GetValue("_assetBundlePath", typeof(pb_AssetBundlePath)); _assetType = (AssetType)info.GetValue("_assetType", typeof(AssetType)); componentDiff = (pb_ComponentDiff)info.GetValue("componentDiff", typeof(pb_ComponentDiff)); }
private bool _GetAssetPath <T>(T asset, out pb_AssetBundlePath path) where T : UnityEngine.Object { foreach (string bundle_path in availableAssetBundles) { try { AssetBundle bundle = _LoadAssetBundle(bundle_path); foreach (KeyValuePair <string, UnityEngine.Object> kvp in LoadBundleAssetsWithPaths(bundle)) { if (kvp.Value.GetType() == typeof(T)) { path = new pb_AssetBundlePath(bundle_path, kvp.Key); return(true); } } } catch (System.Exception e) { Debug.LogWarning("Failed loading AssetBundle: " + bundle_path + "\n" + e.ToString()); } } path = null; return(false); }
/** * Serialized constructor. */ public pb_MetaData(SerializationInfo info, StreamingContext context) { _fileId = (string) info.GetValue("_fileId", typeof(string)); _assetBundlePath = (pb_AssetBundlePath) info.GetValue("_assetBundlePath", typeof(pb_AssetBundlePath)); _assetType = (AssetType) info.GetValue("_assetType", typeof(AssetType)); componentDiff = (pb_ComponentDiff) info.GetValue( "componentDiff", typeof(pb_ComponentDiff)); }
/** * Basic constructor (used on instance assets). */ public pb_MetaData() { _assetType = AssetType.Instance; _fileId = GUID_NOT_FOUND; _assetBundlePath = null; componentDiff = new pb_ComponentDiff(); }
private T _LoadAsset <T>(pb_AssetBundlePath path) where T : UnityEngine.Object { AssetBundle bundle = _LoadAssetBundleWithName(path.assetBundleName); if (bundle == null) { return((T)null); } if (bundle.Contains(path.filePath)) { T obj = bundle.LoadAsset <T>(path.filePath); return(obj); } return((T)null); }
/** * Load an asset from a pb_AssetBundlePath. */ public static T LoadAsset <T>(pb_AssetBundlePath path) where T : UnityEngine.Object { return(pb_AssetBundles.instance._LoadAsset <T>(path)); }
/** * Return the AssetBundle and path within that bundle to an object. * May return a null or emptry string. */ public static bool GetAssetPath <T>(T asset, out pb_AssetBundlePath path) where T : UnityEngine.Object { return(pb_AssetBundles.instance._GetAssetPath <T>(asset, out path)); }
/** * Set the asset bundle information. */ public void SetAssetBundleData(string bundleName, string assetPath) { _fileId = ASSET_BUNDLE; _assetType = AssetType.Bundle; _assetBundlePath = new pb_AssetBundlePath(bundleName, assetPath); }
/** * Set the fileID field if this asset is in the resources folder. */ public void SetFileId(string id) { _assetType = AssetType.Resource; _assetBundlePath = null; _fileId = id; }