예제 #1
0
        public T LoadAsset <T>(KS.SceneActions.Asset asset)
            where T : UnityEngine.Object
        {
            if (Helper.GameName == null)
            {
                return(null);
            }

            if (asset != null && asset.BundleName != null && asset.AssetName != null)
            {
                try
                {
                    var bundle = GetBundle(Helper.GameName, asset.BundleName);
                    if (asset.Index.HasValue)
                    {
                        return(bundle.LoadAssetWithSubAssets <T>(asset.AssetName)[asset.Index.Value]);
                    }
                    else
                    {
                        return(bundle.LoadAsset <T>(asset.AssetName));
                    }
                }
                catch (System.Exception e)
                {
                    if (asset.Index.HasValue)
                    {
                        Debug.LogErrorFormat("Error for load asset {0}[{1}] from {2}", asset.AssetName, asset.Index.Value, asset.BundleName);
                    }
                    else
                    {
                        Debug.LogErrorFormat("Error for load asset {0} from {1}", asset.AssetName, asset.BundleName);
                    }
                    Debug.LogError(e.Message);
                    return(null);
                }
            }
            return(null);
        }
예제 #2
0
        public object DynamicLoadAsset(System.Type type, KS.SceneActions.Asset asset)
        {
            var loadAssetMethod = Helper.MakeGenericMethod(LOAD_ASSET_METHOD_INFO, type);

            return(loadAssetMethod.Invoke(Instance, new object[] { asset }));
        }