Basic saving and loading system

This commit is contained in:
Braedon 2022-01-30 07:03:37 -05:00
parent 7330d19ff6
commit d361f45590
127 changed files with 4967 additions and 33 deletions

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:

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,40 @@
fileFormatVersion: 2
guid: 110fdfb459db4fc448a2ccd37e200fa4
folderAsset: yes
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
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:

View file

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

View file

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

View file

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

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: ddf122e0e89124ce78aacfeecb3ec554
timeCreated: 1508179371
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

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

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

View file

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

View file

@ -0,0 +1,14 @@
{
"name": "VorbisPluginImpl",
"rootNamespace": "OggVorbis",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6369f65a3f137eb448c3456fdbf498ff
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

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

View file

@ -0,0 +1,89 @@
using System.Runtime.InteropServices;
namespace OggVorbis
{
internal static class NativeBridge
{
#if UNITY_IOS && !UNITY_EDITOR
private const string PLUGIN_NAME = "__Internal";
#else
private const string PLUGIN_NAME = "VorbisPlugin";
#endif
[DllImport(PLUGIN_NAME,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "write_all_pcm_data_to_file")]
internal static extern int WriteAllPcmDataToFile(
string filePath,
float[] samples,
int samplesLength,
short channels,
int frequency,
float base_quality,
int samplesToRead);
[DllImport(PLUGIN_NAME,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "write_all_pcm_data_to_memory")]
internal static extern int WriteAllPcmDataToMemory(
out System.IntPtr bytesPtr,
out int bytesLength,
float[] samples,
int samplesLength,
short channels,
int frequency,
float base_quality,
int samplesToRead);
[DllImport(PLUGIN_NAME,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "free_memory_array_for_write_all_pcm_data")]
internal static extern int FreeMemoryArrayForWriteAllPcmData(
System.IntPtr bytesNativeArray);
[DllImport(PLUGIN_NAME,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "read_all_pcm_data_from_file")]
internal static extern int ReadAllPcmDataFromFile(
string filePath,
out System.IntPtr samples,
out int samplesLength,
out short channels,
out int frequency,
int maxSamplesToRead);
[DllImport(PLUGIN_NAME,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "read_all_pcm_data_from_memory")]
internal static extern int ReadAllPcmDataFromMemory(
byte[] memoryArray,
int memoryArrayLength,
out System.IntPtr samples,
out int samplesLength,
out short channels,
out int frequency,
int maxSamplesToRead);
[DllImport(PLUGIN_NAME,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "free_samples_array_native_memory")]
internal static extern int FreeSamplesArrayNativeMemory(
ref System.IntPtr samples);
[DllImport(PLUGIN_NAME,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "open_read_file_stream")]
internal static extern System.IntPtr OpenReadFileStream(
string filePath,
out short channels,
out int frequency);
[DllImport(PLUGIN_NAME,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "read_from_file_stream")]
internal static extern int ReadFromFileStream(
System.IntPtr state,
float[] samplesToFill,
int maxSamplesToRead);
[DllImport(PLUGIN_NAME,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "close_file_stream")]
internal static extern int CloseFileStream(
System.IntPtr state);
}
}

View file

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

View file

@ -0,0 +1,20 @@
namespace OggVorbis
{
public enum NativeErrorCode
{
ERROR_INVALID_FILEPATH_PARAMETER = -1,
ERROR_CANNOT_OPEN_FILE_FOR_WRITE = -2,
ERROR_CANNOT_OPEN_FILE_FOR_READ = -3,
ERROR_INPUT_FILESTREAM_IS_NOT_OGG_STREAM = -4,
ERROR_READING_OGG_STREAM = -5,
ERROR_INVALID_SAMPLES_PARAMETER = -10,
ERROR_INVALID_SAMPLESLENGTH_PARAMETER = -11,
ERROR_INVALID_CHANNELS_PARAMETER = -12,
ERROR_INVALID_FREQUENCY_PARAMETER = -13,
ERROR_INVALID_BASE_QUALITY_PARAMETER = -14,
ERROR_MALLOC_RETURNED_NULL = -15,
ERROR_BYTES_MEMORY_ARRAY_NULL = -16,
ERROR_INVALID_WRITE_CALLBACK_PARAMETER = -17,
}
}

View file

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

View file

@ -0,0 +1,27 @@
namespace OggVorbis
{
public class NativeErrorException : System.Exception
{
public NativeErrorCode NativeErrorCode { get; }
private NativeErrorException(NativeErrorCode nativeErrorCode)
: base($"Error code: {nativeErrorCode}")
{
NativeErrorCode = nativeErrorCode;
}
public override string ToString()
{
return $"{nameof(NativeErrorException)} {Message}";
}
internal static void ThrowExceptionIfNecessary(int returnValue)
{
if (returnValue == 0)
{
return;
}
throw new NativeErrorException((NativeErrorCode)returnValue);
}
}
}

View file

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

View file

@ -0,0 +1,170 @@
using System.Runtime.InteropServices;
namespace OggVorbis
{
public static class VorbisPlugin
{
public static void Save(
string filePath,
UnityEngine.AudioClip audioClip,
float quality = 0.4f,
int samplesToRead = 1024)
{
if (string.IsNullOrWhiteSpace(filePath))
{
throw new System.ArgumentException("The file path is null or white space");
}
if (audioClip == null)
{
throw new System.ArgumentNullException(nameof(audioClip));
}
if (samplesToRead <= 0)
{
throw new System.ArgumentOutOfRangeException(nameof(samplesToRead));
}
short finalChannelsCount = (short)audioClip.channels;
if (finalChannelsCount != 1 && finalChannelsCount != 2)
{
throw new System.ArgumentException($"Only one or two channels are supported, provided channels count: {finalChannelsCount}");
}
if (!filePath.EndsWith(".ogg"))
{
filePath += ".ogg";
}
float[] pcm = new float[audioClip.samples * audioClip.channels];
audioClip.GetData(pcm, 0);
int returnCode = NativeBridge.WriteAllPcmDataToFile(filePath, pcm, pcm.Length, finalChannelsCount, audioClip.frequency, quality, samplesToRead);
NativeErrorException.ThrowExceptionIfNecessary(returnCode);
}
public static byte[] GetOggVorbis(
UnityEngine.AudioClip audioClip,
float quality = 0.4f,
int samplesToRead = 1024)
{
if (audioClip == null)
{
throw new System.ArgumentNullException(nameof(audioClip));
}
if (samplesToRead <= 0)
{
throw new System.ArgumentOutOfRangeException(nameof(samplesToRead));
}
short finalChannelsCount = (short)audioClip.channels;
if (finalChannelsCount != 1 && finalChannelsCount != 2)
{
throw new System.ArgumentException($"Only one or two channels are supported, provided channels count: {finalChannelsCount}");
}
int returnCode;
System.IntPtr bytesPtr = System.IntPtr.Zero;
byte[] bytes;
try
{
float[] pcm = new float[audioClip.samples * audioClip.channels];
audioClip.GetData(pcm, 0);
returnCode = NativeBridge.WriteAllPcmDataToMemory(
out bytesPtr,
out int bytesLength,
pcm,
pcm.Length,
finalChannelsCount,
audioClip.frequency,
quality,
samplesToRead);
NativeErrorException.ThrowExceptionIfNecessary(returnCode);
bytes = new byte[bytesLength];
Marshal.Copy(bytesPtr, bytes, 0, bytesLength);
}
finally
{
returnCode = NativeBridge.FreeMemoryArrayForWriteAllPcmData(bytesPtr);
NativeErrorException.ThrowExceptionIfNecessary(returnCode);
}
return bytes;
}
public static UnityEngine.AudioClip Load(string filePath, int maxSamplesToRead = 1024)
{
if (string.IsNullOrWhiteSpace(filePath))
{
throw new System.ArgumentException("The file path is null or white space");
}
if (maxSamplesToRead <= 0)
{
throw new System.ArgumentOutOfRangeException(nameof(maxSamplesToRead));
}
if (!System.IO.File.Exists(filePath))
{
throw new System.IO.FileNotFoundException();
}
int returnCode;
System.IntPtr pcmPtr = System.IntPtr.Zero;
UnityEngine.AudioClip audioClip;
try
{
returnCode = NativeBridge.ReadAllPcmDataFromFile(
filePath,
out pcmPtr,
out int pcmLength,
out short channels,
out int frequency,
maxSamplesToRead);
NativeErrorException.ThrowExceptionIfNecessary(returnCode);
float[] pcm = new float[pcmLength];
Marshal.Copy(pcmPtr, pcm, 0, pcmLength);
audioClip = UnityEngine.AudioClip.Create(System.IO.Path.GetFileName(filePath), pcmLength / channels, channels, frequency, false);
audioClip.SetData(pcm, 0);
}
finally
{
returnCode = NativeBridge.FreeSamplesArrayNativeMemory(ref pcmPtr);
NativeErrorException.ThrowExceptionIfNecessary(returnCode);
}
return audioClip;
}
public static UnityEngine.AudioClip ToAudioClip(byte[] bytes, string audioClipName, int maxSamplesToRead = 1024)
{
if (bytes == null)
{
throw new System.ArgumentNullException(nameof(bytes));
}
if (bytes.Length < 10)
{
throw new System.ArgumentException(nameof(bytes));
}
if (string.IsNullOrWhiteSpace(audioClipName))
{
throw new System.ArgumentException("Please provide an audio clip name");
}
if (maxSamplesToRead <= 0)
{
throw new System.ArgumentOutOfRangeException(nameof(maxSamplesToRead));
}
int returnCode;
System.IntPtr pcmPtr = System.IntPtr.Zero;
UnityEngine.AudioClip audioClip = null;
try
{
returnCode = NativeBridge.ReadAllPcmDataFromMemory(
bytes,
bytes.Length,
out pcmPtr,
out int pcmLength,
out short channels,
out int frequency,
maxSamplesToRead);
NativeErrorException.ThrowExceptionIfNecessary(returnCode);
float[] pcm = new float[pcmLength];
Marshal.Copy(pcmPtr, pcm, 0, pcmLength);
audioClip = UnityEngine.AudioClip.Create(audioClipName, pcmLength / channels, channels, frequency, false);
audioClip.SetData(pcm, 0);
}
finally
{
returnCode = NativeBridge.FreeSamplesArrayNativeMemory(ref pcmPtr);
NativeErrorException.ThrowExceptionIfNecessary(returnCode);
}
return audioClip;
}
}
}

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: f212bce8ee6b531478c1cbf853aefd27
folderAsset: yes
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 786d6d20fa5aa734e9663361b25b9a13
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings:
CPU: ARM64
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 6b4324dc320d4954d98e6f02832e1310
folderAsset: yes
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 984717b87470169429b9186dfacf490b
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View file

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

View file

@ -0,0 +1,80 @@
fileFormatVersion: 2
guid: 3dd18ede30e7e4dcbaae02cd851ffd1c
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: OSX
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- 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: 7f766c141793afa4cb9995b7ec9dad90
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

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

View file

@ -0,0 +1,82 @@
fileFormatVersion: 2
guid: c604fbaeb4366014db10d1915bf4533d
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: 0
Exclude OSXUniversal: 0
Exclude Win: 0
Exclude Win64: 0
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: x86
DefaultValueInitialized: true
OS: Windows
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

View file

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

View file

@ -0,0 +1,82 @@
fileFormatVersion: 2
guid: 8366486b20439f44ca3c6f11acb29fee
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: 0
Exclude OSXUniversal: 0
Exclude Win: 1
Exclude Win64: 0
- 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: Windows
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: None
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View file

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

View file

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: d0f7d099267d14a02bce1e39b785d79c
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: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 75feb76cf68884b5b92865a558e77af2
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: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 27e6a8c0604d24215b304cb34439667b
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: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: f8cfa486d31994f71acc5a37aabb5fad
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: 0
settings:
DefaultValueInitialized: true
- first:
iPhone: iOS
second:
enabled: 1
settings:
AddToEmbeddedBinaries: false
userData:
assetBundleName:
assetBundleVariant:

View file

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

@ -4962,15 +4962,15 @@ MonoBehaviour:
m_Calls: m_Calls:
- m_Target: {fileID: 1423699437} - m_Target: {fileID: 1423699437}
m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.Editor, Assembly-CSharp m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.Editor, Assembly-CSharp
m_MethodName: DebugSave m_MethodName: SaveRemix
m_Mode: 1 m_Mode: 6
m_Arguments: m_Arguments:
m_ObjectArgument: {fileID: 0} m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0 m_IntArgument: 0
m_FloatArgument: 0 m_FloatArgument: 0
m_StringArgument: m_StringArgument:
m_BoolArgument: 0 m_BoolArgument: 1
m_CallState: 2 m_CallState: 2
--- !u!114 &678553527 --- !u!114 &678553527
MonoBehaviour: MonoBehaviour:
@ -7491,9 +7491,9 @@ MonoBehaviour:
m_OnClick: m_OnClick:
m_PersistentCalls: m_PersistentCalls:
m_Calls: m_Calls:
- m_Target: {fileID: 423099699} - m_Target: {fileID: 1423699437}
m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.CommandManager, Assembly-CSharp m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.Editor, Assembly-CSharp
m_MethodName: Redo m_MethodName: SelectMusic
m_Mode: 1 m_Mode: 1
m_Arguments: m_Arguments:
m_ObjectArgument: {fileID: 0} m_ObjectArgument: {fileID: 0}
@ -10994,7 +10994,19 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1665554292} m_TargetGraphic: {fileID: 1665554292}
m_OnClick: m_OnClick:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls:
- m_Target: {fileID: 1423699437}
m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.Editor, Assembly-CSharp
m_MethodName: OpenRemix
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 &1665554292 --- !u!114 &1665554292
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -96,6 +96,24 @@ namespace RhythmHeavenMania
} }
} }
public void LoadRemix(string json)
{
SortEventsList();
Beatmap = JsonConvert.DeserializeObject<Beatmap>(json);
Conductor.instance.SetBpm(Beatmap.bpm);
if (Beatmap.entities.Count >= 1)
{
SetCurrentGame(Beatmap.entities[0].datamodel.Split(0));
SetGame(Beatmap.entities[0].datamodel.Split(0));
}
else
{
SetGame("noGame");
}
}
// LateUpdate works a bit better but causes a bit of bugs, so remind me to fix those eventually // LateUpdate works a bit better but causes a bit of bugs, so remind me to fix those eventually
private void Update() private void Update()
{ {

View file

@ -66,7 +66,7 @@ namespace RhythmHeavenMania.Editor
} }
} }
private void Clear() public void Clear()
{ {
historyStack.Clear(); historyStack.Clear();
redoHistoryStack.Clear(); redoHistoryStack.Clear();

View file

@ -1,14 +1,23 @@
using System;
using System.IO;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using UnityEngine.Networking;
using Newtonsoft.Json; using Newtonsoft.Json;
using TMPro; using TMPro;
using Starpelly; using Starpelly;
using SFB;
using RhythmHeavenMania.Editor.Track; using RhythmHeavenMania.Editor.Track;
using RhythmHeavenMania.Util;
using System.IO.Compression;
using System.Text;
namespace RhythmHeavenMania.Editor namespace RhythmHeavenMania.Editor
{ {
@ -38,7 +47,9 @@ namespace RhythmHeavenMania.Editor
[SerializeField] private Button EditorSettingsBTN; [SerializeField] private Button EditorSettingsBTN;
[SerializeField] private Button EditorThemeBTN; [SerializeField] private Button EditorThemeBTN;
public static List<TimelineEventObj> EventObjs = new List<TimelineEventObj>(); [Header("Properties")]
private bool changedMusic = false;
private string currentRemixPath = "";
public static Editor instance { get; private set; } public static Editor instance { get; private set; }
@ -142,6 +153,25 @@ namespace RhythmHeavenMania.Editor
CommandManager.instance.Execute(new Commands.Move(result)); CommandManager.instance.Execute(new Commands.Move(result));
} }
} }
if (Input.GetKey(KeyCode.LeftControl))
{
if (Input.GetKeyDown(KeyCode.O))
{
OpenRemix();
}
else if (Input.GetKey(KeyCode.LeftAlt))
{
if (Input.GetKeyDown(KeyCode.S))
{
SaveRemix(true);
}
}
else if (Input.GetKeyDown(KeyCode.S))
{
SaveRemix(false);
}
}
} }
public static Sprite GameIcon(string name) public static Sprite GameIcon(string name)
@ -149,12 +179,189 @@ namespace RhythmHeavenMania.Editor
return Resources.Load<Sprite>($"Sprites/Editor/GameIcons/{name}"); return Resources.Load<Sprite>($"Sprites/Editor/GameIcons/{name}");
} }
public void CopyJson() #region Dialogs
public void SelectMusic()
{
var extensions = new[]
{
new ExtensionFilter("Music Files", "mp3", "ogg", "wav")
};
StandaloneFileBrowser.OpenFilePanelAsync("Open File", "", extensions, false, async (string[] paths) =>
{
if (paths.Length > 0)
{
Conductor.instance.musicSource.clip = await LoadClip(Path.Combine(paths));
changedMusic = true;
}
}
);
// byte[] bytes = OggVorbis.VorbisPlugin.GetOggVorbis(Conductor.instance.musicSource.clip, 1);
// print(bytes.Length);
// OggVorbis.VorbisPlugin.Save(@"C:/Users/Braedon/Downloads/test.ogg", Conductor.instance.musicSource.clip, 1);
}
private async Task<AudioClip> LoadClip(string path)
{
AudioClip clip = null;
AudioType audioType = AudioType.OGGVORBIS;
// this is a bad solution but i'm lazy
if (path.Substring(path.Length - 3) == "ogg")
audioType = AudioType.OGGVORBIS;
else if (path.Substring(path.Length - 3) == "mp3")
audioType = AudioType.MPEG;
else if (path.Substring(path.Length - 3) == "wav")
audioType = AudioType.WAV;
using (UnityWebRequest uwr = UnityWebRequestMultimedia.GetAudioClip(path, audioType))
{
uwr.SendWebRequest();
try
{
while (!uwr.isDone) await Task.Delay(5);
if (uwr.result == UnityWebRequest.Result.ProtocolError) Debug.Log($"{uwr.error}");
else
{
clip = DownloadHandlerAudioClip.GetContent(uwr);
}
}
catch (Exception err)
{
Debug.Log($"{err.Message}, {err.StackTrace}");
}
}
return clip;
}
public void SaveRemix(bool saveAs = true)
{
if (saveAs == true)
{
SaveRemixFilePanel();
}
else
{
if (currentRemixPath == string.Empty)
{
SaveRemixFilePanel();
}
else
{
SaveRemixFile(currentRemixPath);
}
}
}
private void SaveRemixFilePanel()
{
var extensions = new[]
{
new ExtensionFilter("Rhythm Heaven Mania Remix File", "rhmania")
};
StandaloneFileBrowser.SaveFilePanelAsync("Save Remix As", "", "remix_level", extensions, (string path) =>
{
if (path != String.Empty)
{
SaveRemixFile(path);
}
});
}
private void SaveRemixFile(string path)
{
using (FileStream zipFile = File.Open(path, FileMode.Create))
{
using (var archive = new ZipArchive(zipFile, ZipArchiveMode.Update, true))
{
var levelFile = archive.CreateEntry("remix.json", System.IO.Compression.CompressionLevel.NoCompression);
using (var zipStream = levelFile.Open())
zipStream.Write(Encoding.ASCII.GetBytes(GetJson()), 0, Encoding.ASCII.GetBytes(GetJson()).Length);
if (changedMusic || currentRemixPath != path)
{
byte[] bytes = OggVorbis.VorbisPlugin.GetOggVorbis(Conductor.instance.musicSource.clip, 1);
var musicFile = archive.CreateEntry("song.ogg", System.IO.Compression.CompressionLevel.NoCompression);
using (var zipStream = musicFile.Open())
zipStream.Write(bytes, 0, bytes.Length);
}
}
}
}
public void OpenRemix()
{
var extensions = new[]
{
new ExtensionFilter("Rhythm Heaven Mania Remix File", "rhmania")
};
StandaloneFileBrowser.OpenFilePanelAsync("Open Remix", "", extensions, false, (string[] paths) =>
{
var path = Path.Combine(paths);
if (path != String.Empty)
{
using (FileStream zipFile = File.Open(path, FileMode.Open))
{
using (var archive = new ZipArchive(zipFile, ZipArchiveMode.Read))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
if (entry.Name == "remix.json")
{
using (var stream = entry.Open())
{
byte[] bytes;
using (var ms = new MemoryStream())
{
stream.CopyTo(ms);
bytes = ms.ToArray();
string json = Encoding.Default.GetString(bytes);
GameManager.instance.LoadRemix(json);
Timeline.instance.LoadRemix();
}
}
}
else if (entry.Name == "song.ogg")
{
using (var stream = entry.Open())
{
byte[] bytes;
using (var ms = new MemoryStream())
{
stream.CopyTo(ms);
bytes = ms.ToArray();
Conductor.instance.musicSource.clip = OggVorbis.VorbisPlugin.ToAudioClip(bytes, "music");
}
}
}
}
}
}
currentRemixPath = path;
CommandManager.instance.Clear();
}
});
}
#endregion
public string GetJson()
{ {
string json = string.Empty; string json = string.Empty;
json = JsonConvert.SerializeObject(GameManager.instance.Beatmap); json = JsonConvert.SerializeObject(GameManager.instance.Beatmap);
return json;
Debug.Log(json);
} }
public void DebugSave() public void DebugSave()

