Beispiel #1
0
        public Object Resolve(GameItemInfo gameItem)
        {
            Initialize();
            ResourceGameItem item = gameItem as ResourceGameItem;

            if (item != null)
            {
                return(Resources.Load(item.Address));
            }
            AssetBundleGameItem assetBundleGameItem = gameItem as AssetBundleGameItem;

            if (assetBundleGameItem != null)
            {
                if (_assetBundles.ContainsKey(assetBundleGameItem.AssetBundle))
                {
                    return(_assetBundles[assetBundleGameItem.AssetBundle].LoadAsset(assetBundleGameItem.ItemName));
                }
                if (!IsAssetBundleDownloaded(assetBundleGameItem.AssetBundle))
                {
                    throw new Exception(string.Format("Asset bundle {0} is not downloaded", assetBundleGameItem.AssetBundle));
                }
                Uri bundleServerAddress             = GetBundleServerAddress(assetBundleGameItem.AssetBundle);
                UnityEngine.AssetBundle assetBundle =
                    UnityEngine.AssetBundle.LoadFromFile(
                        InfoResolver.Resolve <FortInfo>()
                        .ServerConnectionProvider.UserConnection.LoadFromCache(bundleServerAddress));
                _assetBundles[assetBundleGameItem.AssetBundle] = assetBundle;
                return(assetBundle.LoadAsset(assetBundleGameItem.ItemName));
            }
            return((Object)gameItem.GetType().GetProperty("GameItem").GetValue(gameItem, new object[0]));
        }
