Compare commits

...

2 Commits

Author SHA1 Message Date
Mingu Kim
c7d637383f 경로 선택 탐색기 팝업 기능 구현
- StandaloneFileBrowser 에셋을 활용한 방법
- dll을 활용한 방법
- 유니티 에디터 자체 기능을 활용한 방
2025-12-10 23:28:31 +09:00
Mingu Kim
f0acbe21ad 프레임 수치 조절 스크립트 추가 및 디렉토리 경로 설정을 위한 스크립트 추가
- 윈도우에서 경로 설정 노출 팝업창 기능을 사용하기 위해 Project Settings > Other Settings > Configuration > Api Compatibility Level = .Net Framework로 변
2025-12-10 17:48:43 +09:00
62 changed files with 4266 additions and 11 deletions

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AgentMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AskMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Ask2AgentMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EditMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

View File

@@ -1,12 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="ad175fbc-954b-46da-8e6a-90e2f18e40ec" name="변경" comment="" />
<list default="true" id="ad175fbc-954b-46da-8e6a-90e2f18e40ec" name="변경" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.ScreenCapture/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.ScreenCapture/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Main.unity" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Main.unity" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/DirectorySelect.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/DirectorySelect.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Packages/manifest.json" beforeDir="false" afterPath="$PROJECT_DIR$/Packages/manifest.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Packages/packages-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/Packages/packages-lock.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ProjectSettings/ProjectSettings.asset" beforeDir="false" afterPath="$PROJECT_DIR$/ProjectSettings/ProjectSettings.asset" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$PROJECT_DIR$/Assets/Scripts/FrameCounter.cs" root0="FORCE_HIGHLIGHTING" />
</component>
<component name="KubernetesApiPersistence">{}</component>
<component name="KubernetesApiProvider">{
&quot;isMigrated&quot;: true
}</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 5
}</component>
<component name="ProjectId" id="36Yt39bO2gjPjKyNGF3YLvNZJqD" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
@@ -14,23 +34,122 @@
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.language.and.region&quot;
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;RunOnceActivity.typescript.service.memoryLimit.init&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.pluginManager&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}</component>
<component name="RunManager" selected="Unity 에디터에 연결.Attach to Unity Editor">
<configuration name="유닛 테스트(배치 모드)" type="RunUnityExe" factoryName="Unity Executable">
<option name="EXE_PATH" value="/Applications/Unity/Hub/Editor/6000.2.15f1/Unity.app/Contents/MacOS/Unity" />
<option name="PROGRAM_PARAMETERS" value="-runTests -batchmode -projectPath $PROJECT_DIR$ -testResults Logs/results.xml -logFile Logs/Editor.log -testPlatform EditMode -debugCodeOptimization" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="ENV_FILE_PATHS" value="" />
<option name="REDIRECT_INPUT_PATH" value="" />
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2" />
</configuration>
<configuration name="Start Unity" type="RunUnityExe" factoryName="Unity Executable">
<option name="EXE_PATH" value="/Applications/Unity/Hub/Editor/6000.2.15f1/Unity.app/Contents/MacOS/Unity" />
<option name="PROGRAM_PARAMETERS" value="-projectPath $PROJECT_DIR$ -debugCodeOptimization" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="ENV_FILE_PATHS" value="" />
<option name="REDIRECT_INPUT_PATH" value="" />
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2" />
</configuration>
<configuration name="Unit Tests (batch mode)" type="RunUnityExe" factoryName="Unity Executable">
<option name="EXE_PATH" value="/Applications/Unity/Hub/Editor/6000.2.15f1/Unity.app/Contents/MacOS/Unity" />
<option name="PROGRAM_PARAMETERS" value="-runTests -batchmode -projectPath $PROJECT_DIR$ -testResults Logs/results.xml -logFile Logs/Editor.log -testPlatform EditMode -debugCodeOptimization" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="ENV_FILE_PATHS" value="" />
<option name="REDIRECT_INPUT_PATH" value="" />
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2" />
</configuration>
<configuration name="Unity 시작" type="RunUnityExe" factoryName="Unity Executable">
<option name="EXE_PATH" value="/Applications/Unity/Hub/Editor/6000.2.15f1/Unity.app/Contents/MacOS/Unity" />
<option name="PROGRAM_PARAMETERS" value="-projectPath $PROJECT_DIR$ -debugCodeOptimization" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="ENV_FILE_PATHS" value="" />
<option name="REDIRECT_INPUT_PATH" value="" />
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2" />
</configuration>
<configuration name="Attach to Unity Editor" type="UNITY_DEBUG_RUN_CONFIGURATION" factoryName="Unity Debug" show_console_on_std_err="false" show_console_on_std_out="false" port="50000" address="localhost">
<option name="allowRunningInParallel" value="false" />
<option name="listenPortForConnections" value="false" />
<option name="pid" />
<option name="projectPathOnTarget" />
<option name="runtimes">
<list />
</option>
<option name="selectedOptions">
<list />
</option>
<option name="useMixedMode" value="false" />
<method v="2" />
</configuration>
<configuration name="Unity 에디터에 연결" type="UNITY_DEBUG_RUN_CONFIGURATION" factoryName="Unity Debug" show_console_on_std_err="false" show_console_on_std_out="false" port="50000" address="localhost">
<option name="allowRunningInParallel" value="false" />
<option name="listenPortForConnections" value="false" />
<option name="pid" />
<option name="projectPathOnTarget" />
<option name="runtimes">
<list />
</option>
<option name="selectedOptions">
<list />
</option>
<option name="useMixedMode" value="false" />
<method v="2" />
</configuration>
<configuration name="연결 대상" type="UnityDevicePlayer" factoryName="UnityAttachToDevicePlayer">
<method v="2" />
</configuration>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="ad175fbc-954b-46da-8e6a-90e2f18e40ec" name="변경" comment="" />
<created>1743409431936</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1743409431936</updated>
<workItem from="1743409434026" duration="59000" />
<workItem from="1765197399514" duration="121000" />
<workItem from="1765198531543" duration="267000" />
<workItem from="1765199915866" duration="17000" />
<workItem from="1765335839421" duration="1382000" />
<workItem from="1765337350429" duration="1028000" />
<workItem from="1765338425434" duration="478000" />
<workItem from="1765338925722" duration="1639000" />
<workItem from="1765341739936" duration="7000" />
<workItem from="1765341824210" duration="5450000" />
<workItem from="1765360810958" duration="1512000" />
<workItem from="1765368720710" duration="1781000" />
<workItem from="1765370863078" duration="2786000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="UnityProjectConfiguration" hasMinimizedUI="true" />
<component name="UnityProjectDiscoverer">
<option name="hasUnityReference" value="true" />
<option name="unityProject" value="true" />
<option name="unityProjectFolder" value="true" />
</component>
<component name="UnityUnitTestConfiguration" currentTestLauncher="Both" />
<component name="VcsManagerConfiguration">
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
</component>
@@ -52,4 +171,16 @@
</breakpoints>
</breakpoint-manager>
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />
<select />
</component>
<component name="github-copilot-workspace">
<instructionFileLocations>
<option value=".github/instructions" />
</instructionFileLocations>
<promptFileLocations>
<option value=".github/prompts" />
</promptFileLocations>
</component>
</project>

