I am trying to develop a simple 2D App/Game whereby once the project is built in an EXE…
There will be a button to press which will open up a Local file Browser / Directory whereby the user can navigate to say , ’ the desktop’ and select a Jped or PNG Image.
Once they have selected the image, it will upload into the canvas in game where they can then draw ( ui touch input ) on the canvas and then save what they see as a screenshot ( to a folder on their PC ) Which they can Then Email onward to another person.
I am just trying to find out if this is possible and how it would be done.
All I am worried about at this moment is the simple navigating to a specific directory and uploading an image such as a JPEG in game.
@wolfman
1)Make a raw Image
2) Add Button to canvas
3) Add script below to canvas
4)on button click, add canvas>Explorer script> Open Explorer
5) Add Raw Image to Explorer Script in Canvas
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
UnityEngine.UI;
using UnityEditor;
public class Explorer : MonoBehaviour
{
string path;
public RawImage image;
public void OpenExplorer()
{
path = EditorUtility.OpenFilePanel("Overwrite with png", "", "png");
GetImage();
}
void GetImage()
{
if (path != null)
{
UpdateImage();
}
}
void UpdateImage()
{
WWW www = new WWW("file:///" + path);
image.texture = www.texture;
}
void Display(GameObject plane, byte[] data){
var texture = new Texture2D(Screen.width, Screen.height);
texture.LoadRawTextureData(data);
texture.Apply();
var the_renderer = plane.GetComponent<Renderer>();
the_renderer.material.mainTexture = texture;
}
}