Beispiel #2
0
 public static UIPackage AddPackage(AssetBundle desc, AssetBundle res, string resourceNamePrefix)
 {
     byte[] bytes = ((TextAsset)desc.mainAsset).bytes;
     if (desc != res)
         desc.Unload(true);
     return AddPackage(bytes, res, resourceNamePrefix);
 }
 public void Dispose()
 {
     if (bundle != null) {
         bundle.Unload(false);
         bundle = null;
     }
 }
 public void Decorate(GameObject go, Dictionary<string, object> options, AssetBundle assetBundle)
 {
     if (go.GetComponent<Deco>() != null && _grid)
     {
         go.GetComponent<Deco>().buildOnGrid = _grid;
     }
 }
 static public int LoadAssetAsync(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
             System.String           a1;
             checkType(l, 2, out a1);
             var ret = self.LoadAssetAsync(a1);
             pushValue(l, ret);
             return(1);
         }
         else if (argc == 3)
         {
             UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
             System.String           a1;
             checkType(l, 2, out a1);
             System.Type a2;
             checkType(l, 3, out a2);
             var ret = self.LoadAssetAsync(a1, a2);
             pushValue(l, ret);
             return(1);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int LoadAll(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(System.Type)))
         {
             UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
             System.Type             a1;
             checkType(l, 2, out a1);
             UnityEngine.Object[] ret = self.LoadAll(a1);
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, 2))
         {
             UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
             UnityEngine.Object[]    ret  = self.LoadAll();
             pushValue(l, ret);
             return(1);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Beispiel #7
0
 void LoadAssets(string path)
 {
     if ((System.IO.File.Exists (path) == false) || (path.EndsWith (".unity3d") == false)) {
         return;
     }
     string assetBundleName = System.IO.Path.GetFileNameWithoutExtension (path);
     var loadedAssetBundles = Resources.FindObjectsOfTypeAll<AssetBundle> ();
     foreach (var loadedAssetBundle in loadedAssetBundles) {
         if (loadedAssetBundle.name == assetBundleName) {
             loadedAssetBundle.Unload (true);
         }
     }
     if (string.IsNullOrEmpty (path) == false) {
         if (System.IO.Directory.Exists (path)) {
             return;
         }
         byte[] bytes = System.IO.File.ReadAllBytes (path);
         if (_lastSelectedAssetBundle != null) {
             _lastSelectedAssetBundle.Unload (true);
             _lastSelectedAssetBundle = null;
         }
         _lastSelectedAssetBundle = AssetBundle.CreateFromMemoryImmediate (bytes);
         if (_lastSelectedAssetBundle != null) {
             _lastSelectedAssetBundle.name = assetBundleName;
             _assets = _lastSelectedAssetBundle.LoadAllAssets ();
         }
         OrderBySize ();
     }
 }
        public void Decorate(GameObject go, Dictionary<string, object> options, AssetBundle assetBundle)
        {
            CustomSize cs = go.AddComponent<CustomSize>();

            cs.minSize = 1;
            cs.maxSize = 4;
        }
 static public int LoadAll(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 1)
         {
             UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
             var ret = self.LoadAll();
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 2)
         {
             UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
             System.Type             a1;
             checkType(l, 2, out a1);
             var ret = self.LoadAll(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        public void Decorate(GameObject go, Dictionary<string, object> options, AssetBundle assetBundle)
        {
            go.AddComponent<global::Deco>();

            if (options.ContainsKey("heightDelta"))
                (new HeightDecorator((double)options["heightDelta"])).Decorate(go, options, assetBundle);
        }
Beispiel #11
0
 public override bool IsDone()
 {
     if (this.dependences != null)
     {
         for (int i = 0; i < this.dependences.Length; ++i)
         {
             if (!ResMgr.Instance().IsLoadedAssetBundle(this.dependences[i]))
                 return false;
         }
     }
     if (this.op != null)
     {
         return this.op.isDone;
     }
     else
     {
         if (this.www.isDone)
         {
             this.assetbundle = this.www.assetBundle;
             string scene = base.SceneName.Substring(0, base.SceneName.LastIndexOf('.'));
             if (this.additive)
                 this.op = Application.LoadLevelAdditiveAsync(scene);
             else
                 this.op = Application.LoadLevelAsync(scene);
             this.www.Dispose();
             this.www = null;
         }
         return false;
     }
 }
Beispiel #12
0
 public CacheData(object data, AssetBundle assetBundle, string assetBundleName)
 {
     this.www = data;
     this.assetBundle = assetBundle;
     this.assetBundleKey = assetBundleName;
     this.assetHashCode = LuaHelper.StringToHash(assetBundleName);
 }
 public void Decorate(GameObject go, Dictionary<string, object> options, AssetBundle assetBundle)
 {
     if (go.GetComponent<Deco>() != null)
     {
         go.GetComponent<Deco>().defaultSnapToGridCenter = _snap;
     }
 }
 public void Decorate(GameObject go, Dictionary<string, object> options, AssetBundle assetBundle)
 {
     if (go.GetComponent<Deco>() != null)
     {
         go.GetComponent<Deco>().defaultGridSubdivision = _subdivision;
     }
 }
        protected virtual void Awake()
        {
            string bundlePath = EngineerGlobals.AssemblyPath;

            s_Images = AssetBundle.CreateFromFile(bundlePath + "/images");
            s_Prefabs = AssetBundle.CreateFromFile(bundlePath + "/prefabs");
        }
        public static void OnRecievedAssetFromServerOrCache(string assetName, AssetBundle bundle)
        {
            Debug.Log(assetName);
            Debug.Log(bundle);

            if (bundle == null)
            {
                Debug.Log("Recived null asset");
            }

            string groupName = AssetGroupRefences[assetName];

            AssetObject newAssetObject = AssetGroups[groupName][assetName];

            if (bundle != null)
            {
                newAssetObject.asset = bundle.mainAsset;
                newAssetObject.bundle = bundle;
            }
            else
            {
                newAssetObject.asset = null;
                newAssetObject.bundle = null;
            }

            newAssetObject.isComplete = true;
            if (assetBundleTracker != null)
            {
                assetBundleTracker.addCompletedCount(groupName);
                assetBundleTracker.CheckIsCompletedAllDownloads(groupName);
            }
            newAssetObject.CallEvent();
        }
			/*--------------------------------------------------*/
			/// <summary>
			/// コンストラクタ.
			/// </summary>
			/// <param name="url"> 接続先. </param>
			/// <param name="version"> バージョン. </param>
			/// <param name="crc"> チェックサム. </param>
			/*--------------------------------------------------*/
			public AssetBundleRef(string url, int version, uint crc)
			{
				this.url = url;
				this.version = version;
				this.crc = crc;
				this.status = downloadStatus.none;
				this.bundle = null;
			}
		public GameObject Decorate(Dictionary<string, object> options, AssetBundle assetBundle)
		{
			var asset = UnityEngine.Object.Instantiate(assetBundle.LoadAsset((string)options["model"])) as GameObject;
			asset.gameObject.SetActive (false);
			this.Decorate (asset,options, assetBundle);
			AssetManager.Instance.registerObject (asset.gameObject.GetComponent<Product> ());
			return asset;
		}
 private UnityEngine.Object LoadFromBundle(AssetBundle bundle, string name)
 {
     #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
     return bundle.Load(name);
     #else
     return bundle.LoadAsset(name);
     #endif
 }
 public void Decorate(GameObject go, Dictionary<string, object> options, AssetBundle assetBundle)
 {
     switch (_type)
     {
         case "billboard":
             (new BillboardDecorator()).Decorate(go, options, assetBundle);
             break;
     }
 }
        protected virtual void Start()
        {
            string bundlePath = EngineerGlobals.AssemblyPath + "/AssetBundles/";

            images = AssetBundle.LoadFromFile(bundlePath + "/images");
            prefabs = AssetBundle.LoadFromFile(bundlePath + "/prefabs");

            MyLogger.Log(images);
        }
 /// <summary>
 /// 卸载资源
 /// </summary>
 /// <param name="bundle">卸载的资源</param>
 /// <param name="unload"></param>
 public static void UnLoadSource(AssetBundle bundle, bool unload)
 {
     if (bundle == null)
     {
         LCSConsole.WriteError("卸载资源为空!");
         return;
     }
     bundle.Unload(unload);
 }
 public void AddAssetBundle(string bundleName, AssetBundle bundle)
 {
     if (bundles.ContainsKey(bundleName)) {
         bundles[bundleName].Increase();
     }
     else {
         bundles.Add(bundleName, new AssetReference(bundle));
     }
 }
 //Start async load the assetbundle
 public static AsyncLoader StartLoad(AssetBundle asset, string resName , FINISH_CALLBACK finish_callback)
 {
     if(sGoInstance == null)
     {
         sGoInstance = new GameObject("AsyncLoader");
     }
     AsyncLoader loader = sGoInstance.AddComponent<AsyncLoader>();
     loader.StartCoroutine(loader.GoLoader(asset, resName,finish_callback));
     return loader;
 }
 public static bool PreviewAssetStoreAssetBundleInInspector(AssetBundle bundle, AssetStoreAsset info)
 {
   info.id = 0;
   info.previewAsset = bundle.mainAsset;
   AssetStoreAssetSelection.Clear();
   AssetStoreAssetSelection.AddAssetInternal(info);
   Selection.activeObject = (Object) AssetStoreAssetInspector.Instance;
   AssetStoreAssetInspector.Instance.Repaint();
   return true;
 }
 //finish callback
 protected void FinishCallback(string path , AssetBundle obj)
 {
     this.m_mapRes[path] = obj;
     this.m_iCompleteNum++;
     if(this.m_iCompleteNum == this.m_lstPath.Count)
     {
         if(this.m_delFinishCallback == null ) Debug.LogError("The finish callback is null.");
         else this.m_delFinishCallback(this.m_mapRes);
         GameObject.DestroyImmediate(this.gameObject);
     }
 }
        public void Decorate(GameObject go, Dictionary<string, object> options, AssetBundle assetBundle)
        {
            if (options.ContainsKey("seating_options"))
            {
                Dictionary<string, object> seatingOptions = options["seating_options"] as Dictionary<string, object>;

                go.AddComponent<Seating>();

                go.GetComponent<Seating>().hasBackRest = (bool)seatingOptions["has_back_rest"];
            }
        }
Beispiel #28
0
 public static UIPackage AddPackage(AssetBundle desc, AssetBundle res, string resourceNamePrefix)
 {
     #if UNITY_5
     byte[] bytes = desc.LoadAsset<TextAsset>(desc.GetAllAssetNames()[0]).bytes;
     #else
     byte[] bytes = ((TextAsset)desc.mainAsset).bytes;
     #endif
     if (desc != res)
         desc.Unload(true);
     return AddPackage(bytes, res, resourceNamePrefix);
 }
 static public int get_mainAsset(IntPtr l)
 {
     try {
         UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
         pushValue(l, self.mainAsset);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_isStreamedSceneAssetBundle(IntPtr l)
 {
     try {
         UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
         pushValue(l, self.isStreamedSceneAssetBundle);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #31
0
 /// <summary>
 /// Load and instantiate the named prefab, and set its parent game object.
 /// </summary>
 internal static GameObject Instantiate (GameObject parent, string prefabName)
 {
     if (prefabs == null) {
         var dir = System.IO.Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly ().Location);
         var path = System.IO.Path.Combine (dir, "KRPC.UI.ksp");
         prefabs = new WWW ("file://" + path).assetBundle;
     }
     var prefab = prefabs.LoadAsset<GameObject> (prefabName);
     var obj = UnityEngine.Object.Instantiate (prefab);
     obj.transform.SetParent (parent.transform, false);
     return obj;
 }
        public void Decorate(GameObject go, Dictionary<string, object> options, AssetBundle assetBundle)
        {
            foreach (Material material in AssetManager.Instance.objectMaterials)
            {
                if (material.name == "CustomColorsDiffuse")
                {
                    SetMaterial(go, material);

                    break;
                }
            }
        }
 static public int get_mainAsset(IntPtr l)
 {
     try {
         UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
         pushValue(l, self.mainAsset);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.AssetBundle o;
			o=new UnityEngine.AssetBundle();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
Beispiel #35
0
 /// <summary>
 /// 创建一个的LoadData
 /// </summary>
 /// <param name="fullName"></param>
 /// <param name="loadProgressNum"></param>
 /// <param name="error"></param>
 /// <param name="assetBundle"></param>
 /// <param name="unZipProgressNum"></param>
 /// <param name="objects"></param>
 /// <returns></returns>
 public static LoadData getLoadData(string fullName, float loadProgressNum = 0, string error = null,
     AssetBundle assetBundle = null, float unZipProgressNum = 0, Object[] assets = null)
 {
     LoadData data = new LoadData();
     data.fullName = fullName;
     data.loadProgressNum = loadProgressNum;
     data.error = error;
     data.assetBundle = assetBundle;
     data.unZipProgressNum = unZipProgressNum;
     data.assets = assets;
     return data;
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.AssetBundle o;
         o = new UnityEngine.AssetBundle();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int GetAllScenePaths(IntPtr l)
 {
     try {
         UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
         var ret = self.GetAllScenePaths();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.AssetBundle o;
         o=new UnityEngine.AssetBundle();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
 static public int GetAllAssetNames(IntPtr l)
 {
     try {
         UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
         var ret = self.GetAllAssetNames();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Beispiel #40
0
        private bool initManifest(string assetPath)
        {
            string path = assetPath + "/AssetBundles";

            UnityEngine.AssetBundle mainfest_bundle = UnityEngine.AssetBundle.LoadFromFile(path);
            if (mainfest_bundle != null)
            {
                manifest = (AssetBundleManifest)mainfest_bundle.LoadAsset("AssetBundleManifest");
                mainfest_bundle.Unload(false);
            }

            return(manifest != null);
        }
Beispiel #41
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.AssetBundle o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.AssetBundle();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.AssetBundle o;
         o = new UnityEngine.AssetBundle();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int Unload(IntPtr l)
 {
     try {
         UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
         System.Boolean          a1;
         checkType(l, 2, out a1);
         self.Unload(a1);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #44
0
        /// <summary>
        /// 异步任务转成同步
        /// </summary>
        /// <returns></returns>
        public bool ToSynchronizationTask()
        {
            if (AssetBundleRequest != null && !AssetBundleRequest.isDone)
            {
                // abRequest.assetBundle.Unload(true);
                //直接访问转为同步
                this.assetBundle = AssetBundleRequest.assetBundle;

                return(true);
            }

            return(false);
        }
Beispiel #45
0
 public void OnLoadDependencyAsset(string dependencyAssetName, UnityEngine.AssetBundle assetBundle)
 {
     if (m_MainTask != null)
     {
         m_MainTask.OnLoadDependencyAsset(dependencyAssetName, assetBundle);
         return;
     }
     m_DependencyAssets.Add(assetBundle);
     if (m_LoadAssetCallbacks.LoadAssetDependencyAssetCallback != null)
     {
         m_LoadAssetCallbacks.LoadAssetDependencyAssetCallback(AssetName, dependencyAssetName, LoadedDependencyAssetCount, TotalDependencyAssetCount, UserData);
     }
 }
Beispiel #46
0
 /// <summary>
 /// 加载
 /// </summary>
 /// <param name="path"></param>
 public void Load()
 {
     if (!this.isStartLoading)
     {
         this.isStartLoading = true;
         this.assetBundle    = UnityEngine.AssetBundle.LoadFromFile(LocalPath, crc, offset);
         this.isDone         = true;
     }
     else
     {
         Debug.LogError("Task is loading!");
     }
 }
        public void Decorate(GameObject go, Dictionary<string, object> options, AssetBundle assetBundle)
        {
            go.AddComponent<Deco>();

            if (options.ContainsKey("heightDelta"))
                (new HeightDecorator((double)options["heightDelta"])).Decorate(go, options, assetBundle);

            if (options.ContainsKey("gridSubdivision"))
                (new GridSubdivisionDecorator((double)options["gridSubdivision"])).Decorate(go, options, assetBundle);

            if (options.ContainsKey("snapCenter"))
                (new SnapToCenterDecorator((bool)options["snapCenter"])).Decorate(go, options, assetBundle);
        }
 static public int Contains(IntPtr l)
 {
     try {
         UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
         System.String           a1;
         checkType(l, 2, out a1);
         var ret = self.Contains(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #49
0
 static public int CreateFromFile_s(IntPtr l)
 {
     try{
         System.String a1;
         checkType(l, 1, out a1);
         UnityEngine.AssetBundle ret = UnityEngine.AssetBundle.CreateFromFile(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Beispiel #50
0
 static public int Contains(IntPtr l)
 {
     try{
         UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
         System.String           a1;
         checkType(l, 2, out a1);
         System.Boolean ret = self.Contains(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
        /// <summary>
        /// Loads the asset bundle asynchronously, returns the loaded object.
        /// </summary>
        public async Task <UnityEngine.AssetBundle> LoadAsync()
        {
            await _locker.LockAsync(async() =>
            {
                if (UnityAssetBundle != null)
                {
                    return;
                }

                Debug.Log("#Delight# Loading asset bundle: " + Id);

                // get bundle URI
                var bundleBaseUri = StorageMode == StorageMode.Remote ?
                                    Config.ServerUriLocator.GetServerUri(Id) : Application.streamingAssetsPath;
                if (!bundleBaseUri.EndsWith("/"))
                {
                    bundleBaseUri += "/";
                }

                var bundleUri = string.Empty;
                if (StorageMode == StorageMode.Remote)
                {
                    bundleUri = String.Format("{0}{1}{2}{3}", bundleBaseUri, AssetBundleData.GetPlatformName() + "/", DelightAssetsFolder, Id.ToLower());
                }
                else
                {
                    bundleUri = String.Format("{0}{1}{2}", bundleBaseUri, DelightAssetsFolder, Id.ToLower());
                }

                // get asset bundle
                var version          = Version > 0 ? Version : Config.AssetBundleVersion;
                var getBundleRequest = version > 0 ? UnityWebRequestAssetBundle.GetAssetBundle(bundleUri, version, 0) :
                                       UnityWebRequestAssetBundle.GetAssetBundle(bundleUri);
                var response = (await getBundleRequest.SendWebRequest()) as UnityWebRequestAsyncOperation;
                if (response.webRequest.isNetworkError || response.webRequest.isHttpError)
                {
                    Debug.Log(String.Format("#Delight# Failed to load asset bundle \"{0}\" from URI \"{1}\".", Id, bundleUri));
                    return;
                }

                // simulate slow load
                // await Task.Delay(1500); // TODO remove

                UnityAssetBundle = DownloadHandlerAssetBundle.GetContent(response.webRequest);
            });

            return(UnityAssetBundle);
        }
 static public int LoadAsync(IntPtr l)
 {
     try {
         UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
         System.String           a1;
         checkType(l, 2, out a1);
         System.Type a2;
         checkType(l, 3, out a2);
         var ret = self.LoadAsync(a1, a2);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #53
0
 static public int LoadAsync(IntPtr l)
 {
     try{
         UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l);
         System.String           a1;
         checkType(l, 2, out a1);
         System.Type a2;
         checkType(l, 3, out a2);
         UnityEngine.AssetBundleRequest ret = self.LoadAsync(a1, a2);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Beispiel #54
0
    static int get_assetBundle(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.WWW         obj = (UnityEngine.WWW)o;
            UnityEngine.AssetBundle ret = obj.assetBundle;
            ToLua.PushSealed(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index assetBundle on a nil value"));
        }
    }
Beispiel #55
0
        /// <summary>
        ///   载入Manifest
        /// </summary>
        public static AssetBundleManifest LoadMainManifestByPath(string full_name)
        {
            if (!System.IO.File.Exists(full_name))
            {
                return(null);
            }

            AssetBundleManifest manifest = null;

            UnityEngine.AssetBundle mainfest_bundle = UnityEngine.AssetBundle.LoadFromFile(full_name);
            if (mainfest_bundle != null)
            {
                manifest = (AssetBundleManifest)mainfest_bundle.LoadAsset("AssetBundleManifest");
                mainfest_bundle.Unload(false);
            }

            return(manifest);
        }
Beispiel #56
0
        /// <summary>
        /// Registers load object.
        /// </summary>
        public void UnregisterReference(object referenceObject)
        {
            if (LoadMode != LoadMode.Automatic)
            {
                return;
            }

            _referenceObjects.Remove(referenceObject.GetHashCode());
            List <int> deadReferences = null;

            foreach (var refObjects in _referenceObjects)
            {
                if (refObjects.Value.IsAlive)
                {
                    continue;
                }

                if (deadReferences == null)
                {
                    deadReferences = new List <int>();
                }
                deadReferences.Add(refObjects.Value.Target.GetHashCode());
            }

            if (deadReferences != null)
            {
                foreach (var deadReference in deadReferences)
                {
                    _referenceObjects.Remove(deadReference);
                }
            }

            if (_referenceObjects.Count <= 0 && UnityAssetBundle != null)
            {
                // unload bundle
                UnityAssetBundle.Unload(true);
                UnityAssetBundle = null;

                Debug.Log("#Delight# Unloading asset bundle: " + Id);
            }
        }
Beispiel #57
0
        private void ReassignShader(UnityEngine.AssetBundle assetBundle)
        {
            if (assetBundle.isStreamedSceneAssetBundle)
            {
                return;
            }

            Material[] materials   = assetBundle.LoadAllAssets <Material>();
            Shader     cacheShader = null;

            for (int i = 0; i < materials.Length; i++)
            {
                cacheShader = materials[i].shader;
                if (cacheShader == null)
                {
                    continue;
                }

                materials[i].shader = Shader.Find(cacheShader.name);
            }
        }
Beispiel #58
0
    static int LoadFromFile(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(string)))
            {
                string arg0 = ToLua.ToString(L, 1);
                UnityEngine.AssetBundle o = UnityEngine.AssetBundle.LoadFromFile(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(string), typeof(uint)))
            {
                string arg0 = ToLua.ToString(L, 1);
                uint   arg1 = (uint)LuaDLL.lua_tonumber(L, 2);
                UnityEngine.AssetBundle o = UnityEngine.AssetBundle.LoadFromFile(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(string), typeof(uint), typeof(ulong)))
            {
                string arg0 = ToLua.ToString(L, 1);
                uint   arg1 = (uint)LuaDLL.lua_tonumber(L, 2);
                ulong  arg2 = LuaDLL.tolua_touint64(L, 3);
                UnityEngine.AssetBundle o = UnityEngine.AssetBundle.LoadFromFile(arg0, arg1, arg2);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.AssetBundle.LoadFromFile"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    static int LoadFromStream(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                System.IO.Stream        arg0 = (System.IO.Stream)ToLua.CheckObject <System.IO.Stream>(L, 1);
                UnityEngine.AssetBundle o    = UnityEngine.AssetBundle.LoadFromStream(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 2)
            {
                System.IO.Stream        arg0 = (System.IO.Stream)ToLua.CheckObject <System.IO.Stream>(L, 1);
                uint                    arg1 = (uint)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.AssetBundle o    = UnityEngine.AssetBundle.LoadFromStream(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 3)
            {
                System.IO.Stream        arg0 = (System.IO.Stream)ToLua.CheckObject <System.IO.Stream>(L, 1);
                uint                    arg1 = (uint)LuaDLL.luaL_checknumber(L, 2);
                uint                    arg2 = (uint)LuaDLL.luaL_checknumber(L, 3);
                UnityEngine.AssetBundle o    = UnityEngine.AssetBundle.LoadFromStream(arg0, arg1, arg2);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.AssetBundle.LoadFromStream"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    static int LoadFromFile(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                string arg0 = ToLua.CheckString(L, 1);
                UnityEngine.AssetBundle o = UnityEngine.AssetBundle.LoadFromFile(arg0);
                ToLua.PushSealed(L, o);
                return(1);
            }
            else if (count == 2)
            {
                string arg0 = ToLua.CheckString(L, 1);
                uint   arg1 = (uint)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.AssetBundle o = UnityEngine.AssetBundle.LoadFromFile(arg0, arg1);
                ToLua.PushSealed(L, o);
                return(1);
            }
            else if (count == 3)
            {
                string arg0 = ToLua.CheckString(L, 1);
                uint   arg1 = (uint)LuaDLL.luaL_checknumber(L, 2);
                ulong  arg2 = LuaDLL.tolua_checkuint64(L, 3);
                UnityEngine.AssetBundle o = UnityEngine.AssetBundle.LoadFromFile(arg0, arg1, arg2);
                ToLua.PushSealed(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.AssetBundle.LoadFromFile"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }