Пример #1
0
        public static T LoadObjectFromFile <T>(string path, bool instantiate, bool unloadAfterIns = true) where T : UnityEngine.Object
        {
            System.Console.WriteLine(string.Concat(new object[]
            {
                "Static: LoadObjectFromFile<",
                typeof(T).ToString(),
                ">(",
                path,
                ", ",
                instantiate,
                ")"
            }));
            AssetBundle assetBundle = FileLoader.Instance._loadAssetBundleFromFile(path);
            T           result      = (T)((object)null);

            if (assetBundle != null)
            {
                if (instantiate)
                {
                    if (assetBundle.MainAsset5() == null)
                    {
                        UnityEngine.Debug.LogError("FileLoader.LoadObjectFromFile<" + typeof(T).ToString() + ">: object to instantiate is null, path = " + path);
                        result = (T)((object)null);
                    }
                    else
                    {
                        result = (UnityEngine.Object.Instantiate(assetBundle.MainAsset5()) as T);
                    }
                    if (unloadAfterIns)
                    {
                        FileLoader.UnloadAssetBundle(path);
                    }
                }
                else
                {
                    result = (assetBundle.MainAsset5() as T);
                }
            }
            return(result);
        }