forked from MattRix/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDownloadHandler.cs
More file actions
141 lines (120 loc) · 2.98 KB
/
Copy pathDownloadHandler.cs
File metadata and controls
141 lines (120 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using UnityEngine.Scripting;
namespace UnityEngine.Networking
{
[StructLayout(LayoutKind.Sequential)]
public class DownloadHandler : IDisposable
{
[NonSerialized]
internal IntPtr m_Ptr;
public extern bool isDone
{
[GeneratedByOldBindingsGenerator]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}
public byte[] data
{
get
{
return this.GetData();
}
}
public string text
{
get
{
return this.GetText();
}
}
internal DownloadHandler()
{
}
[GeneratedByOldBindingsGenerator]
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern void InternalCreateBuffer();
[GeneratedByOldBindingsGenerator]
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern void InternalCreateScript();
[GeneratedByOldBindingsGenerator]
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern void InternalCreateTexture(bool readable);
[GeneratedByOldBindingsGenerator]
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern void InternalCreateAssetBundle(string url, uint crc);
internal void InternalCreateAssetBundle(string url, Hash128 hash, uint crc)
{
DownloadHandler.INTERNAL_CALL_InternalCreateAssetBundle(this, url, ref hash, crc);
}
[GeneratedByOldBindingsGenerator]
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void INTERNAL_CALL_InternalCreateAssetBundle(DownloadHandler self, string url, ref Hash128 hash, uint crc);
[GeneratedByOldBindingsGenerator, ThreadAndSerializationSafe]
[MethodImpl(MethodImplOptions.InternalCall)]
private extern void InternalDestroy();
~DownloadHandler()
{
this.InternalDestroy();
}
public void Dispose()
{
this.InternalDestroy();
GC.SuppressFinalize(this);
}
protected virtual byte[] GetData()
{
return null;
}
protected virtual string GetText()
{
byte[] data = this.GetData();
string result;
if (data != null && data.Length > 0)
{
result = Encoding.UTF8.GetString(data, 0, data.Length);
}
else
{
result = "";
}
return result;
}
[UsedByNativeCode]
protected virtual bool ReceiveData(byte[] data, int dataLength)
{
return true;
}
[UsedByNativeCode]
protected virtual void ReceiveContentLength(int contentLength)
{
}
[UsedByNativeCode]
protected virtual void CompleteContent()
{
}
[UsedByNativeCode]
protected virtual float GetProgress()
{
return 0f;
}
protected static T GetCheckedDownloader<T>(UnityWebRequest www) where T : DownloadHandler
{
if (www == null)
{
throw new NullReferenceException("Cannot get content from a null UnityWebRequest object");
}
if (!www.isDone)
{
throw new InvalidOperationException("Cannot get content from an unfinished UnityWebRequest object");
}
if (www.isError)
{
throw new InvalidOperationException(www.error);
}
return (T)((object)www.downloadHandler);
}
}
}