补充示例
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Kirurobo
|
||||
{
|
||||
/// <summary>
|
||||
/// Basic filepanel sample
|
||||
/// </summary>
|
||||
public class FileDialogSample : MonoBehaviour
|
||||
{
|
||||
public Button openFileButton;
|
||||
public Button openMultipleFilesButton;
|
||||
public Button saveFileButton;
|
||||
public Text messageText;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
openFileButton.onClick.AddListener(OpenSingleFile);
|
||||
openMultipleFilesButton.onClick.AddListener(OpenMultipleFiles);
|
||||
saveFileButton.onClick.AddListener(OpenSaveFile);
|
||||
messageText.text = "Click a button!";
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Open the open file dialog to select single file.
|
||||
/// </summary>
|
||||
private void OpenSingleFile() {
|
||||
FilePanel.Settings settings = new FilePanel.Settings();
|
||||
settings.filters = new FilePanel.Filter[]
|
||||
{
|
||||
new FilePanel.Filter("All files", "*"),
|
||||
new FilePanel.Filter("Image files (*.png;*.jpg;*.jpeg;*.tiff;*.gif;*.tga)", "png", "jpg", "jpeg", "tiff", "gif", "tga"),
|
||||
new FilePanel.Filter("Documents (*.txt;*.rtf;*.doc;*.docx)", "txt", "rtf", "doc", "docx"),
|
||||
};
|
||||
settings.title = "Open a file!";
|
||||
settings.initialDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures);
|
||||
|
||||
messageText.text = "";
|
||||
FilePanel.OpenFilePanel(settings, (files) =>
|
||||
{
|
||||
messageText.text = "Open a file\n" + string.Join("\n", files);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Open the open file dialog to select multiple files.
|
||||
/// </summary>
|
||||
private void OpenMultipleFiles() {
|
||||
FilePanel.Settings settings = new FilePanel.Settings();
|
||||
settings.filters = new FilePanel.Filter[]
|
||||
{
|
||||
new FilePanel.Filter("Image files (*.png;*.jpg;*.jpeg;*.tiff;*.gif;*.tga)", "png", "jpg", "jpeg", "tiff", "gif", "tga"),
|
||||
new FilePanel.Filter("Documents (*.txt;*.rtf;*.doc;*.docx)", "txt", "rtf", "doc", "docx"),
|
||||
new FilePanel.Filter("All files", "*"),
|
||||
};
|
||||
settings.flags = FilePanel.Flag.AllowMultipleSelection;
|
||||
settings.title = "Open multiple files!";
|
||||
settings.initialDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
|
||||
|
||||
messageText.text = "";
|
||||
FilePanel.OpenFilePanel(settings, (files) =>
|
||||
{
|
||||
messageText.text = "Open multiple files\n" + string.Join("\n", files);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Open the save file dialog.
|
||||
/// </summary>
|
||||
private void OpenSaveFile() {
|
||||
FilePanel.Settings settings = new FilePanel.Settings();
|
||||
settings.filters = new FilePanel.Filter[]
|
||||
{
|
||||
new FilePanel.Filter("Text file (*.txt;*.log)", "txt", "log"),
|
||||
new FilePanel.Filter("Image files (*.png;*.jpg;*.jpeg;*.tiff;*.gif;*.tga)", "png", "jpg", "jpeg", "tiff", "gif", "tga"),
|
||||
new FilePanel.Filter("All files", "*"),
|
||||
};
|
||||
settings.title = "No save is actually performed";
|
||||
settings.initialFile = "Test.txt";
|
||||
|
||||
messageText.text = "";
|
||||
FilePanel.SaveFilePanel(settings, (files) =>
|
||||
{
|
||||
messageText.text = "Selected file\n" + string.Join("\n", files);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb6dba400744842c1b9025c020a1dd4e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48a0f5141a4d64ffd86a58d24b841e0c
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,63 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!850595691 &4890085278179872738
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: FileDialogSampleSettings
|
||||
serializedVersion: 3
|
||||
m_GIWorkflowMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 1
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 1
|
||||
m_BakeBackend: 1
|
||||
m_LightmapMaxSize: 1024
|
||||
m_BakeResolution: 40
|
||||
m_Padding: 2
|
||||
m_TextureCompression: 1
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 2
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 2
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherRayCount: 256
|
||||
m_FinalGatherFiltering: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVREnvironmentSampleCount: 500
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRMinBounces: 2
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRFilteringMode: 2
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24c3b38da5d7645cca546e4a61bf8980
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 4890085278179872738
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user