yasirkula / UnityNativeShare

A Unity plugin to natively share files (images, videos, documents, etc.) and/or plain text on Android & iOS
MIT License
891 stars 131 forks source link

Can't share my own image #65

Closed Eloren1 closed 3 years ago

Eloren1 commented 4 years ago

I don't want to take a screenshot, how can I share my own banner.png? Where should I place it?

new NativeShare().AddFile("\\banner.png").SetSubject("Subject goes here").SetText("Download this game!").Share();

It doesn't work

yasirkula commented 4 years ago

Where is this file located at?

Eloren1 commented 4 years ago

I can place this banner everywhere

yasirkula commented 4 years ago

You should place/save it to Application.temporaryCachePath and put its filepath to AddFile.

Eloren1 commented 4 years ago

I don't know how to do this... I thought I need just put my banner.png to Assets\Sprites\Share and set this path

yasirkula commented 4 years ago

You can change the file's extension to .bytes, assign it to a public TextAsset variable, and then call File.WriteAllBytes with the TextAsset's bytes property to create a file using it.

Alternatively, you can put the file inside StreamingAssets folder and copy it to temporaryCachePath or persistentDataPath: https://forum.unity.com/threads/native-share-for-android-ios-open-source.519865/page-3#post-3917233. But I'd recommend the first approach when possible.