File tree Expand file tree Collapse file tree 3 files changed +38
-12
lines changed
Assets/StandaloneFileBrowser/Sample Expand file tree Collapse file tree 3 files changed +38
-12
lines changed Original file line number Diff line number Diff line change 55using UnityEngine ;
66using UnityEngine . UI ;
77using UnityEngine . EventSystems ;
8+ using UnityEngine . Networking ;
89using SFB ;
910
1011[ RequireComponent ( typeof ( Button ) ) ]
@@ -46,8 +47,16 @@ private void OnClick() {
4647#endif
4748
4849 private IEnumerator OutputRoutine ( string url ) {
49- var loader = new WWW ( url ) ;
50- yield return loader ;
51- output . texture = loader . texture ;
50+ UnityWebRequest www = UnityWebRequestTexture . GetTexture ( url ) ;
51+ yield return www . SendWebRequest ( ) ;
52+
53+ if ( www . result != UnityWebRequest . Result . Success )
54+ {
55+ Debug . LogError ( www . error ) ;
56+ }
57+ else
58+ {
59+ output . texture = ( ( DownloadHandlerTexture ) www . downloadHandler ) . texture ;
60+ }
5261 }
5362}
Original file line number Diff line number Diff line change 55using UnityEngine ;
66using UnityEngine . UI ;
77using UnityEngine . EventSystems ;
8+ using UnityEngine . Networking ;
89using SFB ;
910
1011[ RequireComponent ( typeof ( Button ) ) ]
@@ -46,8 +47,16 @@ private void OnClick() {
4647#endif
4748
4849 private IEnumerator OutputRoutine ( string url ) {
49- var loader = new WWW ( url ) ;
50- yield return loader ;
51- output . text = loader . text ;
50+ UnityWebRequest www = UnityWebRequest . Get ( url ) ;
51+ yield return www . SendWebRequest ( ) ;
52+
53+ if ( www . result != UnityWebRequest . Result . Success )
54+ {
55+ Debug . LogError ( www . error ) ;
56+ }
57+ else
58+ {
59+ output . text = www . downloadHandler . text ;
60+ }
5261 }
5362}
Original file line number Diff line number Diff line change 1- using System . Text ;
21using System . Collections ;
32using System . Collections . Generic ;
4- using System . Runtime . InteropServices ;
53using UnityEngine ;
64using UnityEngine . UI ;
75using UnityEngine . EventSystems ;
6+ using UnityEngine . Networking ;
87using SFB ;
98
109[ RequireComponent ( typeof ( Button ) ) ]
@@ -52,10 +51,19 @@ private void OnClick() {
5251
5352 private IEnumerator OutputRoutine ( string [ ] urlArr ) {
5453 var outputText = "" ;
55- for ( int i = 0 ; i < urlArr . Length ; i ++ ) {
56- var loader = new WWW ( urlArr [ i ] ) ;
57- yield return loader ;
58- outputText += loader . text ;
54+ for ( int i = 0 ; i < urlArr . Length ; i ++ )
55+ {
56+ UnityWebRequest www = UnityWebRequest . Get ( urlArr [ i ] ) ;
57+ yield return www . SendWebRequest ( ) ;
58+
59+ if ( www . result != UnityWebRequest . Result . Success )
60+ {
61+ Debug . LogError ( www . error ) ;
62+ }
63+ else
64+ {
65+ outputText += www . downloadHandler . text ;
66+ }
5967 }
6068 output . text = outputText ;
6169 }
You can’t perform that action at this time.
0 commit comments