yasirkula / UnitySimpleFileBrowser

A uGUI based runtime file browser for Unity 3D (draggable and resizable)
MIT License
851 stars 111 forks source link

can it be use in android game? #12

Closed stickylabdev closed 5 years ago

stickylabdev commented 5 years ago

i hope it can

yasirkula commented 5 years ago

Yes, it is supposed to work on Android.

stickylabdev commented 5 years ago

what i want is ,,iwant to change the sprite ,, imean something like changine the sprite of gameobject that contain spriterenderer ,,i want to make custom sprite where user can customize png image then applying to the game object through file manager

yasirkula commented 5 years ago

Does changing the "Filetype Icons" variable of the SimpleFileBrowserCanvas prefab not work for you?

stickylabdev commented 5 years ago

i still dont understad how to do , if there some scene example it woulbe help me alot

Pada tanggal Rab, 1 Mei 2019 pukul 14.04 Süleyman Yasir KULA < notifications@github.com> menulis:

Does changing the "Filetype Icons" variable of the SimpleFileBrowserCanvas prefab not work for you?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/yasirkula/UnitySimpleFileBrowser/issues/12#issuecomment-488223472, or mute the thread https://github.com/notifications/unsubscribe-auth/ADDY6YNIYUUMEITSBNZBNKLPTE6IVANCNFSM4HJJFE6Q .

yasirkula commented 5 years ago

png

stickylabdev commented 5 years ago

yes i know , but how to get the png image to replece some image on sprite folder of the game ?

Pada tanggal Rab, 1 Mei 2019 pukul 20.58 Süleyman Yasir KULA < notifications@github.com> menulis:

[image: png] https://user-images.githubusercontent.com/10211608/57020545-3f704e00-6c32-11e9-8c13-6f133f062e5b.png

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/yasirkula/UnitySimpleFileBrowser/issues/12#issuecomment-488289206, or mute the thread https://github.com/notifications/unsubscribe-auth/ADDY6YKYJVXPTCYDYO2EVHTPTGOXVANCNFSM4HJJFE6Q .

stickylabdev commented 5 years ago

so i have to do something here

private void OnOperationSuccessful( string path ) { Success = true; Result = path;

        //Hide();

        if( onSuccess != null )
            onSuccess( path );

        onSuccess = null;
        onCancel = null;
    }

but i dont know how to do bro

Pada tanggal Kam, 2 Mei 2019 pukul 02.51 Muafakul Khoir < alhunaidah@gmail.com> menulis:

yes i know , but how to get the png image to replece some image on sprite folder of the game ?

Pada tanggal Rab, 1 Mei 2019 pukul 20.58 Süleyman Yasir KULA < notifications@github.com> menulis:

[image: png] https://user-images.githubusercontent.com/10211608/57020545-3f704e00-6c32-11e9-8c13-6f133f062e5b.png

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/yasirkula/UnitySimpleFileBrowser/issues/12#issuecomment-488289206, or mute the thread https://github.com/notifications/unsubscribe-auth/ADDY6YKYJVXPTCYDYO2EVHTPTGOXVANCNFSM4HJJFE6Q .

stickylabdev commented 5 years ago

teach

can you make example how to change that sprite ?

yasirkula commented 5 years ago

I see. You have to use the onSuccess event of the ShowLoadDialog function:

FileBrowser.ShowLoadDialog( ( path ) =>
    {
        // Here, create a texture from the image at "path"
        // Google "unity load image runtime" to see how
    }, null );
stickylabdev commented 5 years ago

correct still failed ,,can you give me the correct example ?

stickylabdev commented 5 years ago

can can you give me spesific example ,please , i always failed , cry

stickylabdev commented 5 years ago
private void OnOperationSuccessful (string path) {
        Success = true;
        Result = path;

        //Hide();
        Debug.Log (path);
        if (onSuccess != null)
            onSuccess (path);

        onSuccess = null;
        onCancel = null;

        //LoadPNG(path);

        idontknow (path);
    }

    public void idontknow (string path) {

    //  FileBrowser.ShowLoadDialog ((path) => {
            // Here, create a texture from the image at "path"
            // Google "unity load image runtime" to see how

            Sprite tex = null;
            byte[] fileData;

            if (File.Exists (path)) {
                fileData = File.ReadAllBytes (path);
                tex = new Sprite ();
                //tex.LoadImage (fileData); //..this will auto-resize the texture dimensions.
                sr.sprite = tex;
            }
            //}

        //}, null);
    }

still failded ,can you help me please ?

yasirkula commented 5 years ago
public void idontknow( string path ) 
{
    FileBrowser.ShowLoadDialog( ( path ) => 
    {
        if( File.Exists( path ) )
        {
            byte[] fileData = File.ReadAllBytes( path );
            Texture2D tex = new Texture2D( 2, 2 );
            tex.LoadImage( fileData );

            Sprite sprite = Sprite.Create( tex, new Rect( 0f, 0f, tex.width, tex.height ), new Vector2( 0.5f, 0.5f ), 100f );
            sr.sprite = sprite;
        }
    }, null );
}
stickylabdev commented 5 years ago

cool ,,is it possible to save sprite data in the player prefs or save load playerinfo.bat

yasirkula commented 5 years ago

You can save the path of the file in PlayerPrefs. If you worry about the file getting deleted at some stage, you can copy it to Application.persistentDataPath via File.Copy and then save the path of the copied file.

stickylabdev commented 5 years ago

i will think about it ,and a lot of try and errors ,thanks

Pada tanggal Jum, 3 Mei 2019 pukul 23.31 Süleyman Yasir KULA < notifications@github.com> menulis:

You can save the path of the file in PlayerPrefs. If you worry about the file getting deleted at some stage, you can copy it to Application.persistentDataPath via File.Copy and then save the path of the copied file.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/yasirkula/UnitySimpleFileBrowser/issues/12#issuecomment-489158676, or mute the thread https://github.com/notifications/unsubscribe-auth/ADDY6YPETBMIP4CKYRBGT3DPTRSHVANCNFSM4HJJFE6Q .