1using System.Collections;
6#if UNITY_5_3 || UNITY_5_3_OR_NEWER
20 Debug.Log(
"WebGLFileUploadManager.getOS: " + WebGLFileUploadManager.getOS);
21 Debug.Log(
"WebGLFileUploadManager.isMOBILE: " + WebGLFileUploadManager.IsMOBILE);
22 Debug.Log(
"WebGLFileUploadManager.getUserAgent: " + WebGLFileUploadManager.GetUserAgent);
24 WebGLFileUploadManager.SetDebug(
true);
26 #
if UNITY_WEBGL && !UNITY_EDITOR
27 WebGLFileUploadManager.IsMOBILE
29 Application.isMobilePlatform
32 WebGLFileUploadManager.Show (
false);
33 WebGLFileUploadManager.SetDescription(
"Select image files (.png|.jpg|.gif)");
36 WebGLFileUploadManager.Show (
true);
37 WebGLFileUploadManager.SetDescription(
"Drop image files (.png|.jpg|.gif) here");
39 WebGLFileUploadManager.SetImageEncodeSetting(
true);
40 WebGLFileUploadManager.SetAllowedFileName(
"\\.(png|jpe?g|gif)$");
41 WebGLFileUploadManager.SetImageShrinkingSize(1280 ,960);
42 WebGLFileUploadManager.onFileUploaded += OnFileUploaded;
56 WebGLFileUploadManager.onFileUploaded -= OnFileUploaded;
57 WebGLFileUploadManager.Dispose();
66 if(result.Length == 0) {
67 Debug.Log(
"File upload Error!");
69 Debug.Log(
"File upload success! (result.Length: " + result.Length +
")");
72 foreach(var file
in result){
74 Debug.Log(
"file.filePath: " + file.filePath +
" exists:" + File.Exists(file.filePath));
76 Texture2D texture =
new Texture2D (2, 2);
77 byte[] byteArray = File.ReadAllBytes (file.filePath);
78 texture.LoadImage (byteArray);
79 gameObject.GetComponent<Renderer> ().material.mainTexture = texture;
81 Debug.Log(
"File.ReadAllBytes:byte[].Length: " + byteArray.Length);
93 #if UNITY_5_3 || UNITY_5_3_OR_NEWER
94 SceneManager.LoadScene (
"WebGLFileUploaderExample");
96 Application.LoadLevel (
"WebGLFileUploaderExample");
105 WebGLFileUploadManager.Show(
false, !WebGLFileUploadManager.IsOverlay);
113 WebGLFileUploadManager.Show(
true, !WebGLFileUploadManager.IsOverlay);
121 WebGLFileUploadManager.PopupDialog(
null,
"Select image files (.png|.jpg|.gif)");
129 WebGLFileUploadManager.Enable ();
137 WebGLFileUploadManager.Disable ();
void OnDisableButtonClick()
Raises the disable button click event.
void OnEnableButtonClick()
Raises the enable button click event.
void OnBackButtonClick()
Raises the back button click event.
void OnSwitchButtonOverlayStateButtonClick()
Raises the switch button overlay state button click event.
void OnSwitchDropOverlayStateButtonClick()
Raises the switch drop overlay state button click event.
void OnPopupDialogButtonClick()
Raises the popup dialog button click event.