Esempio n. 1
0
    // For Load
    void OnFinishedImagePicker(string message)
    {
        lastMessage = message;
        if (targetMaterial && LoadTextureFromImagePicker.IsLoaded())
        {
            int width, height;
            if (bUseOriginalImageSize)
            {
                width  = LoadTextureFromImagePicker.GetLoadedTextureWidth();
                height = LoadTextureFromImagePicker.GetLoadedTextureHeight();
            }
            else
            {
                width  = textureWidth;
                height = textureHeight;
            }
            bool      mipmap  = true;
            Texture2D texture = LoadTextureFromImagePicker.GetLoadedTexture(message, width, height, mipmap);
            if (texture)
            {
                // Load Texture
                Texture lastTexture = targetMaterial.mainTexture;
                targetMaterial.mainTexture = texture;
                Destroy(lastTexture);

                if (isSaveToLocalFile)
                {
                    // Save to local file
                    LoadTextureFromImagePicker.SaveToLocalFile(saveTexFileName, texture);
                }
            }
            LoadTextureFromImagePicker.ReleaseLoadedImage();
        }
        else
        {
            // Closed
            LoadTextureFromImagePicker.Release();
        }
    }