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

Addfile problem #67

Closed netkingZ closed 4 years ago

netkingZ commented 4 years ago

Hello , i have a problem ... "this is the error: error CS1061: 'NativeShare' does not contain a definition for 'AddFile' and no accessible extension method 'AddFile' accepting a first argument of type 'NativeShare' could be found (are you missing a using directive or an assembly reference?) " how can fix it? I have imported the last version of files from github link.

This is my code:

void Update() { if( Input.GetMouseButtonDown( 0 ) ) StartCoroutine( TakeSSAndShare() ); }

private IEnumerator TakeSSAndShare()
{
    yield return new WaitForEndOfFrame();

    Texture2D ss = new Texture2D( Screen.width, Screen.height, TextureFormat.RGB24, false );
    ss.ReadPixels( new Rect( 0, 0, Screen.width, Screen.height ), 0, 0 );
    ss.Apply();

    string filePath = Path.Combine( Application.temporaryCachePath, "shared img.png" );
    File.WriteAllBytes( filePath, ss.EncodeToPNG() );

    // To avoid memory leaks
    Destroy( ss );

    new NativeShare().AddFile( filePath ).SetSubject( "Subject goes here" ).SetText( "Hello world!" ).Share();

    // Share on WhatsApp only, if installed (Android only)
    //if( NativeShare.TargetExists( "com.whatsapp" ) )
    //  new NativeShare().AddFile( filePath ).SetText( "Hello world!" ).SetTarget( "com.whatsapp" ).Share();
}

i have add: using System.IO; but nothing change.