View File

@@ -793,7 +793,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_SizeDelta: {x: -20, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &598475234
MonoBehaviour:
@@ -1014,7 +1014,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_SizeDelta: {x: -20, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &694708555
MonoBehaviour:
@@ -1799,6 +1799,7 @@ GameObject:
- component: {fileID: 1251167096}
- component: {fileID: 1251167098}
- component: {fileID: 1251167097}
- component: {fileID: 1251167099}
m_Layer: 5
m_Name: Panel
m_TagString: Untagged
@@ -1867,6 +1868,19 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1251167095}
m_CullTransparentMesh: 1
--- !u!114 &1251167099
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1251167095}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 60ebf93c4e7b5469f80592685f22f30b, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::DirectorySelect
selectedFolderPath:
--- !u!1 &1259274612
GameObject:
m_ObjectHideFlags: 0
@@ -2162,6 +2176,7 @@ GameObject:
m_Component:
- component: {fileID: 1438379832}
- component: {fileID: 1438379833}
- component: {fileID: 1438379834}
m_Layer: 5
m_Name: 'Directory '
m_TagString: Untagged
@@ -2216,6 +2231,19 @@ MonoBehaviour:
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
--- !u!114 &1438379834
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1438379831}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 60ebf93c4e7b5469f80592685f22f30b, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::DirectorySelect
selectedFolderPath:
--- !u!1 &1507575551
GameObject:
m_ObjectHideFlags: 0
@@ -2355,6 +2383,51 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1606638825}
m_CullTransparentMesh: 1
--- !u!1 &1617455199
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1617455200}
- component: {fileID: 1617455201}
m_Layer: 0
m_Name: Manager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1617455200
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1617455199}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 252.14377, y: 106.56857, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1617455201
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1617455199}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 42951d307a33b48fa96e3f52010a70e3, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::FrameCounter
frame: 60
--- !u!1 &1620218703
GameObject:
m_ObjectHideFlags: 0
@@ -2368,7 +2441,7 @@ GameObject:
- component: {fileID: 1620218706}
- component: {fileID: 1620218705}
m_Layer: 5
m_Name: Btn Directory
m_Name: Btn Search
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -2438,7 +2511,19 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1620218706}
m_OnClick:
m_PersistentCalls:
m_Calls: []
m_Calls:
- m_Target: {fileID: 1438379834}
m_TargetAssemblyTypeName: DirectorySelect, Assembly-CSharp
m_MethodName: Search
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &1620218706
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -2944,7 +3029,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_SizeDelta: {x: -20, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2042913672
MonoBehaviour:
@@ -3318,3 +3403,4 @@ SceneRoots:
- {fileID: 619394802}
- {fileID: 1840589191}
- {fileID: 1771175907}
- {fileID: 1617455200}

8
Assets/Scripts.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 35a9e9b414fc94c19adeb3c6ed001fc2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,142 @@
using System;
using TMPro;
using UnityEngine;
using System.Drawing;
using System.Windows.Forms;
using SFB;
using Unity.VisualScripting;
using UnityEditor;
public class DirectorySelect : MonoBehaviour
{
const string BASIC_DIRECTORY = "C://";
public string selectedFolderPath;
// OS별 기본 경로를 const 대신 static readonly 또는 private 필드로 정의
private static readonly string WINDOWS_DIRECTORY = "C:\\"; // Windows 경로는 이중 백슬래시를 사용하거나 @"C:\" 형태로 사용하는 것이 일반적입니다.
private static readonly string MAC_LINUX_DIRECTORY = "/Users/"; // macOS/Linux의 일반적인 사용자 홈 디렉토리 시작점
TMP_InputField inputDirectory;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
inputDirectory = GetComponentInChildren<TMP_InputField>();
// OS에 맞는 기본 경로 설정
string basicDirectory = GetBasicDirectory();
inputDirectory.text = basicDirectory;
}
private void OnSelect(string[] path)
{
Debug.Log(path.ToString());
if (path.Length > 0)
{
selectedFolderPath = path[0];
}
}
public void Search()
{
// 유니티 에디터 자체 기능 사용 작동함...ㅠ
EditorUtility.OpenFolderPanel("디렉토리 선택", inputDirectory.text, "");
// StandaloneFileBrowser.OpenFolderPanelAsync("", "", false, OnSelect);
// // Windows
// if (UnityEngine.Application.platform == RuntimePlatform.WindowsPlayer ||
// UnityEngine.Application.platform == RuntimePlatform.WindowsEditor)
// {
// FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
// folderBrowserDialog.Description = "디렉토리 선택";
//
// if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
// {
// selectedFolderPath = folderBrowserDialog.SelectedPath;
// }
// }
// // macOS (OSX) 및 Linux
// else if (UnityEngine.Application.platform == RuntimePlatform.OSXPlayer ||
// UnityEngine.Application.platform == RuntimePlatform.OSXEditor ||
// UnityEngine.Application.platform == RuntimePlatform.LinuxPlayer ||
// UnityEngine.Application.platform == RuntimePlatform.LinuxEditor)
// {
// // 1. OpenFolderPanelAsync를 사용하여 폴더 선택 팝업을 띄웁니다.
// // 비동기 방식이므로, 팝업이 닫힐 때 실행될 콜백 함수를 인자로 넘깁니다.
// StandaloneFileBrowser.OpenFolderPanelAsync(
// "경로를 선택하세요", // 팝업 창 제목
// inputDirectory.text, // 시작 경로: 현재 inputField의 경로를 기본값으로 사용
// false, // 다중 선택 허용 여부 (false: 폴더 1개만 선택)
// (string[] paths) => {
// // 2. 팝업이 닫힌 후 실행되는 콜백 함수 (람다 표현식)
// if (paths.Length > 0 && !string.IsNullOrEmpty(paths[0]))
// {
// // 선택된 경로가 있다면
// selectedFolderPath = paths[0];
//
// // InputField에 선택된 경로를 업데이트합니다.
// if (inputDirectory != null)
// {
// inputDirectory.text = selectedFolderPath;
// }
//
// Debug.Log("선택된 폴더 경로: " + selectedFolderPath);
// }
// else
// {
// // 선택 취소됨
// Debug.Log("폴더 선택이 취소되었습니다.");
// }
// }
// );
// }
// else
// {
// // 기타 플랫폼 (예: WebGL, Android, iOS)
// // macOS/Linux와 동일한 경로를 기본값으로 사용하거나,
// // 해당 플랫폼에 맞는 다른 경로를 반환할 수 있습니다.
// // return MAC_LINUX_DIRECTORY;
// }
}
// Update is called once per frame
void Update()
{
}
/// <summary>
/// 현재 실행 환경의 OS에 맞는 기본 경로를 반환합니다.
/// </summary>
string GetBasicDirectory()
{
// Application.platform을 사용하여 현재 OS를 확인합니다.
// RuntimePlatform.OSXEditor, RuntimePlatform.OSXPlayer,
// RuntimePlatform.LinuxEditor, RuntimePlatform.LinuxPlayer 등 여러 플랫폼이 있습니다.
// macOS와 Linux는 파일 시스템 구조가 유사합니다 (슬래시 / 사용).
// 유니티 편집기(Editor)나 빌드된 플레이어(Player) 모두에서 확인 가능합니다.
if (UnityEngine.Application.platform == RuntimePlatform.WindowsPlayer ||
UnityEngine.Application.platform == RuntimePlatform.WindowsEditor)
{
// Windows
return WINDOWS_DIRECTORY;
}
else if (UnityEngine.Application.platform == RuntimePlatform.OSXPlayer ||
UnityEngine.Application.platform == RuntimePlatform.OSXEditor ||
UnityEngine.Application.platform == RuntimePlatform.LinuxPlayer ||
UnityEngine.Application.platform == RuntimePlatform.LinuxEditor)
{
// macOS (OSX) 및 Linux
return MAC_LINUX_DIRECTORY;
}
else
{
// 기타 플랫폼 (예: WebGL, Android, iOS)
// macOS/Linux와 동일한 경로를 기본값으로 사용하거나,
// 해당 플랫폼에 맞는 다른 경로를 반환할 수 있습니다.
return MAC_LINUX_DIRECTORY;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 60ebf93c4e7b5469f80592685f22f30b

View File

@@ -0,0 +1,13 @@
using UnityEngine;
public class FrameCounter : MonoBehaviour
{
[SerializeField]
[Range(0, 120)]
int frame = 60;
void Start()
{
Application.targetFrameRate = frame;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 42951d307a33b48fa96e3f52010a70e3

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 57e25b4a578dba94c9353f4633b20549
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7609f7b6787a54496aa41a3053fcc76a
timeCreated: 1483902788
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ddc4e7b83981f244ba9a26b88c18cb67
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 82666e520ab4d4cf08bebbb8059cd6f4
folderAsset: yes
timeCreated: 1538224809
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: bd198408642944765b9305bd99404136
folderAsset: yes
timeCreated: 1538230728
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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:

Binary file not shown.

View File

@@ -0,0 +1,145 @@
fileFormatVersion: 2
guid: e60958662eed5413d86143a0a69b731e
timeCreated: 1491979494
licenseType: Pro
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
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
data:
first:
'': Editor
second:
enabled: 0
settings:
CPU: AnyCPU
OS: AnyOS
data:
first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
data:
first:
Any:
second:
enabled: 0
settings: {}
data:
first:
Editor: Editor
second:
enabled: 1
settings:
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: LinuxUniversal
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
iPhone: iOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,91 @@
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:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 0
Exclude Win: 1
Exclude Win64: 1
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: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXIntel
second:
enabled: 1
settings: {}
- first:
Standalone: OSXIntel64
second:
enabled: 1
settings: {}
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: x86_64
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CPU: AnyCPU
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 996ea0b0fb9804844ba9595686ee3e7a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
<?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>21A559</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>13A1030d</string>
<key>DTPlatformName</key>
<string>macosx</string>
<key>DTPlatformVersion</key>
<string>12.0</string>
<key>DTSDKBuild</key>
<string>21A344</string>
<key>DTSDKName</key>
<string>macosx12.0</string>
<key>DTXcode</key>
<string>1310</string>
<key>DTXcodeBuild</key>
<string>13A1030d</string>
<key>LSMinimumSystemVersion</key>
<string>12.0</string>
</dict>
</plist>

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a5a66f5db020f344c9327188aec2c060
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e6cebbdcd59894d7a8bdee7372ecad5d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,115 @@
<?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>files</key>
<dict/>
<key>files2</key>
<dict/>
<key>rules</key>
<dict>
<key>^Resources/</key>
<true/>
<key>^Resources/.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^Resources/.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Resources/Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^version.plist$</key>
<true/>
</dict>
<key>rules2</key>
<dict>
<key>.*\.dSYM($|/)</key>
<dict>
<key>weight</key>
<real>11</real>
</dict>
<key>^(.*/)?\.DS_Store$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>2000</real>
</dict>
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^.*</key>
<true/>
<key>^Info\.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^PkgInfo$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^Resources/</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^Resources/.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^Resources/.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Resources/Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^[^/]+$</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^embedded\.provisionprofile$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^version\.plist$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
</dict>
</dict>
</plist>

View File

@@ -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);

View File

@@ -0,0 +1,96 @@
fileFormatVersion: 2
guid: 265aaf20a6d564e0fb00a9c4a7a9c300
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
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: x86_64
- 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:

View File

@@ -0,0 +1,145 @@
fileFormatVersion: 2
guid: 7d459a96865cc4aaab657012c6dc4833
timeCreated: 1491979494
licenseType: Pro
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
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
data:
first:
'': Editor
second:
enabled: 0
settings:
CPU: AnyCPU
OS: AnyOS
data:
first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
data:
first:
Any:
second:
enabled: 0
settings: {}
data:
first:
Editor: Editor
second:
enabled: 1
settings:
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: LinuxUniversal
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
iPhone: iOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 435c74f62ab57b448adeeb37cbc0f96b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,119 @@
using System.Collections;
using UnityEngine;
using SFB;
public class BasicSample : MonoBehaviour {
private string _path;
void OnGUI() {
var guiScale = new Vector3(Screen.width / 800.0f, Screen.height / 600.0f, 1.0f);
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, guiScale);
GUILayout.Space(20);
GUILayout.BeginHorizontal();
GUILayout.Space(20);
GUILayout.BeginVertical();
// Open File Samples
if (GUILayout.Button("Open File")) {
WriteResult(StandaloneFileBrowser.OpenFilePanel("Open File", "", "", false));
}
GUILayout.Space(5);
if (GUILayout.Button("Open File Async")) {
StandaloneFileBrowser.OpenFilePanelAsync("Open File", "", "", false, (string[] paths) => { WriteResult(paths); });
}
GUILayout.Space(5);
if (GUILayout.Button("Open File Multiple")) {
WriteResult(StandaloneFileBrowser.OpenFilePanel("Open File", "", "", true));
}
GUILayout.Space(5);
if (GUILayout.Button("Open File Extension")) {
WriteResult(StandaloneFileBrowser.OpenFilePanel("Open File", "", "txt", true));
}
GUILayout.Space(5);
if (GUILayout.Button("Open File Directory")) {
WriteResult(StandaloneFileBrowser.OpenFilePanel("Open File", Application.dataPath, "", true));
}
GUILayout.Space(5);
if (GUILayout.Button("Open File Filter")) {
var extensions = new [] {
new ExtensionFilter("Image Files", "png", "jpg", "jpeg" ),
new ExtensionFilter("Sound Files", "mp3", "wav" ),
new ExtensionFilter("All Files", "*" ),
};
WriteResult(StandaloneFileBrowser.OpenFilePanel("Open File", "", extensions, true));
}
GUILayout.Space(15);
// Open Folder Samples
if (GUILayout.Button("Open Folder")) {
var paths = StandaloneFileBrowser.OpenFolderPanel("Select Folder", "", true);
WriteResult(paths);
}
GUILayout.Space(5);
if (GUILayout.Button("Open Folder Async")) {
StandaloneFileBrowser.OpenFolderPanelAsync("Select Folder", "", true, (string[] paths) => { WriteResult(paths); });
}
GUILayout.Space(5);
if (GUILayout.Button("Open Folder Directory")) {
var paths = StandaloneFileBrowser.OpenFolderPanel("Select Folder", Application.dataPath, true);
WriteResult(paths);
}
GUILayout.Space(15);
// Save File Samples
if (GUILayout.Button("Save File")) {
_path = StandaloneFileBrowser.SaveFilePanel("Save File", "", "", "");
}
GUILayout.Space(5);
if (GUILayout.Button("Save File Async")) {
StandaloneFileBrowser.SaveFilePanelAsync("Save File", "", "", "", (string path) => { WriteResult(path); });
}
GUILayout.Space(5);
if (GUILayout.Button("Save File Default Name")) {
_path = StandaloneFileBrowser.SaveFilePanel("Save File", "", "MySaveFile", "");
}
GUILayout.Space(5);
if (GUILayout.Button("Save File Default Name Ext")) {
_path = StandaloneFileBrowser.SaveFilePanel("Save File", "", "MySaveFile", "dat");
}
GUILayout.Space(5);
if (GUILayout.Button("Save File Directory")) {
_path = StandaloneFileBrowser.SaveFilePanel("Save File", Application.dataPath, "", "");
}
GUILayout.Space(5);
if (GUILayout.Button("Save File Filter")) {
// Multiple save extension filters with more than one extension support.
var extensionList = new [] {
new ExtensionFilter("Binary", "bin"),
new ExtensionFilter("Text", "txt"),
};
_path = StandaloneFileBrowser.SaveFilePanel("Save File", "", "MySaveFile", extensionList);
}
GUILayout.EndVertical();
GUILayout.Space(20);
GUILayout.Label(_path);
GUILayout.EndHorizontal();
}
public void WriteResult(string[] paths) {
if (paths.Length == 0) {
return;
}
_path = "";
foreach (var p in paths) {
_path += p + "\n";
}
}
public void WriteResult(string path) {
_path = path;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5148400295519405d82bb0fa65246ea2
timeCreated: 1483902788
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,248 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 3
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 0
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 10
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 1
m_BakeBackend: 0
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringMode: 0
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 0
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &382763637
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 382763642}
- component: {fileID: 382763641}
- component: {fileID: 382763640}
- component: {fileID: 382763639}
- component: {fileID: 382763638}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &382763638
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 382763637}
m_Enabled: 1
--- !u!124 &382763639
Behaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 382763637}
m_Enabled: 1
--- !u!92 &382763640
Behaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 382763637}
m_Enabled: 1
--- !u!20 &382763641
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 382763637}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 0
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &382763642
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 382763637}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &986049433
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 986049435}
- component: {fileID: 986049434}
m_Layer: 0
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &986049434
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 986049433}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5148400295519405d82bb0fa65246ea2, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &986049435
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 986049433}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d97280fe82b874466870f709c3315d41
timeCreated: 1483902786
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,53 @@
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using SFB;
[RequireComponent(typeof(Button))]
public class CanvasSampleOpenFileImage : MonoBehaviour, IPointerDownHandler {
public RawImage output;
#if UNITY_WEBGL && !UNITY_EDITOR
//
// WebGL
//
[DllImport("__Internal")]
private static extern void UploadFile(string gameObjectName, string methodName, string filter, bool multiple);
public void OnPointerDown(PointerEventData eventData) {
UploadFile(gameObject.name, "OnFileUpload", ".png, .jpg", false);
}
// Called from browser
public void OnFileUpload(string url) {
StartCoroutine(OutputRoutine(url));
}
#else
//
// Standalone platforms & editor
//
public void OnPointerDown(PointerEventData eventData) { }
void Start() {
var button = GetComponent<Button>();
button.onClick.AddListener(OnClick);
}
private void OnClick() {
var paths = StandaloneFileBrowser.OpenFilePanel("Title", "", ".png", false);
if (paths.Length > 0) {
StartCoroutine(OutputRoutine(new System.Uri(paths[0]).AbsoluteUri));
}
}
#endif
private IEnumerator OutputRoutine(string url) {
var loader = new WWW(url);
yield return loader;
output.texture = loader.texture;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 331c95b7bf39e4792acecff50a972040
timeCreated: 1489946149
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,53 @@
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using SFB;
[RequireComponent(typeof(Button))]
public class CanvasSampleOpenFileText : MonoBehaviour, IPointerDownHandler {
public Text output;
#if UNITY_WEBGL && !UNITY_EDITOR
//
// WebGL
//
[DllImport("__Internal")]
private static extern void UploadFile(string gameObjectName, string methodName, string filter, bool multiple);
public void OnPointerDown(PointerEventData eventData) {
UploadFile(gameObject.name, "OnFileUpload", ".txt", false);
}
// Called from browser
public void OnFileUpload(string url) {
StartCoroutine(OutputRoutine(url));
}
#else
//
// Standalone platforms & editor
//
public void OnPointerDown(PointerEventData eventData) { }
void Start() {
var button = GetComponent<Button>();
button.onClick.AddListener(OnClick);
}
private void OnClick() {
var paths = StandaloneFileBrowser.OpenFilePanel("Title", "", "txt", false);
if (paths.Length > 0) {
StartCoroutine(OutputRoutine(new System.Uri(paths[0]).AbsoluteUri));
}
}
#endif
private IEnumerator OutputRoutine(string url) {
var loader = new WWW(url);
yield return loader;
output.text = loader.text;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 99a65d6437df64949b37cba4eadc67a2
timeCreated: 1489946149
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,62 @@
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using SFB;
[RequireComponent(typeof(Button))]
public class CanvasSampleOpenFileTextMultiple : MonoBehaviour, IPointerDownHandler {
public Text output;
#if UNITY_WEBGL && !UNITY_EDITOR
//
// WebGL
//
[DllImport("__Internal")]
private static extern void UploadFile(string gameObjectName, string methodName, string filter, bool multiple);
public void OnPointerDown(PointerEventData eventData) {
UploadFile(gameObject.name, "OnFileUpload", ".txt", true);
}
// Called from browser
public void OnFileUpload(string urls) {
StartCoroutine(OutputRoutine(urls.Split(',')));
}
#else
//
// Standalone platforms & editor
//
public void OnPointerDown(PointerEventData eventData) { }
void Start() {
var button = GetComponent<Button>();
button.onClick.AddListener(OnClick);
}
private void OnClick() {
// var paths = StandaloneFileBrowser.OpenFilePanel("Title", "", "txt", true);
var paths = StandaloneFileBrowser.OpenFilePanel("Open File", "", "", true);
if (paths.Length > 0) {
var urlArr = new List<string>(paths.Length);
for (int i = 0; i < paths.Length; i++) {
urlArr.Add(new System.Uri(paths[i]).AbsoluteUri);
}
StartCoroutine(OutputRoutine(urlArr.ToArray()));
}
}
#endif
private IEnumerator OutputRoutine(string[] urlArr) {
var outputText = "";
for (int i = 0; i < urlArr.Length; i++) {
var loader = new WWW(urlArr[i]);
yield return loader;
outputText += loader.text;
}
output.text = outputText;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 71c09849449d61e47a4599e06b964998
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,65 @@
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using SFB;
[RequireComponent(typeof(Button))]
public class CanvasSampleSaveFileImage : MonoBehaviour, IPointerDownHandler {
public Text output;
private byte[] _textureBytes;
void Awake() {
// Create red texture
var width = 100;
var height = 100;
Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
tex.SetPixel(i, j, Color.red);
}
}
tex.Apply();
_textureBytes = tex.EncodeToPNG();
UnityEngine.Object.Destroy(tex);
}
#if UNITY_WEBGL && !UNITY_EDITOR
//
// WebGL
//
[DllImport("__Internal")]
private static extern void DownloadFile(string gameObjectName, string methodName, string filename, byte[] byteArray, int byteArraySize);
// Broser plugin should be called in OnPointerDown.
public void OnPointerDown(PointerEventData eventData) {
DownloadFile(gameObject.name, "OnFileDownload", "sample.png", _textureBytes, _textureBytes.Length);
}
// Called from browser
public void OnFileDownload() {
output.text = "File Successfully Downloaded";
}
#else
//
// Standalone platforms & editor
//
public void OnPointerDown(PointerEventData eventData) { }
// Listen OnClick event in standlone builds
void Start() {
var button = GetComponent<Button>();
button.onClick.AddListener(OnClick);
}
public void OnClick() {
var path = StandaloneFileBrowser.SaveFilePanel("Title", "", "sample", "png");
if (!string.IsNullOrEmpty(path)) {
File.WriteAllBytes(path, _textureBytes);
}
}
#endif
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6e681018aa67241a69b8447678ec3b4e
timeCreated: 1489946149
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using SFB;
[RequireComponent(typeof(Button))]
public class CanvasSampleSaveFileText : MonoBehaviour, IPointerDownHandler {
public Text output;
// Sample text data
private string _data = "Example text created by StandaloneFileBrowser";
#if UNITY_WEBGL && !UNITY_EDITOR
//
// WebGL
//
[DllImport("__Internal")]
private static extern void DownloadFile(string gameObjectName, string methodName, string filename, byte[] byteArray, int byteArraySize);
// Broser plugin should be called in OnPointerDown.
public void OnPointerDown(PointerEventData eventData) {
var bytes = Encoding.UTF8.GetBytes(_data);
DownloadFile(gameObject.name, "OnFileDownload", "sample.txt", bytes, bytes.Length);
}
// Called from browser
public void OnFileDownload() {
output.text = "File Successfully Downloaded";
}
#else
//
// Standalone platforms & editor
//
public void OnPointerDown(PointerEventData eventData) { }
// Listen OnClick event in standlone builds
void Start() {
var button = GetComponent<Button>();
button.onClick.AddListener(OnClick);
}
public void OnClick() {
var path = StandaloneFileBrowser.SaveFilePanel("Title", "", "sample", "txt");
if (!string.IsNullOrEmpty(path)) {
File.WriteAllText(path, _data);
}
}
#endif
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8e97f52f0bd664ee78305dae0094a755
timeCreated: 1489946149
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c0e4eec5741834194a946535d535405c
timeCreated: 1483902786
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View 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);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3c708be74128e4ced9b79eaaf80e8443
timeCreated: 1483902788
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2650af8de2cda46b99b1bc7cf5d30ca5
timeCreated: 1483902788
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5d3a668018554b8a89c3fe12de72b60c
timeCreated: 1538067919

View 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

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bcb49ddb0ed5644fda9c3b055cafa27a
timeCreated: 1483902788
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 194e247414a78461d83ae606c1b96917
timeCreated: 1483902788
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -16,7 +16,7 @@
"com.unity.test-framework": "1.6.0",
"com.unity.timeline": "1.8.9",
"com.unity.ugui": "2.0.0",
"com.unity.visualscripting": "1.9.8",
"com.unity.visualscripting": "1.9.9",
"com.unity.modules.accessibility": "1.0.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",

View File

@@ -273,7 +273,7 @@
}
},
"com.unity.visualscripting": {
"version": "1.9.8",
"version": "1.9.9",
"depth": 0,
"source": "registry",
"dependencies": {

View File

@@ -70,6 +70,7 @@ PlayerSettings:
androidStartInFullscreen: 1
androidRenderOutsideSafeArea: 1
androidUseSwappy: 1
androidDisplayOptions: 1
androidBlitType: 0
androidResizeableActivity: 1
androidDefaultWindowWidth: 1920
@@ -86,6 +87,7 @@ PlayerSettings:
muteOtherAudioSources: 0
Prepare IOS For Recording: 0
Force IOS Speakers When Recording: 0
audioSpatialExperience: 0
deferSystemGesturesMode: 0
hideHomeButton: 0
submitAnalytics: 1
@@ -272,6 +274,9 @@ PlayerSettings:
AndroidBuildApkPerCpuArchitecture: 0
AndroidTVCompatibility: 0
AndroidIsGame: 1
androidAppCategory: 3
useAndroidAppCategory: 1
androidAppCategoryOther:
AndroidEnableTango: 0
androidEnableBanner: 1
androidUseLowAccuracyLocation: 0
@@ -594,7 +599,7 @@ PlayerSettings:
gcIncremental: 1
gcWBarrierValidation: 0
apiCompatibilityLevelPerPlatform: {}
editorAssembliesCompatibilityLevel: 1
editorAssembliesCompatibilityLevel: 2
m_RenderingPath: 1
m_MobileRenderingPath: 1
metroPackageName: ScreenCapture
@@ -671,7 +676,7 @@ PlayerSettings:
hmiCpuConfiguration:
hmiLogStartupTiming: 0
qnxGraphicConfPath:
apiCompatibilityLevel: 6
apiCompatibilityLevel: 3
captureStartupLogs: {}
activeInputHandler: 1
windowsGamepadBackendHint: 0
@@ -689,3 +694,4 @@ PlayerSettings:
androidVulkanDenyFilterList: []
androidVulkanAllowFilterList: []
androidVulkanDeviceFilterListAsset: {fileID: 0}
d3d12DeviceFilterListAsset: {fileID: 0}