View file

@ -26,12 +26,12 @@ namespace RhythmHeavenMania.Editor.Track
Beatmap.TempoChange tempoChange = GameManager.instance.Beatmap.tempoChanges[i]; Beatmap.TempoChange tempoChange = GameManager.instance.Beatmap.tempoChanges[i];
AddTempoChange(false, tempoChange); AddTempoChange(false, tempoChange);
} }
StartingBPM.GetChild(0).GetComponent<TMP_Text>().text = GameManager.instance.Beatmap.bpm.ToString();
} }
private void Update() private void Update()
{ {
StartingBPM.GetChild(0).GetComponent<TMP_Text>().text = GameManager.instance.Beatmap.bpm.ToString();
if (Timeline.instance.timelineState.tempoChange && !Conductor.instance.NotStopped()) if (Timeline.instance.timelineState.tempoChange && !Conductor.instance.NotStopped())
{ {
if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Camera.main)) if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Camera.main))

View file

@ -80,9 +80,13 @@ namespace RhythmHeavenMania.Editor.Track
#region Initializers #region Initializers
public void Init() public void LoadRemix()
{ {
instance = this; for (int i = 0; i < eventObjs.Count; i++)
{
Destroy(eventObjs[i].gameObject);
}
eventObjs.Clear();
for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++) for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++)
{ {
@ -91,6 +95,13 @@ namespace RhythmHeavenMania.Editor.Track
AddEventObject(e.datamodel, false, new Vector3(e.beat, -e.track * LayerHeight()), e, false, RandomID()); AddEventObject(e.datamodel, false, new Vector3(e.beat, -e.track * LayerHeight()), e, false, RandomID());
} }
}
public void Init()
{
instance = this;
LoadRemix();
TimelineSlider.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB(); TimelineSlider.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
TimelineSlider.GetChild(1).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB(); TimelineSlider.GetChild(1).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
@ -477,7 +488,6 @@ namespace RhythmHeavenMania.Editor.Track
} }
} }
Editor.EventObjs.Add(eventObj);
eventObjs.Add(eventObj); eventObjs.Add(eventObj);
eventObj.eventObjID = eventId; eventObj.eventObjID = eventId;
@ -487,7 +497,7 @@ namespace RhythmHeavenMania.Editor.Track
public void DestroyEventObject(Beatmap.Entity entity) public void DestroyEventObject(Beatmap.Entity entity)
{ {
Editor.EventObjs.Remove(entity.eventObj); eventObjs.Remove(entity.eventObj);
GameManager.instance.Beatmap.entities.Remove(entity); GameManager.instance.Beatmap.entities.Remove(entity);
Timeline.instance.eventObjs.Remove(entity.eventObj); Timeline.instance.eventObjs.Remove(entity.eventObj);

View file

@ -0,0 +1,12 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace RhythmHeavenMania.Util
{
public class Audio
{
}
}

View file

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

8
Assets/Tests.meta Normal file
View file

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

Some files were not shown because too many files have changed in this diff Show more