Inheritance: AsyncOperation
示例#1
0
文件: Asset.cs 项目: K-Yoshiki/menko
		public Asset(UnityObject asset, string path, Action<Asset> unloaded)
		{
			this.path = path;
			this.asset = asset;
			this.unloaded = unloaded;
			this.request = null;
		}
示例#2
0
    static int LoadAsync(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                string arg0 = ToLua.CheckString(L, 1);
                UnityEngine.ResourceRequest o = UnityEngine.Resources.LoadAsync(arg0);
                ToLua.PushSealed(L, o);
                return(1);
            }
            else if (count == 2)
            {
                string      arg0 = ToLua.CheckString(L, 1);
                System.Type arg1 = ToLua.CheckMonoType(L, 2);
                UnityEngine.ResourceRequest o = UnityEngine.Resources.LoadAsync(arg0, arg1);
                ToLua.PushSealed(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Resources.LoadAsync"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    static int LoadAsync(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1 && TypeChecker.CheckTypes(L, typeof(string)))
            {
                string arg0 = ToLua.ToString(L, 1);
                UnityEngine.ResourceRequest o = UnityEngine.Resources.LoadAsync(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, typeof(string), typeof(System.Type)))
            {
                string      arg0 = ToLua.ToString(L, 1);
                System.Type arg1 = (System.Type)ToLua.ToObject(L, 2);
                UnityEngine.ResourceRequest o = UnityEngine.Resources.LoadAsync(arg0, arg1);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Resources.LoadAsync"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.ResourceRequest o;
         o = new UnityEngine.ResourceRequest();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
示例#5
0
文件: Asset.cs 项目: K-Yoshiki/menko
		public Asset(ResourceRequest request, string path, Action<Asset> unloaded)
		{
			this.path = path;
			this.request = request;
			this.unloaded = unloaded;
			this.asset = null;
		}
// fields

// properties
    static void ResourceRequest_asset(JSVCall vc)
    {
        UnityEngine.ResourceRequest _this = (UnityEngine.ResourceRequest)vc.csObj;
        var result = _this.asset;

        JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
    }
 static public int LoadAsync_s(IntPtr l)
 {
     try{
         if (matchType(l, 1, typeof(string)))
         {
             System.String a1;
             checkType(l, 1, out a1);
             UnityEngine.ResourceRequest ret = UnityEngine.Resources.LoadAsync(a1);
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, 1, typeof(string), typeof(System.Type)))
         {
             System.String a1;
             checkType(l, 1, out a1);
             System.Type a2;
             checkType(l, 2, out a2);
             UnityEngine.ResourceRequest ret = UnityEngine.Resources.LoadAsync(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 int LoadAsync(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.Resources.Register");
#endif
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                string arg0 = ToLua.CheckString(L, 1);
                UnityEngine.ResourceRequest o = UnityEngine.Resources.LoadAsync(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 2)
            {
                string      arg0 = ToLua.CheckString(L, 1);
                System.Type arg1 = ToLua.CheckMonoType(L, 2);
                UnityEngine.ResourceRequest o = UnityEngine.Resources.LoadAsync(arg0, arg1);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Resources.LoadAsync"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
示例#9
0
            internal ResourceRequest(UnityResourceRequest request)
            {
                this.request       = request;
                request.completed += (_) =>
                {
                    LookupTable <T> .MoveFromAsyncToSync((string)GetPathFromResourceRequest(this.request), asset);

                    completedInner(this);
                };
            }
示例#10
0
 IEnumerator LoadAsync(string prefabPath)
 {
     request = Resources.LoadAsync<GameObject>(prefabPath);
     while (!request.isDone)
     {
         Debug.Log(request.isDone);
         yield return 0;
     }
     Debug.Log("ok" + request);
     //go = (GameObject)Instantiate(request.asset);
 }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.ResourceRequest o;
			o=new UnityEngine.ResourceRequest();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
示例#12
0
 static public int get_asset(IntPtr l)
 {
     try {
         UnityEngine.ResourceRequest self = (UnityEngine.ResourceRequest)checkSelf(l);
         pushValue(l, self.asset);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int get_asset(IntPtr l)
 {
     try {
         UnityEngine.ResourceRequest self = (UnityEngine.ResourceRequest)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.asset);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#14
0
    private void Stream()
    {
        resourceRequest = Resources.LoadAsync(mapSegmentName, typeof(GameObject));

        if (resourceRequest != null)
        {
            if (resourceRequest.isDone && mapSegmentObject == null)
            {
                mapSegmentObject = Instantiate(resourceRequest.asset) as GameObject;
                mapSegmentObject.transform.SetParent(this.transform);
            }
        }
    }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.ResourceRequest o;
         o=new UnityEngine.ResourceRequest();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.ResourceRequest o;
         o = new UnityEngine.ResourceRequest();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#17
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.ResourceRequest o;
         o = new UnityEngine.ResourceRequest();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
示例#18
0
    // Update is called once per frame
    void Update()
    {
        if (!audioSource.isPlaying)
        {
            if (nextSong == null)
                print("Next track failed to load properly.");

            currentSong = nextSong;
            audioSource.PlayOneShot(currentSong);

            nextSongRequest = Resources.LoadAsync<AudioClip>(GetNextSongPath());
            StartCoroutine(LoadNextSong());            
        }
    }
    static int get_asset(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.ResourceRequest obj = (UnityEngine.ResourceRequest)o;
            UnityEngine.Object          ret = obj.asset;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index asset on a nil value"));
        }
    }
    IEnumerator LoadAnimClip(string clipName, string boolName)
    {
        request = Resources.LoadAsync("Animations/" + clipName);

        yield return request;

        AnimationClip animClip = request.asset as AnimationClip;

        overrideController[clipName + " Empty"] = animClip;

        // Push back state
        for (int i = 0; i < animator.layerCount; i++)
        {
            animator.Play(layerInfo[i].nameHash, i, layerInfo[i].normalizedTime);
        }

        // Force an update
        animator.Update(0.0f);

        //		animator.SetBool(boolName, true);
    }
示例#21
0
    // Use this for initialization
    void Start()
    {
        //Collect all song files from Music dir
        var musicDir = new DirectoryInfo(fullPathToMusicFolder);
        var musicFiles = musicDir.GetFiles();
        var tempList = new List<string>();
        foreach (FileInfo file in musicFiles)
        {
            if (file.Extension != ".meta")
            {
                tempList.Add(Path.GetFileNameWithoutExtension(file.FullName));
            }
        }

        playList = tempList.ToArray();
        audioSource = GetComponent<AudioSource>();
        currentSong = Resources.Load<AudioClip>(GetNextSongPath());
        audioSource.PlayOneShot(currentSong);
        nextSongRequest = Resources.LoadAsync<AudioClip>(GetNextSongPath());
        StartCoroutine(LoadNextSong());
    }
    static int _CreateUnityEngine_ResourceRequest(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                UnityEngine.ResourceRequest obj = new UnityEngine.ResourceRequest();
                ToLua.PushSealed(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.ResourceRequest.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
示例#23
0
    private void StreamOnPlay()
    {
        if (distanceToPlayer <= StreamingManager.Instance.StreamingDistance & resourceRequest == null)
        {
            if (StreamingManager.Instance.StreamingLoging == true)
            {
                Debug.Log(startLoading + ": " + this.mapSegmentName);
            }

            resourceRequest = Resources.LoadAsync(mapSegmentName, typeof(GameObject));
        }

        if (resourceRequest != null)
        {
            if (resourceRequest.isDone && mapSegmentObject == null)
            {
                if (StreamingManager.Instance.StreamingLoging == true)
                {
                    Debug.Log(loadingDone + ": " + this.mapSegmentName);
                }

                mapSegmentObject = Instantiate(resourceRequest.asset) as GameObject;
                mapSegmentObject.transform.SetParent(this.transform);
            }
        }

        if (distanceToPlayer > StreamingManager.Instance.StreamingDistance & mapSegmentObject != null)
        {
            if (StreamingManager.Instance.StreamingLoging == true)
            {
                Debug.Log(unloading + ": " + this.mapSegmentName);
            }

            GameObject.Destroy(mapSegmentObject);
            resourceRequest = null;
        }
    }
		public bool loadResourceAsynch()
		{
			switch (storeAsset.Type)
			{
			case VariableType.GameObject:
				_request = Resources.LoadAsync(assetPath.Value, typeof(GameObject));

				break;
			case VariableType.Texture:
				_request = Resources.LoadAsync(assetPath.Value, typeof(Texture2D));

				break;
			case VariableType.Material:
				_request = Resources.LoadAsync(assetPath.Value, typeof(Material));

				break;
			case VariableType.String:
				_request = Resources.LoadAsync(assetPath.Value, typeof(TextAsset));

				break;
			case VariableType.Object:
				_objectVar = this.Fsm.Variables.GetFsmObject(storeAsset.variableName); 
				_request = Resources.LoadAsync(assetPath.Value,_objectVar.ObjectType);

				break;
			default:
				// not supported.
				return false;
			}

			return true;
		}
 public void UpdateProgress(ResourceRequest resourceRequest)
 {
     isDone = resourceRequest.isDone;
     progress = resourceRequest.progress;
 }
示例#26
0
 /// <summary>
 /// 直接从 Resources 文件夹下加载资源
 /// </summary>
 /// <param name="request"></param>
 /// <param name="callback"></param>
 /// <returns></returns>
 private IEnumerator StartLoad(ResourceRequest request, LoadSourceEntity entity, Action<LoadSourceEntity> callback)
 {
     if (entity == null) yield return 0;
     if (request == null)
     {
         LCSConsole.WriteError("异步加载 ResourceRequest 不存在!, request = null");
         yield return 0;
     }
     yield return request;
     if (callback == null) yield return 0;
     entity.LoadObj = request.asset;
     callback(entity);
 }
示例#27
0
 private void Awake()
 {
     CoopPeerStarter.Dedicated = false;
     CoopPeerStarter.DedicatedHost = false;
     UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
     this.PrefabDbResource = Resources.LoadAsync<PrefabDatabase>("BoltPrefabDatabase");
     BoltLauncher.SetUdpPlatform(new SteamPlatform());
     TheForest.Utils.Input.player.controllers.maps.SetMapsEnabled(true, ControllerType.Joystick, "Menu");
     if (!SteamManager.Initialized)
     {
         if (TitleScreen.StartGameSetup.MpType == TitleScreen.GameSetup.MpTypes.Server)
         {
             this.OpenScreen(CoopSteamNGUI.Screens.LobbySetup);
         }
         else
         {
             this.OpenScreen(CoopSteamNGUI.Screens.GameBrowser);
         }
         this.SetLoadingText("Steam not initialized");
         return;
     }
     this.RefreshUI();
     if (TitleScreen.StartGameSetup.MpType == TitleScreen.GameSetup.MpTypes.Server)
     {
         this._hostGameName = PlayerPrefs.GetString("MpGameName", this._hostGameName);
         this._hostMaxPlayers = PlayerPrefs.GetInt("MpGamePlayerCount", this.GetHostPlayersMax()).ToString();
         this._hostFriendsOnly = (PlayerPrefs.GetInt("MpGameFriendsOnly", (!this._hostFriendsOnly) ? 0 : 1) == 1);
         this._lobbySetupScreen._gameNameInput.value = this._hostGameName;
         this._lobbySetupScreen._playerCountInput.value = this._hostMaxPlayers;
         this._lobbySetupScreen._privateOnlyToggle.value = this._hostFriendsOnly;
         this.OpenScreen(CoopSteamNGUI.Screens.LobbySetup);
     }
     else
     {
         CoopLobbyManager.QueryList();
         this.OpenScreen(CoopSteamNGUI.Screens.GameBrowser);
     }
     if (AutoJoinAfterMPInvite.LobbyID != null && (CoopLobby.Instance == null || CoopLobby.Instance.Info.LobbyId.ToString() != AutoJoinAfterMPInvite.LobbyID))
     {
         CoopLobbyInfo lobby = new CoopLobbyInfo(ulong.Parse(AutoJoinAfterMPInvite.LobbyID));
         AutoJoinAfterMPInvite.LobbyID = null;
         if (TitleScreen.StartGameSetup.Type == TitleScreen.GameSetup.InitTypes.Continue)
         {
             this.OnClientContinueGame(lobby);
         }
         else
         {
             this.OnClientNewGame(lobby);
         }
     }
 }
示例#28
0
 public void LoadAsync()
 {
     request = type == null ? Resources.LoadAsync(assetFullName) : Resources.LoadAsync(assetFullName,type);
 }
示例#29
0
        /// <summary>
        /// Load this asset from request.
        /// </summary>
        public void Load()
        {
            if(assetType==null)
            {
                assetType=typeof(GameObject);
            }

            request=Resources.LoadAsync(assetName,assetType);
        }
示例#30
0
 public LoadAssetInfo(ResourceRequest _request, string _assetName)
 {
     this.request = _request;
     this.assetName = _assetName;
 }