UnityNativeShare icon indicating copy to clipboard operation
UnityNativeShare copied to clipboard

Can't share my own image

Open Eloren1 opened this issue 6 years ago • 5 comments

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

Eloren1 avatar Mar 15 '20 10:03 Eloren1

Where is this file located at?

yasirkula avatar Mar 15 '20 11:03 yasirkula

I can place this banner everywhere

Eloren1 avatar Mar 15 '20 12:03 Eloren1

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

yasirkula avatar Mar 15 '20 12:03 yasirkula

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

Eloren1 avatar Mar 15 '20 12:03 Eloren1

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.

yasirkula avatar Mar 15 '20 13:03 yasirkula