// Raw binary data
        public override void OnGetData(DataPackage package, FilePath path)
        {
            // Get the bytes:
            byte[] data = System.IO.File.ReadAllBytes(path.Path);

            // Let the package know:
            package.GotData(data, null);
        }
		// Raw binary data
		public override void OnGetData(DataPackage package,FilePath path){
			
			// Get the bytes:
			byte[] data=System.IO.File.ReadAllBytes(path.Path);
			
			// Let the package know:
			package.GotData(data,null);
			
		}
		public override void OnGetData(DataPackage package,FilePath path){
			
			if(Callback.WillDelay){
				
				// Buffer this call until later - we're not on the main thread.
				
				// Create the callback:
				ResourcesProtocolCallback callback=new ResourcesProtocolCallback(package,path);
				
				// Hook up the protocol handler for speed later:
				callback.Protocol=this;
				
				// Request it to run:
				callback.Go();
				
				return;
			}
			
			// Getting a files text content from resources.
			byte[] data=null;
			string error=null;
			string resPath=path.Path;
			
			TextAsset asset=(TextAsset)Resources.Load(resPath);
			
			if(asset==null){
				
				error="File not found in resources ("+path.Directory+path.Filename+" from URL '"+path.Url+"'). Does your file in Unity end with .bytes?";
				
			}else{
				data=asset.bytes;
			}
			
			package.GotData(data,error);
			
		}
예제 #4
0
        private void GotDataResult(HttpRequest request)
        {
            DataPackage package = (DataPackage)request.ExtraData;

            package.GotData(request.Bytes, request.Error);
        }