gkngkc / UnityStandaloneFileBrowser

A native file browser for unity standalone platforms
MIT License
2.01k stars 317 forks source link

Is there a way to load local image with only file path string in WebGL? #21

Open HiddenStar0412 opened 6 years ago

HiddenStar0412 commented 6 years ago

I am going to load local image files in web GL. I use file path string without open dialog. Is it possible with your code?

what does it means? What is the parameter of "UploadFile" method? [DllImport("__Internal")] private static extern void UploadFile(string id); public void OnPointerDown(PointerEventData eventData) { UploadFile(gameObject.name); }

gkngkc commented 6 years ago

Yes it can be done, see live demo

UploadFile is the js extension method and uses UnitySendMessage to communicate with C# code. Parameter is the name of gameobject and plugin calls that gameobject's "OnFileUploaded" method with a url. ( OnFileUploaded is hardcoded into js extension but you can change -or parameterize- it if you want)