mirror of
https://github.com/maxartz15/TextureCombiner.git
synced 2025-06-27 12:46:05 +02:00
Init.
P4 -> GitHub sync.
This commit is contained in:
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace SFB {
|
||||
public interface IStandaloneFileBrowser {
|
||||
string[] OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect);
|
||||
string[] OpenFolderPanel(string title, string directory, bool multiselect);
|
||||
string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions);
|
||||
|
||||
void OpenFilePanelAsync(string title, string directory, ExtensionFilter[] extensions, bool multiselect, Action<string[]> cb);
|
||||
void OpenFolderPanelAsync(string title, string directory, bool multiselect, Action<string[]> cb);
|
||||
void SaveFilePanelAsync(string title, string directory, string defaultName, ExtensionFilter[] extensions, Action<string> cb);
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7609f7b6787a54496aa41a3053fcc76a
|
||||
timeCreated: 1483902788
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/StandaloneFileBrowser/Plugins.meta
Normal file
8
Assets/Plugins/StandaloneFileBrowser/Plugins.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddc4e7b83981f244ba9a26b88c18cb67
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
10
Assets/Plugins/StandaloneFileBrowser/Plugins/Linux.meta
Normal file
10
Assets/Plugins/StandaloneFileBrowser/Plugins/Linux.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82666e520ab4d4cf08bebbb8059cd6f4
|
||||
folderAsset: yes
|
||||
timeCreated: 1538224809
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd198408642944765b9305bd99404136
|
||||
folderAsset: yes
|
||||
timeCreated: 1538230728
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -0,0 +1,126 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8c465928f1784a3fac8dc3766f7201c
|
||||
timeCreated: 1538230728
|
||||
licenseType: Free
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
- first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 0
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 0
|
||||
Exclude LinuxUniversal: 0
|
||||
Exclude OSXIntel: 1
|
||||
Exclude OSXIntel64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude SamsungTV: 1
|
||||
Exclude Tizen: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 0
|
||||
Exclude Win64: 0
|
||||
Exclude iOS: 1
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
DefaultValueInitialized: true
|
||||
OS: Linux
|
||||
- first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Samsung TV: SamsungTV
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
STV_MODEL: STANDARD_15
|
||||
- first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
- first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
- first:
|
||||
Standalone: OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Plugins/StandaloneFileBrowser/Plugins/Ookii.Dialogs.dll
Normal file
BIN
Assets/Plugins/StandaloneFileBrowser/Plugins/Ookii.Dialogs.dll
Normal file
Binary file not shown.
@ -0,0 +1,130 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e60958662eed5413d86143a0a69b731e
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 0
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXIntel: 1
|
||||
Exclude OSXIntel64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 0
|
||||
Exclude Win64: 0
|
||||
Exclude iOS: 1
|
||||
- first:
|
||||
: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,43 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 110fdfb459db4fc448a2ccd37e200fa4
|
||||
folderAsset: yes
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Standalone: OSXIntel
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Standalone: OSXIntel64
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 996ea0b0fb9804844ba9595686ee3e7a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildMachineOSBuild</key>
|
||||
<string>18A391</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>StandaloneFileBrowser</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.gkngkc.sfb</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>StandaloneFileBrowser</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0 </string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>10A255</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>GM</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>18A384</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>macosx10.14</string>
|
||||
<key>DTXcode</key>
|
||||
<string>1000</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>10A255</string>
|
||||
</dict>
|
||||
</plist>
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce685769797f44046afa3e567860c94c
|
||||
timeCreated: 1505756861
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5a66f5db020f344c9327188aec2c060
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddf122e0e89124ce78aacfeecb3ec554
|
||||
timeCreated: 1508179371
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,90 @@
|
||||
var StandaloneFileBrowserWebGLPlugin = {
|
||||
// Open file.
|
||||
// gameObjectNamePtr: Unique GameObject name. Required for calling back unity with SendMessage.
|
||||
// methodNamePtr: Callback method name on given GameObject.
|
||||
// filter: Filter files. Example filters:
|
||||
// Match all image files: "image/*"
|
||||
// Match all video files: "video/*"
|
||||
// Match all audio files: "audio/*"
|
||||
// Custom: ".plist, .xml, .yaml"
|
||||
// multiselect: Allows multiple file selection
|
||||
UploadFile: function(gameObjectNamePtr, methodNamePtr, filterPtr, multiselect) {
|
||||
gameObjectName = Pointer_stringify(gameObjectNamePtr);
|
||||
methodName = Pointer_stringify(methodNamePtr);
|
||||
filter = Pointer_stringify(filterPtr);
|
||||
|
||||
// Delete if element exist
|
||||
var fileInput = document.getElementById(gameObjectName)
|
||||
if (fileInput) {
|
||||
document.body.removeChild(fileInput);
|
||||
}
|
||||
|
||||
fileInput = document.createElement('input');
|
||||
fileInput.setAttribute('id', gameObjectName);
|
||||
fileInput.setAttribute('type', 'file');
|
||||
fileInput.setAttribute('style','display:none;');
|
||||
fileInput.setAttribute('style','visibility:hidden;');
|
||||
if (multiselect) {
|
||||
fileInput.setAttribute('multiple', '');
|
||||
}
|
||||
if (filter) {
|
||||
fileInput.setAttribute('accept', filter);
|
||||
}
|
||||
fileInput.onclick = function (event) {
|
||||
// File dialog opened
|
||||
this.value = null;
|
||||
};
|
||||
fileInput.onchange = function (event) {
|
||||
// multiselect works
|
||||
var urls = [];
|
||||
for (var i = 0; i < event.target.files.length; i++) {
|
||||
urls.push(URL.createObjectURL(event.target.files[i]));
|
||||
}
|
||||
// File selected
|
||||
SendMessage(gameObjectName, methodName, urls.join());
|
||||
|
||||
// Remove after file selected
|
||||
document.body.removeChild(fileInput);
|
||||
}
|
||||
document.body.appendChild(fileInput);
|
||||
|
||||
document.onmouseup = function() {
|
||||
fileInput.click();
|
||||
document.onmouseup = null;
|
||||
}
|
||||
},
|
||||
|
||||
// Save file
|
||||
// DownloadFile method does not open SaveFileDialog like standalone builds, its just allows user to download file
|
||||
// gameObjectNamePtr: Unique GameObject name. Required for calling back unity with SendMessage.
|
||||
// methodNamePtr: Callback method name on given GameObject.
|
||||
// filenamePtr: Filename with extension
|
||||
// byteArray: byte[]
|
||||
// byteArraySize: byte[].Length
|
||||
DownloadFile: function(gameObjectNamePtr, methodNamePtr, filenamePtr, byteArray, byteArraySize) {
|
||||
gameObjectName = Pointer_stringify(gameObjectNamePtr);
|
||||
methodName = Pointer_stringify(methodNamePtr);
|
||||
filename = Pointer_stringify(filenamePtr);
|
||||
|
||||
var bytes = new Uint8Array(byteArraySize);
|
||||
for (var i = 0; i < byteArraySize; i++) {
|
||||
bytes[i] = HEAPU8[byteArray + i];
|
||||
}
|
||||
|
||||
var downloader = window.document.createElement('a');
|
||||
downloader.setAttribute('id', gameObjectName);
|
||||
downloader.href = window.URL.createObjectURL(new Blob([bytes], { type: 'application/octet-stream' }));
|
||||
downloader.download = filename;
|
||||
document.body.appendChild(downloader);
|
||||
|
||||
document.onmouseup = function() {
|
||||
downloader.click();
|
||||
document.body.removeChild(downloader);
|
||||
document.onmouseup = null;
|
||||
|
||||
SendMessage(gameObjectName, methodName);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
mergeInto(LibraryManager.library, StandaloneFileBrowserWebGLPlugin);
|
@ -0,0 +1,99 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 265aaf20a6d564e0fb00a9c4a7a9c300
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Editor: 1
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Facebook: WebGL
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
WebGL: WebGL
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -0,0 +1,130 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d459a96865cc4aaab657012c6dc4833
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 0
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXIntel: 1
|
||||
Exclude OSXIntel64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 0
|
||||
Exclude Win64: 0
|
||||
Exclude iOS: 1
|
||||
- first:
|
||||
: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
153
Assets/Plugins/StandaloneFileBrowser/StandaloneFileBrowser.cs
Normal file
153
Assets/Plugins/StandaloneFileBrowser/StandaloneFileBrowser.cs
Normal file
@ -0,0 +1,153 @@
|
||||
using System;
|
||||
|
||||
namespace SFB {
|
||||
public struct ExtensionFilter {
|
||||
public string Name;
|
||||
public string[] Extensions;
|
||||
|
||||
public ExtensionFilter(string filterName, params string[] filterExtensions) {
|
||||
Name = filterName;
|
||||
Extensions = filterExtensions;
|
||||
}
|
||||
}
|
||||
|
||||
public class StandaloneFileBrowser {
|
||||
private static IStandaloneFileBrowser _platformWrapper = null;
|
||||
|
||||
static StandaloneFileBrowser() {
|
||||
#if UNITY_STANDALONE_OSX
|
||||
_platformWrapper = new StandaloneFileBrowserMac();
|
||||
#elif UNITY_STANDALONE_WIN
|
||||
_platformWrapper = new StandaloneFileBrowserWindows();
|
||||
#elif UNITY_STANDALONE_LINUX
|
||||
_platformWrapper = new StandaloneFileBrowserLinux();
|
||||
#elif UNITY_EDITOR
|
||||
_platformWrapper = new StandaloneFileBrowserEditor();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Native open file dialog
|
||||
/// </summary>
|
||||
/// <param name="title">Dialog title</param>
|
||||
/// <param name="directory">Root directory</param>
|
||||
/// <param name="extension">Allowed extension</param>
|
||||
/// <param name="multiselect">Allow multiple file selection</param>
|
||||
/// <returns>Returns array of chosen paths. Zero length array when cancelled</returns>
|
||||
public static string[] OpenFilePanel(string title, string directory, string extension, bool multiselect) {
|
||||
var extensions = string.IsNullOrEmpty(extension) ? null : new [] { new ExtensionFilter("", extension) };
|
||||
return OpenFilePanel(title, directory, extensions, multiselect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Native open file dialog
|
||||
/// </summary>
|
||||
/// <param name="title">Dialog title</param>
|
||||
/// <param name="directory">Root directory</param>
|
||||
/// <param name="extensions">List of extension filters. Filter Example: new ExtensionFilter("Image Files", "jpg", "png")</param>
|
||||
/// <param name="multiselect">Allow multiple file selection</param>
|
||||
/// <returns>Returns array of chosen paths. Zero length array when cancelled</returns>
|
||||
public static string[] OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect) {
|
||||
return _platformWrapper.OpenFilePanel(title, directory, extensions, multiselect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Native open file dialog async
|
||||
/// </summary>
|
||||
/// <param name="title">Dialog title</param>
|
||||
/// <param name="directory">Root directory</param>
|
||||
/// <param name="extension">Allowed extension</param>
|
||||
/// <param name="multiselect">Allow multiple file selection</param>
|
||||
/// <param name="cb">Callback")</param>
|
||||
public static void OpenFilePanelAsync(string title, string directory, string extension, bool multiselect, Action<string[]> cb) {
|
||||
var extensions = string.IsNullOrEmpty(extension) ? null : new [] { new ExtensionFilter("", extension) };
|
||||
OpenFilePanelAsync(title, directory, extensions, multiselect, cb);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Native open file dialog async
|
||||
/// </summary>
|
||||
/// <param name="title">Dialog title</param>
|
||||
/// <param name="directory">Root directory</param>
|
||||
/// <param name="extensions">List of extension filters. Filter Example: new ExtensionFilter("Image Files", "jpg", "png")</param>
|
||||
/// <param name="multiselect">Allow multiple file selection</param>
|
||||
/// <param name="cb">Callback")</param>
|
||||
public static void OpenFilePanelAsync(string title, string directory, ExtensionFilter[] extensions, bool multiselect, Action<string[]> cb) {
|
||||
_platformWrapper.OpenFilePanelAsync(title, directory, extensions, multiselect, cb);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Native open folder dialog
|
||||
/// NOTE: Multiple folder selection doesn't supported on Windows
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="directory">Root directory</param>
|
||||
/// <param name="multiselect"></param>
|
||||
/// <returns>Returns array of chosen paths. Zero length array when cancelled</returns>
|
||||
public static string[] OpenFolderPanel(string title, string directory, bool multiselect) {
|
||||
return _platformWrapper.OpenFolderPanel(title, directory, multiselect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Native open folder dialog async
|
||||
/// NOTE: Multiple folder selection doesn't supported on Windows
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="directory">Root directory</param>
|
||||
/// <param name="multiselect"></param>
|
||||
/// <param name="cb">Callback")</param>
|
||||
public static void OpenFolderPanelAsync(string title, string directory, bool multiselect, Action<string[]> cb) {
|
||||
_platformWrapper.OpenFolderPanelAsync(title, directory, multiselect, cb);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Native save file dialog
|
||||
/// </summary>
|
||||
/// <param name="title">Dialog title</param>
|
||||
/// <param name="directory">Root directory</param>
|
||||
/// <param name="defaultName">Default file name</param>
|
||||
/// <param name="extension">File extension</param>
|
||||
/// <returns>Returns chosen path. Empty string when cancelled</returns>
|
||||
public static string SaveFilePanel(string title, string directory, string defaultName , string extension) {
|
||||
var extensions = string.IsNullOrEmpty(extension) ? null : new [] { new ExtensionFilter("", extension) };
|
||||
return SaveFilePanel(title, directory, defaultName, extensions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Native save file dialog
|
||||
/// </summary>
|
||||
/// <param name="title">Dialog title</param>
|
||||
/// <param name="directory">Root directory</param>
|
||||
/// <param name="defaultName">Default file name</param>
|
||||
/// <param name="extensions">List of extension filters. Filter Example: new ExtensionFilter("Image Files", "jpg", "png")</param>
|
||||
/// <returns>Returns chosen path. Empty string when cancelled</returns>
|
||||
public static string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions) {
|
||||
return _platformWrapper.SaveFilePanel(title, directory, defaultName, extensions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Native save file dialog async
|
||||
/// </summary>
|
||||
/// <param name="title">Dialog title</param>
|
||||
/// <param name="directory">Root directory</param>
|
||||
/// <param name="defaultName">Default file name</param>
|
||||
/// <param name="extension">File extension</param>
|
||||
/// <param name="cb">Callback")</param>
|
||||
public static void SaveFilePanelAsync(string title, string directory, string defaultName , string extension, Action<string> cb) {
|
||||
var extensions = string.IsNullOrEmpty(extension) ? null : new [] { new ExtensionFilter("", extension) };
|
||||
SaveFilePanelAsync(title, directory, defaultName, extensions, cb);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Native save file dialog async
|
||||
/// </summary>
|
||||
/// <param name="title">Dialog title</param>
|
||||
/// <param name="directory">Root directory</param>
|
||||
/// <param name="defaultName">Default file name</param>
|
||||
/// <param name="extensions">List of extension filters. Filter Example: new ExtensionFilter("Image Files", "jpg", "png")</param>
|
||||
/// <param name="cb">Callback")</param>
|
||||
public static void SaveFilePanelAsync(string title, string directory, string defaultName, ExtensionFilter[] extensions, Action<string> cb) {
|
||||
_platformWrapper.SaveFilePanelAsync(title, directory, defaultName, extensions, cb);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c708be74128e4ced9b79eaaf80e8443
|
||||
timeCreated: 1483902788
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,56 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System;
|
||||
using UnityEditor;
|
||||
|
||||
namespace SFB {
|
||||
public class StandaloneFileBrowserEditor : IStandaloneFileBrowser {
|
||||
public string[] OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect) {
|
||||
string path = "";
|
||||
|
||||
if (extensions == null) {
|
||||
path = EditorUtility.OpenFilePanel(title, directory, "");
|
||||
}
|
||||
else {
|
||||
path = EditorUtility.OpenFilePanelWithFilters(title, directory, GetFilterFromFileExtensionList(extensions));
|
||||
}
|
||||
|
||||
return string.IsNullOrEmpty(path) ? new string[0] : new[] { path };
|
||||
}
|
||||
|
||||
public void OpenFilePanelAsync(string title, string directory, ExtensionFilter[] extensions, bool multiselect, Action<string[]> cb) {
|
||||
cb.Invoke(OpenFilePanel(title, directory, extensions, multiselect));
|
||||
}
|
||||
|
||||
public string[] OpenFolderPanel(string title, string directory, bool multiselect) {
|
||||
var path = EditorUtility.OpenFolderPanel(title, directory, "");
|
||||
return string.IsNullOrEmpty(path) ? new string[0] : new[] {path};
|
||||
}
|
||||
|
||||
public void OpenFolderPanelAsync(string title, string directory, bool multiselect, Action<string[]> cb) {
|
||||
cb.Invoke(OpenFolderPanel(title, directory, multiselect));
|
||||
}
|
||||
|
||||
public string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions) {
|
||||
var ext = extensions != null ? extensions[0].Extensions[0] : "";
|
||||
var name = string.IsNullOrEmpty(ext) ? defaultName : defaultName + "." + ext;
|
||||
return EditorUtility.SaveFilePanel(title, directory, name, ext);
|
||||
}
|
||||
|
||||
public void SaveFilePanelAsync(string title, string directory, string defaultName, ExtensionFilter[] extensions, Action<string> cb) {
|
||||
cb.Invoke(SaveFilePanel(title, directory, defaultName, extensions));
|
||||
}
|
||||
|
||||
// EditorUtility.OpenFilePanelWithFilters extension filter format
|
||||
private static string[] GetFilterFromFileExtensionList(ExtensionFilter[] extensions) {
|
||||
var filters = new string[extensions.Length * 2];
|
||||
for (int i = 0; i < extensions.Length; i++) {
|
||||
filters[(i * 2)] = extensions[i].Name;
|
||||
filters[(i * 2) + 1] = string.Join(",", extensions[i].Extensions);
|
||||
}
|
||||
return filters;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2650af8de2cda46b99b1bc7cf5d30ca5
|
||||
timeCreated: 1483902788
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,115 @@
|
||||
#if UNITY_STANDALONE_LINUX
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SFB {
|
||||
|
||||
public class StandaloneFileBrowserLinux : IStandaloneFileBrowser {
|
||||
|
||||
private static Action<string[]> _openFileCb;
|
||||
private static Action<string[]> _openFolderCb;
|
||||
private static Action<string> _saveFileCb;
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate void AsyncCallback(string path);
|
||||
|
||||
[DllImport("StandaloneFileBrowser")]
|
||||
private static extern void DialogInit();
|
||||
[DllImport("StandaloneFileBrowser")]
|
||||
private static extern IntPtr DialogOpenFilePanel(string title, string directory, string extension, bool multiselect);
|
||||
[DllImport("StandaloneFileBrowser")]
|
||||
private static extern void DialogOpenFilePanelAsync(string title, string directory, string extension, bool multiselect, AsyncCallback callback);
|
||||
[DllImport("StandaloneFileBrowser")]
|
||||
private static extern IntPtr DialogOpenFolderPanel(string title, string directory, bool multiselect);
|
||||
[DllImport("StandaloneFileBrowser")]
|
||||
private static extern void DialogOpenFolderPanelAsync(string title, string directory, bool multiselect, AsyncCallback callback);
|
||||
[DllImport("StandaloneFileBrowser")]
|
||||
private static extern IntPtr DialogSaveFilePanel(string title, string directory, string defaultName, string extension);
|
||||
[DllImport("StandaloneFileBrowser")]
|
||||
private static extern void DialogSaveFilePanelAsync(string title, string directory, string defaultName, string extension, AsyncCallback callback);
|
||||
|
||||
public StandaloneFileBrowserLinux()
|
||||
{
|
||||
DialogInit();
|
||||
}
|
||||
|
||||
public string[] OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect) {
|
||||
var paths = Marshal.PtrToStringAnsi(DialogOpenFilePanel(
|
||||
title,
|
||||
directory,
|
||||
GetFilterFromFileExtensionList(extensions),
|
||||
multiselect));
|
||||
return paths.Split((char)28);
|
||||
}
|
||||
|
||||
public void OpenFilePanelAsync(string title, string directory, ExtensionFilter[] extensions, bool multiselect, Action<string[]> cb) {
|
||||
_openFileCb = cb;
|
||||
DialogOpenFilePanelAsync(
|
||||
title,
|
||||
directory,
|
||||
GetFilterFromFileExtensionList(extensions),
|
||||
multiselect,
|
||||
(string result) => { _openFileCb.Invoke(result.Split((char)28)); });
|
||||
}
|
||||
|
||||
public string[] OpenFolderPanel(string title, string directory, bool multiselect) {
|
||||
var paths = Marshal.PtrToStringAnsi(DialogOpenFolderPanel(
|
||||
title,
|
||||
directory,
|
||||
multiselect));
|
||||
return paths.Split((char)28);
|
||||
}
|
||||
|
||||
public void OpenFolderPanelAsync(string title, string directory, bool multiselect, Action<string[]> cb) {
|
||||
_openFolderCb = cb;
|
||||
DialogOpenFolderPanelAsync(
|
||||
title,
|
||||
directory,
|
||||
multiselect,
|
||||
(string result) => { _openFolderCb.Invoke(result.Split((char)28)); });
|
||||
}
|
||||
|
||||
public string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions) {
|
||||
return Marshal.PtrToStringAnsi(DialogSaveFilePanel(
|
||||
title,
|
||||
directory,
|
||||
defaultName,
|
||||
GetFilterFromFileExtensionList(extensions)));
|
||||
}
|
||||
|
||||
public void SaveFilePanelAsync(string title, string directory, string defaultName, ExtensionFilter[] extensions, Action<string> cb) {
|
||||
_saveFileCb = cb;
|
||||
DialogSaveFilePanelAsync(
|
||||
title,
|
||||
directory,
|
||||
defaultName,
|
||||
GetFilterFromFileExtensionList(extensions),
|
||||
(string result) => { _saveFileCb.Invoke(result); });
|
||||
}
|
||||
|
||||
private static string GetFilterFromFileExtensionList(ExtensionFilter[] extensions) {
|
||||
if (extensions == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
var filterString = "";
|
||||
foreach (var filter in extensions) {
|
||||
filterString += filter.Name + ";";
|
||||
|
||||
foreach (var ext in filter.Extensions) {
|
||||
filterString += ext + ",";
|
||||
}
|
||||
|
||||
filterString = filterString.Remove(filterString.Length - 1);
|
||||
filterString += "|";
|
||||
}
|
||||
filterString = filterString.Remove(filterString.Length - 1);
|
||||
return filterString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d3a668018554b8a89c3fe12de72b60c
|
||||
timeCreated: 1538067919
|
119
Assets/Plugins/StandaloneFileBrowser/StandaloneFileBrowserMac.cs
Normal file
119
Assets/Plugins/StandaloneFileBrowser/StandaloneFileBrowserMac.cs
Normal file
@ -0,0 +1,119 @@
|
||||
#if UNITY_STANDALONE_OSX
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SFB {
|
||||
public class StandaloneFileBrowserMac : IStandaloneFileBrowser {
|
||||
private static Action<string[]> _openFileCb;
|
||||
private static Action<string[]> _openFolderCb;
|
||||
private static Action<string> _saveFileCb;
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate void AsyncCallback(string path);
|
||||
|
||||
[AOT.MonoPInvokeCallback(typeof(AsyncCallback))]
|
||||
private static void openFileCb(string result) {
|
||||
_openFileCb.Invoke(result.Split((char)28));
|
||||
}
|
||||
|
||||
[AOT.MonoPInvokeCallback(typeof(AsyncCallback))]
|
||||
private static void openFolderCb(string result) {
|
||||
_openFolderCb.Invoke(result.Split((char)28));
|
||||
}
|
||||
|
||||
[AOT.MonoPInvokeCallback(typeof(AsyncCallback))]
|
||||
private static void saveFileCb(string result) {
|
||||
_saveFileCb.Invoke(result);
|
||||
}
|
||||
|
||||
[DllImport("StandaloneFileBrowser")]
|
||||
private static extern IntPtr DialogOpenFilePanel(string title, string directory, string extension, bool multiselect);
|
||||
[DllImport("StandaloneFileBrowser")]
|
||||
private static extern void DialogOpenFilePanelAsync(string title, string directory, string extension, bool multiselect, AsyncCallback callback);
|
||||
[DllImport("StandaloneFileBrowser")]
|
||||
private static extern IntPtr DialogOpenFolderPanel(string title, string directory, bool multiselect);
|
||||
[DllImport("StandaloneFileBrowser")]
|
||||
private static extern void DialogOpenFolderPanelAsync(string title, string directory, bool multiselect, AsyncCallback callback);
|
||||
[DllImport("StandaloneFileBrowser")]
|
||||
private static extern IntPtr DialogSaveFilePanel(string title, string directory, string defaultName, string extension);
|
||||
[DllImport("StandaloneFileBrowser")]
|
||||
private static extern void DialogSaveFilePanelAsync(string title, string directory, string defaultName, string extension, AsyncCallback callback);
|
||||
|
||||
public string[] OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect) {
|
||||
var paths = Marshal.PtrToStringAnsi(DialogOpenFilePanel(
|
||||
title,
|
||||
directory,
|
||||
GetFilterFromFileExtensionList(extensions),
|
||||
multiselect));
|
||||
return paths.Split((char)28);
|
||||
}
|
||||
|
||||
public void OpenFilePanelAsync(string title, string directory, ExtensionFilter[] extensions, bool multiselect, Action<string[]> cb) {
|
||||
_openFileCb = cb;
|
||||
DialogOpenFilePanelAsync(
|
||||
title,
|
||||
directory,
|
||||
GetFilterFromFileExtensionList(extensions),
|
||||
multiselect,
|
||||
openFileCb);
|
||||
}
|
||||
|
||||
public string[] OpenFolderPanel(string title, string directory, bool multiselect) {
|
||||
var paths = Marshal.PtrToStringAnsi(DialogOpenFolderPanel(
|
||||
title,
|
||||
directory,
|
||||
multiselect));
|
||||
return paths.Split((char)28);
|
||||
}
|
||||
|
||||
public void OpenFolderPanelAsync(string title, string directory, bool multiselect, Action<string[]> cb) {
|
||||
_openFolderCb = cb;
|
||||
DialogOpenFolderPanelAsync(
|
||||
title,
|
||||
directory,
|
||||
multiselect,
|
||||
openFolderCb);
|
||||
}
|
||||
|
||||
public string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions) {
|
||||
return Marshal.PtrToStringAnsi(DialogSaveFilePanel(
|
||||
title,
|
||||
directory,
|
||||
defaultName,
|
||||
GetFilterFromFileExtensionList(extensions)));
|
||||
}
|
||||
|
||||
public void SaveFilePanelAsync(string title, string directory, string defaultName, ExtensionFilter[] extensions, Action<string> cb) {
|
||||
_saveFileCb = cb;
|
||||
DialogSaveFilePanelAsync(
|
||||
title,
|
||||
directory,
|
||||
defaultName,
|
||||
GetFilterFromFileExtensionList(extensions),
|
||||
saveFileCb);
|
||||
}
|
||||
|
||||
private static string GetFilterFromFileExtensionList(ExtensionFilter[] extensions) {
|
||||
if (extensions == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
var filterString = "";
|
||||
foreach (var filter in extensions) {
|
||||
filterString += filter.Name + ";";
|
||||
|
||||
foreach (var ext in filter.Extensions) {
|
||||
filterString += ext + ",";
|
||||
}
|
||||
|
||||
filterString = filterString.Remove(filterString.Length - 1);
|
||||
filterString += "|";
|
||||
}
|
||||
filterString = filterString.Remove(filterString.Length - 1);
|
||||
return filterString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcb49ddb0ed5644fda9c3b055cafa27a
|
||||
timeCreated: 1483902788
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,137 @@
|
||||
#if UNITY_STANDALONE_WIN
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
using Ookii.Dialogs;
|
||||
|
||||
namespace SFB {
|
||||
// For fullscreen support
|
||||
// - WindowWrapper class and GetActiveWindow() are required for modal file dialog.
|
||||
// - "PlayerSettings/Visible In Background" should be enabled, otherwise when file dialog opened app window minimizes automatically.
|
||||
|
||||
public class WindowWrapper : IWin32Window {
|
||||
private IntPtr _hwnd;
|
||||
public WindowWrapper(IntPtr handle) { _hwnd = handle; }
|
||||
public IntPtr Handle { get { return _hwnd; } }
|
||||
}
|
||||
|
||||
public class StandaloneFileBrowserWindows : IStandaloneFileBrowser {
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetActiveWindow();
|
||||
|
||||
public string[] OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect) {
|
||||
var fd = new VistaOpenFileDialog();
|
||||
fd.Title = title;
|
||||
if (extensions != null) {
|
||||
fd.Filter = GetFilterFromFileExtensionList(extensions);
|
||||
fd.FilterIndex = 1;
|
||||
}
|
||||
else {
|
||||
fd.Filter = string.Empty;
|
||||
}
|
||||
fd.Multiselect = multiselect;
|
||||
if (!string.IsNullOrEmpty(directory)) {
|
||||
fd.FileName = GetDirectoryPath(directory);
|
||||
}
|
||||
var res = fd.ShowDialog(new WindowWrapper(GetActiveWindow()));
|
||||
var filenames = res == DialogResult.OK ? fd.FileNames : new string[0];
|
||||
fd.Dispose();
|
||||
return filenames;
|
||||
}
|
||||
|
||||
public void OpenFilePanelAsync(string title, string directory, ExtensionFilter[] extensions, bool multiselect, Action<string[]> cb) {
|
||||
cb.Invoke(OpenFilePanel(title, directory, extensions, multiselect));
|
||||
}
|
||||
|
||||
public string[] OpenFolderPanel(string title, string directory, bool multiselect) {
|
||||
var fd = new VistaFolderBrowserDialog();
|
||||
fd.Description = title;
|
||||
if (!string.IsNullOrEmpty(directory)) {
|
||||
fd.SelectedPath = GetDirectoryPath(directory);
|
||||
}
|
||||
var res = fd.ShowDialog(new WindowWrapper(GetActiveWindow()));
|
||||
var filenames = res == DialogResult.OK ? new []{ fd.SelectedPath } : new string[0];
|
||||
fd.Dispose();
|
||||
return filenames;
|
||||
}
|
||||
|
||||
public void OpenFolderPanelAsync(string title, string directory, bool multiselect, Action<string[]> cb) {
|
||||
cb.Invoke(OpenFolderPanel(title, directory, multiselect));
|
||||
}
|
||||
|
||||
public string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions) {
|
||||
var fd = new VistaSaveFileDialog();
|
||||
fd.Title = title;
|
||||
|
||||
var finalFilename = "";
|
||||
|
||||
if (!string.IsNullOrEmpty(directory)) {
|
||||
finalFilename = GetDirectoryPath(directory);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(defaultName)) {
|
||||
finalFilename += defaultName;
|
||||
}
|
||||
|
||||
fd.FileName = finalFilename;
|
||||
if (extensions != null) {
|
||||
fd.Filter = GetFilterFromFileExtensionList(extensions);
|
||||
fd.FilterIndex = 1;
|
||||
fd.DefaultExt = extensions[0].Extensions[0];
|
||||
fd.AddExtension = true;
|
||||
}
|
||||
else {
|
||||
fd.DefaultExt = string.Empty;
|
||||
fd.Filter = string.Empty;
|
||||
fd.AddExtension = false;
|
||||
}
|
||||
var res = fd.ShowDialog(new WindowWrapper(GetActiveWindow()));
|
||||
var filename = res == DialogResult.OK ? fd.FileName : "";
|
||||
fd.Dispose();
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void SaveFilePanelAsync(string title, string directory, string defaultName, ExtensionFilter[] extensions, Action<string> cb) {
|
||||
cb.Invoke(SaveFilePanel(title, directory, defaultName, extensions));
|
||||
}
|
||||
|
||||
// .NET Framework FileDialog Filter format
|
||||
// https://msdn.microsoft.com/en-us/library/microsoft.win32.filedialog.filter
|
||||
private static string GetFilterFromFileExtensionList(ExtensionFilter[] extensions) {
|
||||
var filterString = "";
|
||||
foreach (var filter in extensions) {
|
||||
filterString += filter.Name + "(";
|
||||
|
||||
foreach (var ext in filter.Extensions) {
|
||||
filterString += "*." + ext + ",";
|
||||
}
|
||||
|
||||
filterString = filterString.Remove(filterString.Length - 1);
|
||||
filterString += ") |";
|
||||
|
||||
foreach (var ext in filter.Extensions) {
|
||||
filterString += "*." + ext + "; ";
|
||||
}
|
||||
|
||||
filterString += "|";
|
||||
}
|
||||
filterString = filterString.Remove(filterString.Length - 1);
|
||||
return filterString;
|
||||
}
|
||||
|
||||
private static string GetDirectoryPath(string directory) {
|
||||
var directoryPath = Path.GetFullPath(directory);
|
||||
if (!directoryPath.EndsWith("\\")) {
|
||||
directoryPath += "\\";
|
||||
}
|
||||
if (Path.GetPathRoot(directoryPath) == directoryPath) {
|
||||
return directory;
|
||||
}
|
||||
return Path.GetDirectoryName(directoryPath) + Path.DirectorySeparatorChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 194e247414a78461d83ae606c1b96917
|
||||
timeCreated: 1483902788
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user