Merge pull request #21 from croakfang/master

Add MobUma List, Outline width setting,  StandaloneMode
This commit is contained in:
katboi01
2023-02-26 16:59:18 +01:00
committed by GitHub
1596 changed files with 113970 additions and 9539 deletions
+3
View File
@@ -51,6 +51,7 @@ public class GlobalValue : EditorWindow
Vector4 _Global_FogLength;
float _RimHorizonOffset;
float _UVEmissivePower;
Color _AmbientColor;
@@ -77,6 +78,7 @@ public class GlobalValue : EditorWindow
_GlobalCameraFov = EditorGUILayout.Slider("_GlobalCameraFov", _GlobalCameraFov, 0, 100);
_CylinderBlend = EditorGUILayout.Slider("_CylinderBlend", _CylinderBlend, 0, 100);
_RimHorizonOffset = EditorGUILayout.Slider("_RimHorizonOffset", _RimHorizonOffset, 0, 1);
_UVEmissivePower = EditorGUILayout.Slider("_UVEmissivePower", _UVEmissivePower, 0, 10);
//Color
_GlobalToonColor = EditorGUILayout.ColorField("阴影颜色", _GlobalToonColor);
_Global_FogColor = EditorGUILayout.ColorField("_Global_FogColor", _Global_FogColor);
@@ -136,6 +138,7 @@ public class GlobalValue : EditorWindow
Shader.SetGlobalFloat("_GlobalCameraFov", _GlobalCameraFov);
Shader.SetGlobalFloat("_CylinderBlend", _CylinderBlend);
Shader.SetGlobalFloat("_RimHorizonOffset", _RimHorizonOffset);
Shader.SetGlobalFloat("_UVEmissivePower", _UVEmissivePower);
//Vector Array
_MainParam.Clear();
_MainParam.Add(_MainParam_0);
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 94a19af2ebcc39448a7265778a585f83
guid: 18af0e9423bc204488746a0cfbdf8a99
folderAsset: yes
DefaultImporter:
externalObjects: {}
+47
View File
@@ -0,0 +1,47 @@
using System;
using UnityEngine;
namespace IK
{
public class IKCollisionData : ScriptableObject
{
public Parameter[] ParameterArray;
public bool IsHeightScale;
public struct RuntimeParameter
{
public Parameter.CollisionType Type;
public Vector3 Offset;
public bool IsBodyScale;
public float Param1;
public float Radius { get; }
}
[Serializable]
public class Parameter
{
public CollisionType Type;
public string LinkBoneName;
public Vector3 Offset;
public Scene SceneType;
public float Param1;
public enum CollisionType
{
Sphere = 0
}
public enum Scene
{
Event = 1,
Live = 2,
All = 65535
}
}
}
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 71e62a5239b1859499398c28ccee9b96
guid: 4a1187d9f807ff846bde338c226f3450
MonoImporter:
externalObjects: {}
serializedVersion: 2
+14
View File
@@ -0,0 +1,14 @@
{
"name": "Plugins",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fd1d627189c561043911a07470238b9c
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2658fe7276645e2458423f92943ea27d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 57e25b4a578dba94c9353f4633b20549
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
using System;
namespace SFB {
public interface IStandaloneFileBrowser {
string[] OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect);
string[] OpenFolderPanel(string title, string directory, bool multiselect);
string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions);
void OpenFilePanelAsync(string title, string directory, ExtensionFilter[] extensions, bool multiselect, Action<string[]> cb);
void OpenFolderPanelAsync(string title, string directory, bool multiselect, Action<string[]> cb);
void SaveFilePanelAsync(string title, string directory, string defaultName, ExtensionFilter[] extensions, Action<string> cb);
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7609f7b6787a54496aa41a3053fcc76a
timeCreated: 1483902788
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ca01b287ca68a7f48bc613d156008c9f
guid: ddc4e7b83981f244ba9a26b88c18cb67
folderAsset: yes
DefaultImporter:
externalObjects: {}
@@ -0,0 +1,132 @@
fileFormatVersion: 2
guid: e60958662eed5413d86143a0a69b731e
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXIntel: 1
Exclude OSXIntel64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 0
Exclude Win64: 0
Exclude iOS: 1
- first:
: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
OS: AnyOS
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: LinuxUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
iPhone: iOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,43 @@
fileFormatVersion: 2
guid: 110fdfb459db4fc448a2ccd37e200fa4
folderAsset: yes
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
DefaultValueInitialized: true
- first:
Standalone: OSXIntel
second:
enabled: 1
settings: {}
- first:
Standalone: OSXIntel64
second:
enabled: 1
settings: {}
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 996ea0b0fb9804844ba9595686ee3e7a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>18A391</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>StandaloneFileBrowser</string>
<key>CFBundleIdentifier</key>
<string>com.gkngkc.sfb</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>StandaloneFileBrowser</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0 </string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>10A255</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>18A384</string>
<key>DTSDKName</key>
<string>macosx10.14</string>
<key>DTXcode</key>
<string>1000</string>
<key>DTXcodeBuild</key>
<string>10A255</string>
</dict>
</plist>
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ce685769797f44046afa3e567860c94c
timeCreated: 1505756861
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a5a66f5db020f344c9327188aec2c060
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ddf122e0e89124ce78aacfeecb3ec554
timeCreated: 1508179371
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,90 @@
var StandaloneFileBrowserWebGLPlugin = {
// Open file.
// gameObjectNamePtr: Unique GameObject name. Required for calling back unity with SendMessage.
// methodNamePtr: Callback method name on given GameObject.
// filter: Filter files. Example filters:
// Match all image files: "image/*"
// Match all video files: "video/*"
// Match all audio files: "audio/*"
// Custom: ".plist, .xml, .yaml"
// multiselect: Allows multiple file selection
UploadFile: function(gameObjectNamePtr, methodNamePtr, filterPtr, multiselect) {
gameObjectName = Pointer_stringify(gameObjectNamePtr);
methodName = Pointer_stringify(methodNamePtr);
filter = Pointer_stringify(filterPtr);
// Delete if element exist
var fileInput = document.getElementById(gameObjectName)
if (fileInput) {
document.body.removeChild(fileInput);
}
fileInput = document.createElement('input');
fileInput.setAttribute('id', gameObjectName);
fileInput.setAttribute('type', 'file');
fileInput.setAttribute('style','display:none;');
fileInput.setAttribute('style','visibility:hidden;');
if (multiselect) {
fileInput.setAttribute('multiple', '');
}
if (filter) {
fileInput.setAttribute('accept', filter);
}
fileInput.onclick = function (event) {
// File dialog opened
this.value = null;
};
fileInput.onchange = function (event) {
// multiselect works
var urls = [];
for (var i = 0; i < event.target.files.length; i++) {
urls.push(URL.createObjectURL(event.target.files[i]));
}
// File selected
SendMessage(gameObjectName, methodName, urls.join());
// Remove after file selected
document.body.removeChild(fileInput);
}
document.body.appendChild(fileInput);
document.onmouseup = function() {
fileInput.click();
document.onmouseup = null;
}
},
// Save file
// DownloadFile method does not open SaveFileDialog like standalone builds, its just allows user to download file
// gameObjectNamePtr: Unique GameObject name. Required for calling back unity with SendMessage.
// methodNamePtr: Callback method name on given GameObject.
// filenamePtr: Filename with extension
// byteArray: byte[]
// byteArraySize: byte[].Length
DownloadFile: function(gameObjectNamePtr, methodNamePtr, filenamePtr, byteArray, byteArraySize) {
gameObjectName = Pointer_stringify(gameObjectNamePtr);
methodName = Pointer_stringify(methodNamePtr);
filename = Pointer_stringify(filenamePtr);
var bytes = new Uint8Array(byteArraySize);
for (var i = 0; i < byteArraySize; i++) {
bytes[i] = HEAPU8[byteArray + i];
}
var downloader = window.document.createElement('a');
downloader.setAttribute('id', gameObjectName);
downloader.href = window.URL.createObjectURL(new Blob([bytes], { type: 'application/octet-stream' }));
downloader.download = filename;
document.body.appendChild(downloader);
document.onmouseup = function() {
downloader.click();
document.body.removeChild(downloader);
document.onmouseup = null;
SendMessage(gameObjectName, methodName);
}
}
};
mergeInto(LibraryManager.library, StandaloneFileBrowserWebGLPlugin);
@@ -0,0 +1,99 @@
fileFormatVersion: 2
guid: 265aaf20a6d564e0fb00a9c4a7a9c300
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: WebGL
second:
enabled: 1
settings: {}
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: LinuxUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 369718b89f259f64bb8530151f3d9cc1
guid: cf7cd152578c2c9488c752cb5f9b692d
PluginImporter:
externalObjects: {}
serializedVersion: 2
@@ -22,6 +22,12 @@ PluginImporter:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,153 @@
using System;
namespace SFB {
public struct ExtensionFilter {
public string Name;
public string[] Extensions;
public ExtensionFilter(string filterName, params string[] filterExtensions) {
Name = filterName;
Extensions = filterExtensions;
}
}
public class StandaloneFileBrowser {
private static IStandaloneFileBrowser _platformWrapper = null;
static StandaloneFileBrowser() {
#if UNITY_STANDALONE_OSX
_platformWrapper = new StandaloneFileBrowserMac();
#elif UNITY_STANDALONE_WIN
_platformWrapper = new StandaloneFileBrowserWindows();
#elif UNITY_STANDALONE_LINUX
_platformWrapper = new StandaloneFileBrowserLinux();
#elif UNITY_EDITOR
_platformWrapper = new StandaloneFileBrowserEditor();
#endif
}
/// <summary>
/// Native open file dialog
/// </summary>
/// <param name="title">Dialog title</param>
/// <param name="directory">Root directory</param>
/// <param name="extension">Allowed extension</param>
/// <param name="multiselect">Allow multiple file selection</param>
/// <returns>Returns array of chosen paths. Zero length array when cancelled</returns>
public static string[] OpenFilePanel(string title, string directory, string extension, bool multiselect) {
var extensions = string.IsNullOrEmpty(extension) ? null : new [] { new ExtensionFilter("", extension) };
return OpenFilePanel(title, directory, extensions, multiselect);
}
/// <summary>
/// Native open file dialog
/// </summary>
/// <param name="title">Dialog title</param>
/// <param name="directory">Root directory</param>
/// <param name="extensions">List of extension filters. Filter Example: new ExtensionFilter("Image Files", "jpg", "png")</param>
/// <param name="multiselect">Allow multiple file selection</param>
/// <returns>Returns array of chosen paths. Zero length array when cancelled</returns>
public static string[] OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect) {
return _platformWrapper.OpenFilePanel(title, directory, extensions, multiselect);
}
/// <summary>
/// Native open file dialog async
/// </summary>
/// <param name="title">Dialog title</param>
/// <param name="directory">Root directory</param>
/// <param name="extension">Allowed extension</param>
/// <param name="multiselect">Allow multiple file selection</param>
/// <param name="cb">Callback")</param>
public static void OpenFilePanelAsync(string title, string directory, string extension, bool multiselect, Action<string[]> cb) {
var extensions = string.IsNullOrEmpty(extension) ? null : new [] { new ExtensionFilter("", extension) };
OpenFilePanelAsync(title, directory, extensions, multiselect, cb);
}
/// <summary>
/// Native open file dialog async
/// </summary>
/// <param name="title">Dialog title</param>
/// <param name="directory">Root directory</param>
/// <param name="extensions">List of extension filters. Filter Example: new ExtensionFilter("Image Files", "jpg", "png")</param>
/// <param name="multiselect">Allow multiple file selection</param>
/// <param name="cb">Callback")</param>
public static void OpenFilePanelAsync(string title, string directory, ExtensionFilter[] extensions, bool multiselect, Action<string[]> cb) {
_platformWrapper.OpenFilePanelAsync(title, directory, extensions, multiselect, cb);
}
/// <summary>
/// Native open folder dialog
/// NOTE: Multiple folder selection doesn't supported on Windows
/// </summary>
/// <param name="title"></param>
/// <param name="directory">Root directory</param>
/// <param name="multiselect"></param>
/// <returns>Returns array of chosen paths. Zero length array when cancelled</returns>
public static string[] OpenFolderPanel(string title, string directory, bool multiselect) {
return _platformWrapper.OpenFolderPanel(title, directory, multiselect);
}
/// <summary>
/// Native open folder dialog async
/// NOTE: Multiple folder selection doesn't supported on Windows
/// </summary>
/// <param name="title"></param>
/// <param name="directory">Root directory</param>
/// <param name="multiselect"></param>
/// <param name="cb">Callback")</param>
public static void OpenFolderPanelAsync(string title, string directory, bool multiselect, Action<string[]> cb) {
_platformWrapper.OpenFolderPanelAsync(title, directory, multiselect, cb);
}
/// <summary>
/// Native save file dialog
/// </summary>
/// <param name="title">Dialog title</param>
/// <param name="directory">Root directory</param>
/// <param name="defaultName">Default file name</param>
/// <param name="extension">File extension</param>
/// <returns>Returns chosen path. Empty string when cancelled</returns>
public static string SaveFilePanel(string title, string directory, string defaultName , string extension) {
var extensions = string.IsNullOrEmpty(extension) ? null : new [] { new ExtensionFilter("", extension) };
return SaveFilePanel(title, directory, defaultName, extensions);
}
/// <summary>
/// Native save file dialog
/// </summary>
/// <param name="title">Dialog title</param>
/// <param name="directory">Root directory</param>
/// <param name="defaultName">Default file name</param>
/// <param name="extensions">List of extension filters. Filter Example: new ExtensionFilter("Image Files", "jpg", "png")</param>
/// <returns>Returns chosen path. Empty string when cancelled</returns>
public static string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions) {
return _platformWrapper.SaveFilePanel(title, directory, defaultName, extensions);
}
/// <summary>
/// Native save file dialog async
/// </summary>
/// <param name="title">Dialog title</param>
/// <param name="directory">Root directory</param>
/// <param name="defaultName">Default file name</param>
/// <param name="extension">File extension</param>
/// <param name="cb">Callback")</param>
public static void SaveFilePanelAsync(string title, string directory, string defaultName , string extension, Action<string> cb) {
var extensions = string.IsNullOrEmpty(extension) ? null : new [] { new ExtensionFilter("", extension) };
SaveFilePanelAsync(title, directory, defaultName, extensions, cb);
}
/// <summary>
/// Native save file dialog async
/// </summary>
/// <param name="title">Dialog title</param>
/// <param name="directory">Root directory</param>
/// <param name="defaultName">Default file name</param>
/// <param name="extensions">List of extension filters. Filter Example: new ExtensionFilter("Image Files", "jpg", "png")</param>
/// <param name="cb">Callback")</param>
public static void SaveFilePanelAsync(string title, string directory, string defaultName, ExtensionFilter[] extensions, Action<string> cb) {
_platformWrapper.SaveFilePanelAsync(title, directory, defaultName, extensions, cb);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3c708be74128e4ced9b79eaaf80e8443
timeCreated: 1483902788
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,56 @@
#if UNITY_EDITOR
using System;
using UnityEditor;
namespace SFB {
public class StandaloneFileBrowserEditor : IStandaloneFileBrowser {
public string[] OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect) {
string path = "";
if (extensions == null) {
path = EditorUtility.OpenFilePanel(title, directory, "");
}
else {
path = EditorUtility.OpenFilePanelWithFilters(title, directory, GetFilterFromFileExtensionList(extensions));
}
return string.IsNullOrEmpty(path) ? new string[0] : new[] { path };
}
public void OpenFilePanelAsync(string title, string directory, ExtensionFilter[] extensions, bool multiselect, Action<string[]> cb) {
cb.Invoke(OpenFilePanel(title, directory, extensions, multiselect));
}
public string[] OpenFolderPanel(string title, string directory, bool multiselect) {
var path = EditorUtility.OpenFolderPanel(title, directory, "");
return string.IsNullOrEmpty(path) ? new string[0] : new[] {path};
}
public void OpenFolderPanelAsync(string title, string directory, bool multiselect, Action<string[]> cb) {
cb.Invoke(OpenFolderPanel(title, directory, multiselect));
}
public string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions) {
var ext = extensions != null ? extensions[0].Extensions[0] : "";
var name = string.IsNullOrEmpty(ext) ? defaultName : defaultName + "." + ext;
return EditorUtility.SaveFilePanel(title, directory, name, ext);
}
public void SaveFilePanelAsync(string title, string directory, string defaultName, ExtensionFilter[] extensions, Action<string> cb) {
cb.Invoke(SaveFilePanel(title, directory, defaultName, extensions));
}
// EditorUtility.OpenFilePanelWithFilters extension filter format
private static string[] GetFilterFromFileExtensionList(ExtensionFilter[] extensions) {
var filters = new string[extensions.Length * 2];
for (int i = 0; i < extensions.Length; i++) {
filters[(i * 2)] = extensions[i].Name;
filters[(i * 2) + 1] = string.Join(",", extensions[i].Extensions);
}
return filters;
}
}
}
#endif
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2650af8de2cda46b99b1bc7cf5d30ca5
timeCreated: 1483902788
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,137 @@
#if UNITY_STANDALONE_WIN
using System;
using System.IO;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Ookii.Dialogs;
namespace SFB {
// For fullscreen support
// - WindowWrapper class and GetActiveWindow() are required for modal file dialog.
// - "PlayerSettings/Visible In Background" should be enabled, otherwise when file dialog opened app window minimizes automatically.
public class WindowWrapper : IWin32Window {
private IntPtr _hwnd;
public WindowWrapper(IntPtr handle) { _hwnd = handle; }
public IntPtr Handle { get { return _hwnd; } }
}
public class StandaloneFileBrowserWindows : IStandaloneFileBrowser {
[DllImport("user32.dll")]
private static extern IntPtr GetActiveWindow();
public string[] OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect) {
var fd = new VistaOpenFileDialog();
fd.Title = title;
if (extensions != null) {
fd.Filter = GetFilterFromFileExtensionList(extensions);
fd.FilterIndex = 1;
}
else {
fd.Filter = string.Empty;
}
fd.Multiselect = multiselect;
if (!string.IsNullOrEmpty(directory)) {
fd.FileName = GetDirectoryPath(directory);
}
var res = fd.ShowDialog(new WindowWrapper(GetActiveWindow()));
var filenames = res == DialogResult.OK ? fd.FileNames : new string[0];
fd.Dispose();
return filenames;
}
public void OpenFilePanelAsync(string title, string directory, ExtensionFilter[] extensions, bool multiselect, Action<string[]> cb) {
cb.Invoke(OpenFilePanel(title, directory, extensions, multiselect));
}
public string[] OpenFolderPanel(string title, string directory, bool multiselect) {
var fd = new VistaFolderBrowserDialog();
fd.Description = title;
if (!string.IsNullOrEmpty(directory)) {
fd.SelectedPath = GetDirectoryPath(directory);
}
var res = fd.ShowDialog(new WindowWrapper(GetActiveWindow()));
var filenames = res == DialogResult.OK ? new []{ fd.SelectedPath } : new string[0];
fd.Dispose();
return filenames;
}
public void OpenFolderPanelAsync(string title, string directory, bool multiselect, Action<string[]> cb) {
cb.Invoke(OpenFolderPanel(title, directory, multiselect));
}
public string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions) {
var fd = new VistaSaveFileDialog();
fd.Title = title;
var finalFilename = "";
if (!string.IsNullOrEmpty(directory)) {
finalFilename = GetDirectoryPath(directory);
}
if (!string.IsNullOrEmpty(defaultName)) {
finalFilename += defaultName;
}
fd.FileName = finalFilename;
if (extensions != null) {
fd.Filter = GetFilterFromFileExtensionList(extensions);
fd.FilterIndex = 1;
fd.DefaultExt = extensions[0].Extensions[0];
fd.AddExtension = true;
}
else {
fd.DefaultExt = string.Empty;
fd.Filter = string.Empty;
fd.AddExtension = false;
}
var res = fd.ShowDialog(new WindowWrapper(GetActiveWindow()));
var filename = res == DialogResult.OK ? fd.FileName : "";
fd.Dispose();
return filename;
}
public void SaveFilePanelAsync(string title, string directory, string defaultName, ExtensionFilter[] extensions, Action<string> cb) {
cb.Invoke(SaveFilePanel(title, directory, defaultName, extensions));
}
// .NET Framework FileDialog Filter format
// https://msdn.microsoft.com/en-us/library/microsoft.win32.filedialog.filter
private static string GetFilterFromFileExtensionList(ExtensionFilter[] extensions) {
var filterString = "";
foreach (var filter in extensions) {
filterString += filter.Name + "(";
foreach (var ext in filter.Extensions) {
filterString += "*." + ext + ",";
}
filterString = filterString.Remove(filterString.Length - 1);
filterString += ") |";
foreach (var ext in filter.Extensions) {
filterString += "*." + ext + "; ";
}
filterString += "|";
}
filterString = filterString.Remove(filterString.Length - 1);
return filterString;
}
private static string GetDirectoryPath(string directory) {
var directoryPath = Path.GetFullPath(directory);
if (!directoryPath.EndsWith("\\")) {
directoryPath += "\\";
}
if (Path.GetPathRoot(directoryPath) == directoryPath) {
return directory;
}
return Path.GetDirectoryName(directoryPath) + Path.DirectorySeparatorChar;
}
}
}
#endif
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 194e247414a78461d83ae606c1b96917
timeCreated: 1483902788
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
{
"name": "StandalongFileBrowser.runtime",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 145e2572884581c48a08acf566c1a1d6
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -78,7 +78,10 @@ AnimatorStateTransition:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: IsLoop
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -4932711163649999293}
m_Solo: 0
@@ -212,19 +215,25 @@ AnimatorController:
m_DefaultFloat: 1
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: next
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: next_s
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: IsLoop
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
@@ -347,7 +356,10 @@ AnimatorStateTransition:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: IsLoop
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -1569566867637420955}
m_Solo: 0
@@ -7,7 +7,10 @@ AnimatorStateTransition:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: IsLoop
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -1046042063806159501}
m_Solo: 0
@@ -56,7 +59,10 @@ AnimatorStateTransition:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: IsLoop
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 5228601998091799676}
m_Solo: 0
@@ -85,7 +91,13 @@ AnimatorController:
m_DefaultFloat: 1
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: IsLoop
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
+463
View File
@@ -0,0 +1,463 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1679236400360698642
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1679236400360698643}
- component: {fileID: 1679236400360698641}
- component: {fileID: 1679236400360698640}
- component: {fileID: 7159069016347322542}
- component: {fileID: 5423960384028092001}
- component: {fileID: 4882398606576421441}
m_Layer: 5
m_Name: CharaSelect
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1679236400360698643
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1679236400360698642}
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:
- {fileID: 8943345654956533132}
- {fileID: 1679236400528196893}
- {fileID: 1679236400529307937}
- {fileID: 2014716433788527325}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 180, y: 250}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1679236400360698641
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1679236400360698642}
m_CullTransparentMesh: 1
--- !u!114 &1679236400360698640
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1679236400360698642}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.2}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &7159069016347322542
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1679236400360698642}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 1679236400360698640}
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &5423960384028092001
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1679236400360698642}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c73dbc71d1114ee4d9faf37a28216671, type: 3}
m_Name:
m_EditorClassIdentifier:
CharaId: 0
CostumeId:
CharaImage: {fileID: 1679236400528196890}
BackGroundImage: {fileID: 4359019069968187769}
CostumeImage: {fileID: 1679236400529307950}
IndexText: {fileID: 2233745518321098558}
--- !u!114 &4882398606576421441
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1679236400360698642}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 31a19414c41e5ae4aae2af33fee712f6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ShowMaskGraphic: 1
--- !u!1 &1679236400528196892
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1679236400528196893}
- component: {fileID: 1679236400528196891}
- component: {fileID: 1679236400528196890}
m_Layer: 5
m_Name: Chara
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1679236400528196893
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1679236400528196892}
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: 1679236400360698643}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -55}
m_SizeDelta: {x: 120, y: 120}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1679236400528196891
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1679236400528196892}
m_CullTransparentMesh: 1
--- !u!114 &1679236400528196890
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1679236400528196892}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: fcb07487bdd0f054f81d8865b4800c13, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &1679236400529307936
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1679236400529307937}
- component: {fileID: 1679236400529307951}
- component: {fileID: 1679236400529307950}
m_Layer: 5
m_Name: Dress
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1679236400529307937
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1679236400529307936}
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: 1679236400360698643}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -180}
m_SizeDelta: {x: 120, y: 120}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1679236400529307951
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1679236400529307936}
m_CullTransparentMesh: 1
--- !u!114 &1679236400529307950
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1679236400529307936}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 74c10446f10883c4683a526eb8380a5b, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &4346032192954077524
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8943345654956533132}
- component: {fileID: 9146919278922802724}
- component: {fileID: 4359019069968187769}
m_Layer: 5
m_Name: BG
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8943345654956533132
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4346032192954077524}
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: 1679236400360698643}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -115}
m_SizeDelta: {x: 345, y: 345}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &9146919278922802724
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4346032192954077524}
m_CullTransparentMesh: 1
--- !u!114 &4359019069968187769
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4346032192954077524}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.5019608}
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: fcb07487bdd0f054f81d8865b4800c13, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &7987743244650596613
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2014716433788527325}
- component: {fileID: 3508166106652295565}
- component: {fileID: 2233745518321098558}
m_Layer: 5
m_Name: Index
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2014716433788527325
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7987743244650596613}
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: 1679236400360698643}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -10, y: -10}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3508166106652295565
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7987743244650596613}
m_CullTransparentMesh: 1
--- !u!114 &2233745518321098558
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7987743244650596613}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: 036631af73b15ac41a9d10f75f5bbafe, type: 3}
m_FontSize: 25
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 56
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 1
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: db8e57d6cda624648bbe2c78faf0644f
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: fcb07487bdd0f054f81d8865b4800c13
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: 74c10446f10883c4683a526eb8380a5b
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 1
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
+5647 -160
View File
File diff suppressed because it is too large Load Diff
+6 -1
View File
@@ -131,7 +131,6 @@ public class CameraOrbit : MonoBehaviour
if (Input.GetMouseButton(0) && controlOn)
{
position -= Input.GetAxis("Mouse X") * transform.right * OrbitCamSpeedSlider.value;
OrbitCamZoomSlider.value -= Input.mouseScrollDelta.y * OrbitCamZoomSpeedSlider.value;
OrbitCamHeightSlider.value -= Input.GetAxis("Mouse Y") * OrbitCamSpeedSlider.value;
}
else
@@ -139,6 +138,11 @@ public class CameraOrbit : MonoBehaviour
controlOn = false;
}
if (!eventSystem.IsPointerOverGameObject())
{
OrbitCamZoomSlider.value -= Input.mouseScrollDelta.y * OrbitCamZoomSpeedSlider.value;
}
if ((Input.GetMouseButtonDown(2) || Input.GetKeyDown(KeyCode.LeftControl)) && !eventSystem.IsPointerOverGameObject())
{
CameraTargetHelper.SetActive(true);
@@ -153,6 +157,7 @@ public class CameraOrbit : MonoBehaviour
CameraTargetHelper.SetActive(false);
}
float camDist = OrbitCamZoomSlider.value;
OrbitCamHeightSlider.maxValue = camDist + 1 - camDist * 0.2f;
OrbitCamHeightSlider.minValue = -camDist + 1 + camDist * 0.2f;
+21 -5
View File
@@ -1,23 +1,27 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
public class Config
{
public static string configPath = Application.dataPath + "/../Config.json";
public static Config Instance;
public string Version = "";
public string LanguageTip = "Affects Uma names on the list. Language options: 0 - En, 1 - Jp";
public Language Language = Language.En;
public string MainPathTip = "Path to game folder, eg. D:\\Backup\\Cygames\\umamusume or D:/Backup/Cygames/umamusume";
public string MainPathTip = "Path to game folder, eg. D:/Backup/Cygames/umamusume";
public string MainPath = "";
public string WorkModeTip = "Affects how application work, options: 0 - work with game client, 1 - work without game client, Database needs to be updated manually";
public WorkMode WorkMode = WorkMode.Default;
public Config()
{
//TODO: Updating config file
Version = Application.version;
string configPath = Application.dataPath + "/../Config.json";
MainPath = $@"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Low"}\Cygames\umamusume";
if (!File.Exists(configPath))
@@ -32,17 +36,29 @@ public class Config
}
catch (Exception ex)
{
UmaViewerUI.Instance.LyricsText.text = "Config load error. Using default path. " + ex.Message;
UmaViewerUI.Instance.ShowMessage("Config load error. Using default. " + ex.Message);
MainPath = $@"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Low"}\Cygames\umamusume";
}
}
Instance = this;
}
public void UpdateConfig()
{
File.WriteAllText(configPath, JsonUtility.ToJson(this, true));
UmaViewerUI.Instance.ShowMessage("The configuration has changed. Please restart the application.");
}
}
public enum Language
{
En,
Jp
}
public enum WorkMode
{
Default,
Standalone
}
+20 -13
View File
@@ -17,7 +17,7 @@ public class ManifestDB
public ManifestDB()
{
string DBPath = $"{Config.Instance.MainPath}\\meta";
string DBPath = $"{Config.Instance.MainPath}\\meta_umaviewer";
ManifestDB.DBPath = DBPath;
if (!File.Exists(DBPath))
{
@@ -177,7 +177,7 @@ public class ManifestDB
callback?.Invoke($"Checking master.mdb");
SqliteCommand command = new SqliteCommand("SELECT h FROM a WHERE n LIKE 'master.mdb.lz4'", MetaDB);
var reader = command.ExecuteReader();
if (reader.Read())
{
var hash = reader.GetString(0);
@@ -199,9 +199,17 @@ public class ManifestDB
}
callback?.Invoke($"Decompress master.mdb");
var masterPath = $"{Path.GetDirectoryName(DBPath)}/master/master.mdb";
var masterPath = $"{Path.GetDirectoryName(DBPath)}/master/master_umaviewer.mdb";
Directory.CreateDirectory(Path.GetDirectoryName(masterPath));
File.WriteAllBytes(masterPath, LZ4Util.DecompressFromFile(path));
try
{
File.WriteAllBytes(masterPath, LZ4Util.DecompressFromFile(path));
}
catch
{
callback?.Invoke($"Decompress master.mdb error");
yield break;
}
}
}
@@ -230,28 +238,25 @@ public class ManifestDB
ulong count = reader.GetRowCount();
ManifestEntry[] manifests = new ManifestEntry[count];
if (kind == Kind.Default)
for (ulong i = 0; i < count; i++)
{
for (ulong i = 0; i < count; i++)
manifests[i].kind = (int)kind;
if (kind == Kind.Default)
{
manifests[i].kind = (int)kind;
if (!reader.ReadLine(ManifestEntry.GetBsvParser(ManifestEntry.Format.Full, reader), ref manifests[i]))
{
Debug.LogError("ReadLineError");
return null;
}
}
}
else
{
for (ulong i = 0; i < count; i++)
else
{
manifests[i].kind = (int)kind;
if (!reader.ReadLine(ManifestEntry.GetBsvParser(ManifestEntry.Format.Simplified, reader), ref manifests[i]))
{
Debug.LogError("ReadLineError");
return null;
}
}
}
return manifests;
@@ -284,6 +289,8 @@ public class ManifestDB
else
{
Debug.LogError("Download Manifest Failed :" + www.error);
callback?.Invoke($"Download Manifest Failed :{www.error},Update aborted");
yield break;
}
}
@@ -320,6 +327,6 @@ public class ManifestDB
}
return platformEntrys[0];
}
}
+31
View File
@@ -0,0 +1,31 @@
using UnityEngine;
using UnityEngine.UI;
public class LiveCharacterSelect : MonoBehaviour
{
public CharaEntry CharaEntry;
public string CostumeId;
public Image CharaImage;
public Image BackGroundImage;
public Image CostumeImage;
public Text IndexText;
public void SelectChara(UmaViewerUI ui)
{
if (!ui) return;
ui.CurrentSeletChara = this;
if (!ui.SelectCharacterPannel.activeInHierarchy)
ui.ToggleUIPanel(ui.SelectCharacterPannel);
}
public void SetValue(CharaEntry charaentry, string costumeId, Sprite costumeSprite)
{
CharaEntry = charaentry;
CostumeId = costumeId;
CharaImage.sprite = charaentry.Icon;
BackGroundImage.enabled = true;
BackGroundImage.sprite = charaentry.Icon;
CostumeImage.sprite = costumeSprite;
}
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: eaa5ee5165a2a114dad6e67c9e6d9ce4
guid: c73dbc71d1114ee4d9faf37a28216671
MonoImporter:
externalObjects: {}
serializedVersion: 2
+40 -4
View File
@@ -12,6 +12,7 @@ public class UmaContainer : MonoBehaviour
public GameObject Body;
public GameObject Tail;
public GameObject Head;
public GameObject Hair;
public List<Texture2D> TailTextures = new List<Texture2D>();
@@ -30,6 +31,7 @@ public class UmaContainer : MonoBehaviour
[Header("Face")]
public FaceDrivenKeyTarget FaceDrivenKeyTarget;
public FaceEmotionKeyTarget FaceEmotionKeyTarget;
public FaceOverrideData FaceOverrideData;
public GameObject HeadBone;
public GameObject TrackTarget;
public float EyeHeight;
@@ -59,11 +61,21 @@ public class UmaContainer : MonoBehaviour
public bool IsMini = false;
public List<Texture2D> MiniHeadTextures = new List<Texture2D>();
[Header("Mob")]
public bool IsMob = false;
public DataRow MobDressColor;
public DataRow MobHeadColor;
public List<Texture2D> MobHeadTextures = new List<Texture2D>();
[Header("Physics")]
public bool EnablePhysics = true;
public List<CySpringDataContainer> cySpringDataContainers;
public GameObject PhysicsContainer;
public float BodyScale = 1;
[Header("Other")]
public CharaShaderEffectData ShaderEffectData;
public void Initialize()
{
TrackTarget = Camera.main.gameObject;
@@ -132,15 +144,40 @@ public class UmaContainer : MonoBehaviour
UmaAnimator.runtimeAnimatorController = OverrideController;
}
public void MergeHairModel()
{
if (!Head || !Hair) return;
List<Transform> bodybones = new List<Transform>(Head.GetComponentsInChildren<Transform>());
List<Transform> emptyBones = new List<Transform>();
var headHolder = Head.GetComponent<AssetHolder>();
var hairHolder = Hair.GetComponent<AssetHolder>();
headHolder._assetTable.list.AddRange(hairHolder._assetTable.list);
headHolder._assetTableValue.list.AddRange(hairHolder._assetTableValue.list);
//MergeHair
var hairskins = Hair.GetComponentsInChildren<SkinnedMeshRenderer>();
foreach (SkinnedMeshRenderer hairskin in hairskins)
{
hairskin.gameObject.transform.SetParent(Head.transform);
emptyBones.AddRange(MergeBone(hairskin, bodybones));
}
Hair.gameObject.SetActive(false);
emptyBones.ForEach(a => { if (a) Destroy(a.gameObject); });
}
public void SetHeight(int scale = 0)
{
if(scale == 0)
if (scale == 0)
{
BodyScale = 1;
}
else if(scale == -1)
else if (scale == -1)
{
BodyScale = (Convert.ToInt32(CharaData["scale"]) / 160f);
BodyScale = (Convert.ToInt32(CharaData[IsMob ? "chara_height" : "scale"]) / 160f);
}
else
{
@@ -249,7 +286,6 @@ public class UmaContainer : MonoBehaviour
}
}
public void SetNextAnimationCut(string cutName)
{
var asset = UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.Equals(cutName));
+30 -3
View File
@@ -1,8 +1,8 @@
using RootMotion.Dynamics;
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Gallop;
using System.IO;
public class UmaDatabaseEntry
{
@@ -11,7 +11,29 @@ public class UmaDatabaseEntry
public string Url;
public string Checksum;
public string Prerequisites;
public string FilePath => $"{Config.Instance.MainPath}\\dat\\{Url.Substring(0, 2)}\\{Url}";
public string FilePath
{
get
{
var path = $"{Config.Instance.MainPath}\\dat\\{Url.Substring(0, 2)}\\{Url}";
if (!File.Exists(path) && Config.Instance.WorkMode == WorkMode.Standalone)
{
DownloadAsset(this);
}
return path;
}
}
//TODO Make it async
public static void DownloadAsset(UmaDatabaseEntry entry)
{
var path = $"{Config.Instance.MainPath}\\dat\\{entry.Url.Substring(0, 2)}\\{entry.Url}";
UmaViewerDownload.DownloadAssetSync(entry, path , delegate(string msg)
{
UmaViewerUI.Instance.ShowMessage(msg);
});
}
}
public class UmaCharaData
@@ -25,6 +47,7 @@ public class UmaHeadData
public int id;
public string costumeId;
public int tailId;
public CharaEntry chara;
}
public class UmaLyricsData
@@ -72,6 +95,7 @@ public class CharaEntry
public Sprite Icon;
public int Id;
public string ThemeColor;
public bool IsMob;
}
[System.Serializable]
@@ -79,6 +103,8 @@ public class LiveEntry
{
public int MusicId;
public string SongName;
public int MemberCount;
public int DefaultDress;
public string BackGroundId;
public Sprite Icon;
public List<string[]> LiveSettings = new List<string[]>();
@@ -100,6 +126,7 @@ public class CostumeEntry
{
public string Id;
public int CharaId;
public string DressName;
public int BodyType;
public int BodyTypeSub;
public Sprite Icon;
@@ -44,6 +44,7 @@ public class UmaDatabaseController
public IEnumerable<UmaDatabaseEntry> MetaEntries;
public IEnumerable<DataRow> CharaData;
public IEnumerable<DataRow> MobCharaData;
public IEnumerable<FaceTypeData> FaceTypeData;
public IEnumerable<DataRow> LiveData;
public IEnumerable<DataRow> DressData;
@@ -57,24 +58,41 @@ public class UmaDatabaseController
{
try
{
metaDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\meta;");
masterDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\master\master.mdb;");
if(Config.Instance.WorkMode == WorkMode.Standalone)
{
metaDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\meta_umaviewer;");
masterDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\master\master_umaviewer.mdb;");
}
else
{
metaDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\meta;");
masterDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\master\master.mdb;");
}
metaDb.Open();
MetaEntries = ReadMeta(metaDb);
masterDb.Open();
CharaData = ReadMaster(masterDb);
CharaData = ReadCharaMaster(masterDb);
MobCharaData = ReadMobCharaMaster(masterDb);
FaceTypeData = ReadFaceTypeData(masterDb);
LiveData = ReadAllLiveData(masterDb);
DressData = ReadAllDressData(masterDb);
}
catch
catch
{
UmaViewerUI.Instance.LyricsText.text = $"Database not found: \n{Config.Instance.MainPath}\\meta\n{Config.Instance.MainPath}\\master\\master.mdb";
UmaViewerUI.Instance.LyricsText.color = Color.red;
masterDb.Close();
metaDb.Close();
CloseAllConnection();
var msg = $"Database not found at: {Config.Instance.MainPath}";
if(Config.Instance.WorkMode == WorkMode.Standalone)
{
msg += "\nPlease update the database in the settings panel";
}
else
{
msg += "\nPlease install the dmm game client";
}
UmaViewerUI.Instance.ShowMessage(msg);
}
}
@@ -103,10 +121,21 @@ public class UmaDatabaseController
return entries;
}
static IEnumerable<DataRow> ReadMaster(SqliteConnection conn)
static IEnumerable<DataRow> ReadCharaMaster(SqliteConnection conn)
{
return ReadMaster(conn, "SELECT * FROM chara_data C,(SELECT D.'index' charaid,D.'text' charaname FROM text_data D WHERE id like 6) T WHERE C.id like T.charaid");
}
static IEnumerable<DataRow> ReadMobCharaMaster(SqliteConnection conn)
{
return ReadMaster(conn, "SELECT * FROM mob_data");
}
static IEnumerable<DataRow> ReadMaster(SqliteConnection conn,string sql)
{
SqliteCommand sqlite_cmd = conn.CreateCommand();
sqlite_cmd.CommandText = "SELECT * FROM chara_data C,(SELECT D.'index' charaid,D.'text' charaname FROM text_data D WHERE id like 6) T WHERE C.id like T.charaid";
sqlite_cmd.CommandText = sql;
SqliteDataReader sqlite_datareader = sqlite_cmd.ExecuteReader();
var result = new DataTable();
result.Load(sqlite_datareader);
@@ -142,43 +171,45 @@ public class UmaDatabaseController
static IEnumerable<DataRow> ReadAllLiveData(SqliteConnection conn)
{
SqliteCommand sqlite_cmd = conn.CreateCommand();
sqlite_cmd.CommandText =
$"SELECT * FROM live_data L,(SELECT D.'index' songid,D.'text' songname FROM text_data D WHERE id like 16) T WHERE L.music_id like T.songid";
SqliteDataReader sqlite_datareader = sqlite_cmd.ExecuteReader();
var result = new DataTable();
result.Load(sqlite_datareader);
var temp = result.Rows.GetEnumerator();
while (temp.MoveNext())
{
yield return (DataRow)temp.Current;
}
return ReadMaster(conn, $"SELECT * FROM live_data L,(SELECT D.'index' songid,D.'text' songname FROM text_data D WHERE id like 16) T WHERE L.music_id like T.songid");
}
static IEnumerable<DataRow> ReadAllDressData(SqliteConnection conn)
{
SqliteCommand sqlite_cmd = conn.CreateCommand();
sqlite_cmd.CommandText =
$"SELECT * FROM dress_data";
SqliteDataReader sqlite_datareader = sqlite_cmd.ExecuteReader();
var result = new DataTable();
result.Load(sqlite_datareader);
var temp = result.Rows.GetEnumerator();
while (temp.MoveNext())
{
yield return (DataRow)temp.Current;
}
return ReadMaster(conn, $"SELECT * FROM dress_data C,(SELECT D.'index' dressid,D.'text' dressname FROM text_data D WHERE id like 14) T WHERE C.id like T.dressid");
}
public static DataRow ReadCharaData(int id)
public static DataRow ReadCharaData(CharaEntry chara)
{
SqliteCommand sqlite_cmd = instance.masterDb.CreateCommand();
sqlite_cmd.CommandText = $"SELECT * FROM chara_data WHERE id LIKE {id}";
SqliteDataReader sqlite_datareader = sqlite_cmd.ExecuteReader();
var result = new DataTable();
result.Load(sqlite_datareader);
DataRow row = result.Rows[0];
return row;
foreach (var charaentry in chara.IsMob ? instance.MobCharaData : instance.CharaData)
{
if (Convert.ToInt32(charaentry[chara.IsMob ? "mob_id" : "id"]) == chara.Id)
{
return charaentry;
}
}
return null;
}
public static DataRow ReadMobDressColor(string mobid)
{
var results= ReadMaster(instance.masterDb, $"SELECT * FROM mob_dress_color_set WHERE id LIKE {mobid}");
foreach(var data in results)
{
return data;
}
return null;
}
public static DataRow ReadMobHairColor(string colorid)
{
var results= ReadMaster(instance.masterDb, $"SELECT * FROM mob_hair_color_set WHERE id LIKE {colorid}");
foreach(var data in results)
{
return data;
}
return null;
}
public void CloseAllConnection()
@@ -186,4 +217,5 @@ public class UmaDatabaseController
masterDb.Close();
metaDb.Close();
}
}
+589 -47
View File
@@ -10,6 +10,7 @@ using System.IO;
using System.Linq;
using UmaMusumeAudio;
using UnityEngine;
using Random = UnityEngine.Random;
public class UmaViewerBuilder : MonoBehaviour
{
@@ -50,37 +51,51 @@ public class UmaViewerBuilder : MonoBehaviour
Instance = this;
}
public IEnumerator LoadUma(int id, string costumeId, bool mini)
public IEnumerator LoadUma(CharaEntry chara, string costumeId, bool mini)
{
UnloadUma();
int id = chara.Id;
CurrentUMAContainer = new GameObject($"Chara_{id}_{costumeId}").AddComponent<UmaContainer>();
UnloadAllBundle();
CurrentUMAContainer.CharaData = UmaDatabaseController.ReadCharaData(id);
if (mini)
{
LoadMiniUma(id, costumeId);
CurrentUMAContainer.CharaData = UmaDatabaseController.ReadCharaData(chara);
LoadMiniUma(chara, costumeId);
}
else if (chara.IsMob)
{
CurrentUMAContainer.CharaData = UmaDatabaseController.ReadCharaData(chara);
LoadMobUma(chara, costumeId);
}
else if (UI.isHeadFix && CurrentHead != null && CurrentHead.chara.IsMob)
{
CurrentUMAContainer.CharaData = UmaDatabaseController.ReadCharaData(CurrentHead.chara);
LoadMobUma(CurrentHead.chara, costumeId, chara.Id);
}
else
{
LoadNormalUma(id, costumeId);
CurrentUMAContainer.CharaData = UmaDatabaseController.ReadCharaData(chara);
LoadNormalUma(chara, costumeId);
}
yield break;
}
private void LoadNormalUma(int id, string costumeId)
private void LoadNormalUma(CharaEntry chara, string costumeId)
{
int id = chara.Id;
DataRow charaData = CurrentUMAContainer.CharaData;
bool genericCostume = CurrentUMAContainer.IsGeneric = costumeId.Length >= 4;
string skin = charaData["skin"].ToString(),
height = charaData["height"].ToString(),
socks = charaData["socks"].ToString(),
bust = charaData["bust"].ToString(),
sex = charaData["sex"].ToString(),
shape = charaData["shape"].ToString(),
costumeIdShort = "";
string skin, height, socks, bust, sex, shape, costumeIdShort = "";
skin = charaData["skin"].ToString();
height = charaData["height"].ToString();
socks = charaData["socks"].ToString();
bust = charaData["bust"].ToString();
sex = charaData["sex"].ToString();
shape = charaData["shape"].ToString();
UmaDatabaseEntry asset = null;
if (genericCostume)
@@ -155,11 +170,20 @@ public class UmaViewerBuilder : MonoBehaviour
//Load Body
RecursiveLoadAsset(asset);
bool physicsloaded = false, physicsloaded2 = false;
//Load Physics
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith(UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/clothes")))
{
if (asset1.Name.Contains("cloth00") && asset1.Name.Contains("bust" + bust))
if (asset1.Name.Contains("cloth00") && asset1.Name.Contains("bust" + bust) && !physicsloaded)
{
RecursiveLoadAsset(asset1);
physicsloaded = true;
}
else if (asset1.Name.Contains("cloth00") && !asset1.Name.Contains("bust") && !physicsloaded2)
{
RecursiveLoadAsset(asset1);
physicsloaded2 = true;
}
}
}
else
@@ -174,15 +198,11 @@ public class UmaViewerBuilder : MonoBehaviour
}
}
// Record Head Data
int head_id;
string head_costumeId;
int tailId = Convert.ToInt32(charaData["tail_model_id"]);
//The tailId of 9006 is 1, but the character has no tail
if (id == 9006) tailId = -1;
if (UI.isHeadFix && CurrentHead != null)
{
head_id = CurrentHead.id;
@@ -198,7 +218,8 @@ public class UmaViewerBuilder : MonoBehaviour
{
id = id,
costumeId = costumeId,
tailId = tailId
tailId = tailId,
chara = chara
};
}
@@ -326,9 +347,11 @@ public class UmaViewerBuilder : MonoBehaviour
var firsehead = CurrentUMAContainer.Head;
var faceDriven = firsehead.GetComponent<AssetHolder>()._assetTable["facial_target"] as FaceDrivenKeyTarget;
var earDriven = firsehead.GetComponent<AssetHolder>()._assetTable["ear_target"] as DrivenKeyTarget;
var faceOverride = firsehead.GetComponent<AssetHolder>()._assetTable["face_override"] as FaceOverrideData;
faceDriven._earTarget = earDriven._targetFaces;
CurrentUMAContainer.FaceDrivenKeyTarget = faceDriven;
CurrentUMAContainer.FaceDrivenKeyTarget.Container = CurrentUMAContainer;
CurrentUMAContainer.FaceOverrideData = faceOverride;
faceDriven.DrivenKeyLocator = locator.transform;
faceDriven.Initialize(firsehead.GetComponentsInChildren<Transform>().ToList());
@@ -349,8 +372,297 @@ public class UmaViewerBuilder : MonoBehaviour
LoadAsset(UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"anm_eve_chr{id}_00_idle01_loop")));
}
private void LoadMiniUma(int id, string costumeId)
private void LoadMobUma(CharaEntry chara, string costumeId, int bodyid = -1)
{
int id = chara.Id;
CurrentUMAContainer.IsMob = chara.IsMob;
CurrentUMAContainer.MobDressColor = UmaDatabaseController.ReadMobDressColor(CurrentUMAContainer.CharaData["dress_color_id"].ToString());
CurrentUMAContainer.MobHeadColor = UmaDatabaseController.ReadMobHairColor(CurrentUMAContainer.CharaData["chara_hair_color"].ToString());
DataRow charaData = CurrentUMAContainer.CharaData;
bool genericCostume = CurrentUMAContainer.IsGeneric = costumeId.Length >= 4;
string skin, height, socks, bust, sex, shape, costumeIdShort = "";
string faceid, hairid, personality;
faceid = charaData["chara_face_model"].ToString();
hairid = charaData["chara_hair_model"].ToString();
personality = charaData["default_personality"].ToString();
skin = charaData["chara_skin_color"].ToString();
height = "0";
socks = charaData["socks"].ToString();
bust = charaData["chara_bust_size"].ToString();
sex = charaData["sex"].ToString();
shape = "0";
UmaDatabaseEntry asset = null;
if (genericCostume)
{
costumeIdShort = costumeId.Remove(costumeId.LastIndexOf('_'));
CurrentUMAContainer.VarCostumeIdShort = costumeIdShort;
CurrentUMAContainer.VarCostumeIdLong = costumeId;
CurrentUMAContainer.VarBust = bust;
CurrentUMAContainer.VarSkin = skin;
CurrentUMAContainer.VarSocks = socks;
CurrentUMAContainer.VarHeight = height;
// Pattern for generic body type is as follows:
//
// (costume id)_(body_type_sub)_(body_setting)_(height)_(shape)_(bust)
//
// body_type_sub is used for variants like the summer/winter uniform or the swimsuit/towel
// body_setting is used for subvariants of each variant like the big belly version of the uniform, and the genders for the tracksuits
//
// Some models will naturally be missing due to how this system is designed.
string body = "";
body = UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/pfb_bdy{costumeId}_{height}_{shape}_{bust}";
Debug.Log("Looking for " + body);
asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == body);
}
else asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == UmaDatabaseController.BodyPath + $"bdy{bodyid}_{costumeId}/pfb_bdy{bodyid}_{costumeId}");
if (asset == null)
{
Debug.LogError("No body, can't load!");
return;
}
else if (genericCostume)
{
string texPattern1 = "", texPattern2 = "", texPattern3 = "", texPattern4 = "", texPattern5 = "";
switch (costumeId.Split('_')[0])
{
case "0001":
texPattern1 = $"tex_bdy{costumeIdShort}_00_{skin}_{bust}_0{socks}";
texPattern2 = $"tex_bdy{costumeIdShort}_00_0_{bust}";
texPattern3 = $"tex_bdy{costumeIdShort}_zekken";
texPattern4 = $"tex_bdy{costumeIdShort}_00_waku";
texPattern5 = $"tex_bdy{costumeIdShort}_num";
break;
case "0003":
texPattern1 = $"tex_bdy{costumeIdShort}_00_{skin}_{bust}";
texPattern2 = $"tex_bdy{costumeIdShort}_00_0_{bust}";
break;
case "0006": //last var is color?
texPattern1 = $"tex_bdy{costumeId}_{skin}_{bust}_0{0}";
texPattern2 = $"tex_bdy{costumeId}_0_{bust}_00_";
break;
default:
texPattern1 = $"tex_bdy{costumeId}_{skin}_{bust}";
texPattern2 = $"tex_bdy{costumeId}_0_{bust}";
break;
}
Debug.Log(texPattern1 + " " + texPattern2);
//Load Body Textures
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith(UmaDatabaseController.BodyPath)
&& (a.Name.Contains(texPattern1)
|| a.Name.Contains(texPattern2)
|| (string.IsNullOrEmpty(texPattern3) ? false : a.Name.Contains(texPattern3))
|| (string.IsNullOrEmpty(texPattern4) ? false : a.Name.Contains(texPattern4))
|| (string.IsNullOrEmpty(texPattern5) ? false : a.Name.Contains(texPattern5)))))
{
RecursiveLoadAsset(asset1);
}
//Load Body
RecursiveLoadAsset(asset);
bool physicsloaded = false, physicsloaded2 = false;
//Load Physics
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith(UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/clothes")))
{
if (asset1.Name.Contains("cloth00") && asset1.Name.Contains("bust" + bust) && !physicsloaded)
{
RecursiveLoadAsset(asset1);
physicsloaded = true;
}
else if (asset1.Name.Contains("cloth00") && !asset1.Name.Contains("bust") && !physicsloaded2)
{
RecursiveLoadAsset(asset1);
physicsloaded2 = true;
}
}
}
else
{
RecursiveLoadAsset(asset);
//Load Physics
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith(UmaDatabaseController.BodyPath + $"bdy{bodyid}_{costumeId}/clothes")))
{
if (asset1.Name.Contains("cloth00"))
RecursiveLoadAsset(asset1);
}
}
// Record Head Data
int head_id = 1;
string head_costumeId = "00";
int tailId = 1;
CurrentHead = new UmaHeadData
{
id = id,
costumeId = costumeId,
tailId = tailId,
chara = chara
};
var head_s = head_id.ToString().PadLeft(4, '0');
string head = UmaDatabaseController.HeadPath + $"chr{head_s}_{head_costumeId}/pfb_chr{head_s}_{head_costumeId}_face{faceid.PadLeft(3, '0')}";
string hair = UmaDatabaseController.HeadPath + $"chr{head_s}_{head_costumeId}/pfb_chr{head_s}_{head_costumeId}_hair{hairid.PadLeft(3, '0')}";
asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == head);
var hairasset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == hair);
bool isDefaultHead = true;
if (asset != null && hairasset != null)
{
//Load Face And Hair Textures
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith($"{UmaDatabaseController.HeadPath}chr{head_s}_{head_costumeId}/textures")))
{
if (asset1.Name.Contains($"tex_chr{head_s}_{head_costumeId}_face{faceid.PadLeft(3, '0')}_0")
|| asset1.Name.Contains($"tex_chr{head_s}_{head_costumeId}_face{faceid.PadLeft(3, '0')}_{skin}"))
{
RecursiveLoadAsset(asset1);
}
if (asset1.Name.Contains($"tex_chr{head_s}_{head_costumeId}_hair{hairid.PadLeft(3, '0')}"))
{
RecursiveLoadAsset(asset1);
}
}
//Load face
RecursiveLoadAsset(asset);
//Load hair
RecursiveLoadAsset(hairasset);
CurrentUMAContainer.MergeHairModel();
//Load Physics
if (isDefaultHead)
{
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith($"{UmaDatabaseController.HeadPath}chr{head_s}_00/clothes")))
{
if (asset1.Name.Contains($"hair{hairid.PadLeft(3, '0')}_cloth00"))
RecursiveLoadAsset(asset1);
}
}
}
if (tailId != 0)
{
string tailName = $"tail{tailId.ToString().PadLeft(4, '0')}_00";
string tailPath = $"3d/chara/tail/{tailName}/";
string tailPfb = tailPath + $"pfb_{tailName}";
asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == tailPfb);
if (asset != null)
{
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith($"{tailPath}textures/tex_{tailName}_{head_s}") || a.Name.StartsWith($"{tailPath}textures/tex_{tailName}_0000")))
{
RecursiveLoadAsset(asset1);
}
RecursiveLoadAsset(asset);
//Load Physics
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith($"{tailPath}clothes")))
{
if (asset1.Name.Contains("cloth00"))
RecursiveLoadAsset(asset1);
}
}
else
{
Debug.Log("no tail");
}
}
CurrentUMAContainer.LoadPhysics(); //Need to load physics before loading FacialMorph
//Load FacialMorph
if (CurrentUMAContainer.Head)
{
var locatorEntry = Main.AbList.FirstOrDefault(a => a.Name.EndsWith("3d/animator/drivenkeylocator"));
var bundle = AssetBundle.LoadFromFile(locatorEntry.FilePath);
Main.LoadedBundles.Add(locatorEntry.Name, bundle);
var locator = Instantiate(bundle.LoadAsset("DrivenKeyLocator"), CurrentUMAContainer.transform) as GameObject;
locator.name = "DrivenKeyLocator";
var headBone = (GameObject)CurrentUMAContainer.Head.GetComponent<AssetHolder>()._assetTable["head"];
var eyeLocator_L = headBone.transform.Find("Eye_target_locator_L");
var eyeLocator_R = headBone.transform.Find("Eye_target_locator_R");
var mangaEntry = Main.AbEffect.FindAll(a => a.Name.StartsWith("3d/effect/charaemotion/pfb_eff_chr_emo_eye"));
var mangaObjects = new List<GameObject>();
mangaEntry.ForEach(entry =>
{
AssetBundle ab = AssetBundle.LoadFromFile(entry.FilePath);
Main.LoadedBundles.Add(entry.Name, ab);
var obj = ab.LoadAsset(Path.GetFileNameWithoutExtension(entry.Name)) as GameObject;
obj.SetActive(false);
var leftObj = Instantiate(obj, eyeLocator_L.transform);
new List<Renderer>(leftObj.GetComponentsInChildren<Renderer>()).ForEach(a => a.material.renderQueue = -1);
CurrentUMAContainer.LeftMangaObject.Add(leftObj);
var RightObj = Instantiate(obj, eyeLocator_R.transform);
if (RightObj.TryGetComponent<AssetHolder>(out var holder))
{
if (holder._assetTableValue["invert"] > 0)
RightObj.transform.localScale = new Vector3(-1, 1, 1);
}
new List<Renderer>(RightObj.GetComponentsInChildren<Renderer>()).ForEach(a => { a.material.renderQueue = -1; });
CurrentUMAContainer.RightMangaObject.Add(RightObj);
});
var tearEntry = Main.AbChara.FindAll(a => a.Name.StartsWith("3d/chara/common/tear/") && a.Name.Contains("pfb_chr_tear"));
if (tearEntry.Count > 0)
{
tearEntry.ForEach(a => RecursiveLoadAsset(a));
}
if (CurrentUMAContainer.TearPrefab_0 && CurrentUMAContainer.TearPrefab_1)
{
var p0 = CurrentUMAContainer.TearPrefab_0;
var p1 = CurrentUMAContainer.TearPrefab_1;
var t = headBone.transform;
CurrentUMAContainer.TearControllers.Add(new TearController(t, Instantiate(p0, t), Instantiate(p1, t), 0, 1));
CurrentUMAContainer.TearControllers.Add(new TearController(t, Instantiate(p0, t), Instantiate(p1, t), 1, 1));
CurrentUMAContainer.TearControllers.Add(new TearController(t, Instantiate(p0, t), Instantiate(p1, t), 0, 0));
CurrentUMAContainer.TearControllers.Add(new TearController(t, Instantiate(p0, t), Instantiate(p1, t), 1, 0));
}
var firsehead = CurrentUMAContainer.Head;
var faceDriven = firsehead.GetComponent<AssetHolder>()._assetTable["facial_target"] as FaceDrivenKeyTarget;
var earDriven = firsehead.GetComponent<AssetHolder>()._assetTable["ear_target"] as DrivenKeyTarget;
var faceOverride = firsehead.GetComponent<AssetHolder>()._assetTable["face_override"] as FaceOverrideData;
faceDriven._earTarget = earDriven._targetFaces;
CurrentUMAContainer.FaceDrivenKeyTarget = faceDriven;
CurrentUMAContainer.FaceDrivenKeyTarget.Container = CurrentUMAContainer;
CurrentUMAContainer.FaceOverrideData = faceOverride;
faceDriven.DrivenKeyLocator = locator.transform;
faceDriven.Initialize(firsehead.GetComponentsInChildren<Transform>().ToList());
var emotionDriven = ScriptableObject.CreateInstance<FaceEmotionKeyTarget>();
emotionDriven.name = $"char{id}_{costumeId}_emotion_target";
CurrentUMAContainer.FaceEmotionKeyTarget = emotionDriven;
emotionDriven.FaceDrivenKeyTarget = faceDriven;
emotionDriven.FaceEmotionKey = UmaDatabaseController.Instance.FaceTypeData.ToList();
emotionDriven.Initialize();
}
CurrentUMAContainer.TearControllers.ForEach(a => a.SetDir(a.CurrentDir));
CurrentUMAContainer.HeadBone = (GameObject)CurrentUMAContainer.Body.GetComponent<AssetHolder>()._assetTable["head"];
CurrentUMAContainer.EyeHeight = CurrentUMAContainer.Head.GetComponent<AssetHolder>()._assetTableValue["head_center_offset_y"];
CurrentUMAContainer.MergeModel();
CurrentUMAContainer.Initialize();
CurrentUMAContainer.SetHeight(-1);
LoadAsset(UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"homestand{personality.PadLeft(2,'0')}_loop")));
}
private void LoadMiniUma(CharaEntry chara, string costumeId)
{
int id = chara.Id;
DataRow charaData = CurrentUMAContainer.CharaData;
CurrentUMAContainer.IsMini = true;
bool isGeneric = CurrentUMAContainer.IsGeneric = costumeId.Length >= 4;
@@ -459,17 +771,16 @@ public class UmaViewerBuilder : MonoBehaviour
RecursiveLoadAsset(entry);
}
public void LoadLive(LiveEntry live)
public void LoadLive(LiveEntry live, List<LiveCharacterSelect> characters)
{
var asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name.EndsWith("cutt_son" + live.MusicId));
var BGasset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name.EndsWith($"pfb_env_live{live.BackGroundId}_controller000"));
if (asset == null || BGasset == null) return;
UnloadLive();
UnloadAllBundle();
CurrentLiveContainer = new GameObject(Path.GetFileName(asset.Name)).AddComponent<UmaContainer>();
RecursiveLoadAsset(asset);
RecursiveLoadAsset(BGasset);
characters.ForEach(a =>
{
if (a.CharaEntry == null || a.CostumeId == "")
{
a.CharaEntry = Main.Characters[Random.Range(0, Main.Characters.Count)];
a.CostumeId = "00";
}
});//fill empty
}
//Use CriWare Library
@@ -544,7 +855,7 @@ public class UmaViewerBuilder : MonoBehaviour
Destroy(tmp.gameObject);
UI.ResetAudioPlayer();
}
if(subindex == -1)
if (subindex == -1)
{
foreach (AudioClip clip in LoadAudio(SongAwb))
{
@@ -555,7 +866,7 @@ public class UmaViewerBuilder : MonoBehaviour
{
AddAudioSource(LoadAudio(SongAwb)[subindex]);
}
}
private void AddAudioSource(AudioClip clip)
@@ -759,7 +1070,14 @@ public class UmaViewerBuilder : MonoBehaviour
}
else if (bundle.name.Contains("/head/"))
{
LoadHead(go);
if (bundle.name.Contains("_hair")&&!bundle.name.Contains("mchr"))
{
LoadHair(go);
}
else
{
LoadHead(go);
}
}
else if (bundle.name.Contains("/body/"))
{
@@ -799,6 +1117,11 @@ public class UmaViewerBuilder : MonoBehaviour
{
CurrentUMAContainer.GenericBodyTextures.Add(tex2D);
}
else if (bundle.name.Contains("_face")|| bundle.name.Contains("_hair"))
{
if(CurrentUMAContainer.IsMob)
CurrentUMAContainer.MobHeadTextures.Add(tex2D);
}
break;
}
}
@@ -836,15 +1159,38 @@ public class UmaViewerBuilder : MonoBehaviour
if (CurrentUMAContainer.IsMini)
{
m.SetTexture("_MainTex", textures[0]);
}
else
{
//BodyAlapha's shader need to change manually.
if (m.name.Contains("bdy") && m.name.Contains("Alpha"))
if (m.shader.name.Contains("Noline") && m.shader.name.Contains("TSER"))
{
m.shader = bodyAlphaShader;
var s = ShaderList.Find(a => a.name == m.shader.name.Replace("Noline", "")); //Generic costume shader need to change manually.
if (s)
{
m.shader = s;
}
}
//BodyAlapha's shader need to change manually.
if (m.name.Contains("bdy"))
{
if (m.name.Contains("Alpha"))
{
m.shader = bodyAlphaShader;
}
else
{
//some costume use area texture
var areaTex = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name.StartsWith(UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/textures") && a.Name.EndsWith("area"));
if (areaTex != null)
{
RecursiveLoadAsset(areaTex);
m.SetTexture("_MaskColorTex", textures.FirstOrDefault(t => t.name.Contains(costumeIdShort) && t.name.EndsWith("area")));
SetMaskColor(m, CurrentUMAContainer.IsMob ? CurrentUMAContainer.MobDressColor : CurrentUMAContainer.CharaData, CurrentUMAContainer.IsMob);
}
}
}
switch (costumeIdShort.Split('_')[0]) //costume ID
@@ -899,7 +1245,6 @@ public class UmaViewerBuilder : MonoBehaviour
tripleMap = $"tex_bdy{costumeIdLong}_0_{bust}_base";
optionMap = $"tex_bdy{costumeIdLong}_0_{bust}_ctrl";
break;
}
Debug.Log("Looking for texture " + mainTex);
m.SetTexture("_MainTex", textures.FirstOrDefault(t => t.name == mainTex));
@@ -931,6 +1276,8 @@ public class UmaViewerBuilder : MonoBehaviour
private void LoadHead(GameObject go)
{
var isMob = CurrentUMAContainer.IsMob;
var textures = CurrentUMAContainer.MobHeadTextures;
GameObject head = Instantiate(go, CurrentUMAContainer.transform);
CurrentUMAContainer.Head = head;
@@ -971,6 +1318,34 @@ public class UmaViewerBuilder : MonoBehaviour
}
else
{
if (isMob)
{
if (m.name.EndsWith("eye"))
{
m.SetTexture("_MainTex", textures.LastOrDefault(t => t.name.Contains("_eye") && t.name.EndsWith("eye0")));
m.SetTexture("_High0Tex", textures.LastOrDefault(t => t.name.Contains("_eye") && t.name.EndsWith("hi00")));
m.SetTexture("_High1Tex", textures.LastOrDefault(t => t.name.Contains("_eye") && t.name.EndsWith("hi01")));
m.SetTexture("_High2Tex", textures.LastOrDefault(t => t.name.Contains("_eye") && t.name.EndsWith("hi02")));
m.SetTexture("_MaskColorTex", textures.LastOrDefault(t => t.name.Contains("_eye") && t.name.EndsWith("area")));
SetMaskColor(m, CurrentUMAContainer.MobHeadColor, "eye", false);
}
if (m.name.EndsWith("face"))
{
m.SetTexture("_MainTex", textures.LastOrDefault(t => t.name.Contains("_face") && t.name.EndsWith("diff")));
m.SetTexture("_ToonMap", textures.LastOrDefault(t => t.name.Contains("_face") && t.name.EndsWith("shad_c")));
m.SetTexture("_TripleMaskMap", textures.LastOrDefault(t => t.name.Contains("_face") && t.name.EndsWith("base")));
m.SetTexture("_OptionMaskMap", textures.LastOrDefault(t => t.name.Contains("_face") && t.name.EndsWith("ctrl")));
m.SetTexture("_MaskColorTex", textures.LastOrDefault(t => t.name.Contains("_face") && t.name.EndsWith("area")&&! t.name.Contains("_eye")));
SetMaskColor(m, CurrentUMAContainer.MobHeadColor, "mayu", true);
}
if (m.name.EndsWith("mayu"))
{
m.SetTexture("_MainTex", textures.LastOrDefault(t => t.name.Contains("_face") && t.name.EndsWith("diff")));
m.SetTexture("_MaskColorTex", textures.LastOrDefault(t => t.name.Contains("_face") && t.name.EndsWith("area") && !t.name.Contains("_eye")));
SetMaskColor(m, CurrentUMAContainer.MobHeadColor, "mayu", true);
}
}
//Glasses's shader need to change manually.
if (r.name.Contains("Hair") && r.name.Contains("Alpha"))
{
@@ -980,10 +1355,17 @@ public class UmaViewerBuilder : MonoBehaviour
//Blush Setting
if (r.name.Contains("Cheek"))
{
var table = CurrentUMAContainer.Head.GetComponent<AssetHolder>()._assetTable.list;
CurrentUMAContainer.CheekTex_0 = table.FindLast(a => a.Key.Equals("cheek0")).Value as Texture;
CurrentUMAContainer.CheekTex_1 = table.FindLast(a => a.Key.Equals("cheek1")).Value as Texture;
CurrentUMAContainer.CheekTex_2 = table.FindLast(a => a.Key.Equals("cheek2")).Value as Texture;
if (isMob)
{
CurrentUMAContainer.CheekTex_0 = CurrentUMAContainer.MobHeadTextures.FindLast(a=>a.name.Contains("cheek0"));
CurrentUMAContainer.CheekTex_1 = CurrentUMAContainer.MobHeadTextures.FindLast(a => a.name.Contains("cheek1"));
}
else
{
var table = CurrentUMAContainer.Head.GetComponent<AssetHolder>()._assetTable;
CurrentUMAContainer.CheekTex_0 = table["cheek0"] as Texture;
CurrentUMAContainer.CheekTex_1 = table["cheek1"] as Texture;
}
}
switch (m.shader.name)
{
@@ -1015,10 +1397,57 @@ public class UmaViewerBuilder : MonoBehaviour
}
}
//foreach (var anim in Main.AbList.Where(a => a.Name.StartsWith("3d/chara/head/chr0001_00/facial/")))
//{
// RecursiveLoadAsset(anim);
//}
//shader effect
var assetholder = head.GetComponent<AssetHolder>();
if (assetholder)
{
CurrentUMAContainer.ShaderEffectData = assetholder._assetTable["chara_shader_effect"] as CharaShaderEffectData;
if (CurrentUMAContainer.ShaderEffectData)
{
CurrentUMAContainer.ShaderEffectData.Initialize();
}
}
}
private void LoadHair(GameObject go)
{
GameObject hair = Instantiate(go, CurrentUMAContainer.transform);
CurrentUMAContainer.Hair = hair;
var textures = CurrentUMAContainer.MobHeadTextures;
foreach (Renderer r in hair.GetComponentsInChildren<Renderer>())
{
foreach (Material m in r.sharedMaterials)
{
//Glasses's shader need to change manually.
if (r.name.Contains("Hair") && r.name.Contains("Alpha"))
{
m.shader = alphaShader;
}
if(m.name.EndsWith("_hair"))
{
m.SetTexture("_MainTex", textures.FirstOrDefault(t => t.name.Contains("_hair") && t.name.EndsWith("diff")));
m.SetTexture("_ToonMap", textures.FirstOrDefault(t => t.name.Contains("_hair") && t.name.EndsWith("shad_c")));
m.SetTexture("_TripleMaskMap", textures.FirstOrDefault(t => t.name.Contains("_hair") && t.name.EndsWith("base")));
m.SetTexture("_OptionMaskMap", textures.FirstOrDefault(t => t.name.Contains("_hair") && t.name.EndsWith("ctrl")));
m.SetTexture("_MaskColorTex", textures.FirstOrDefault(t => t.name.Contains("_hair") && t.name.EndsWith("area")));
SetMaskColor(m, CurrentUMAContainer.MobHeadColor, "hair", true);
}
switch (m.shader.name)
{
case "Gallop/3D/Chara/ToonHair/TSER":
m.shader = hairShader;
m.SetFloat("_CylinderBlend", 0.25f);
break;
default:
Debug.Log(m.shader.name);
// m.shader = Shader.Find("Nars/UmaMusume/Body");
break;
}
}
}
}
private void LoadTail(GameObject go)
@@ -1033,6 +1462,10 @@ public class UmaViewerBuilder : MonoBehaviour
m.SetTexture("_ToonMap", textures.FirstOrDefault(t => t.name.Contains("shad")));
m.SetTexture("_TripleMaskMap", textures.FirstOrDefault(t => t.name.Contains("base")));
m.SetTexture("_OptionMaskMap", textures.FirstOrDefault(t => t.name.Contains("ctrl")));
if (CurrentUMAContainer.IsMob)
{
SetMaskColor(m, CurrentUMAContainer.MobHeadColor, "tail", true);
}
}
}
}
@@ -1223,6 +1656,11 @@ public class UmaViewerBuilder : MonoBehaviour
{
RecursiveLoadAsset(facialMotion);
}
var earMotion = Main.AbMotions.FirstOrDefault(a => a.Name.EndsWith(clip.name + "_ear"));
if (earMotion != null)
{
RecursiveLoadAsset(earMotion);
}
CurrentUMAContainer.UmaAnimator.Play("motion_1", 0, lastTime);
CurrentUMAContainer.UmaAnimator.SetTrigger("next");
@@ -1263,7 +1701,8 @@ public class UmaViewerBuilder : MonoBehaviour
foreach (var bundle in Main.LoadedBundles)
{
bundle.Value.Unload(unloadAllObjects);
if (bundle.Value)
bundle.Value.Unload(unloadAllObjects);
}
if (unloadAllObjects)
{
@@ -1294,6 +1733,26 @@ public class UmaViewerBuilder : MonoBehaviour
return null;
}
public Sprite LoadMobCharaIcon(string id)
{
string value = $"mob/mob_chr_icon_{id}_000001_01";
var entry = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name.Equals(value));
if (entry == null) { return null; }
string path = entry.FilePath;
if (File.Exists(path))
{
AssetBundle assetBundle = AssetBundle.LoadFromFile(path);
if (assetBundle.Contains($"mob_chr_icon_{id}_000001_01"))
{
Texture2D texture = (Texture2D)assetBundle.LoadAsset($"mob_chr_icon_{id}_000001_01");
Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
assetBundle.Unload(false);
return sprite;
}
}
return null;
}
public Sprite LoadSprite(UmaDatabaseEntry item)
{
string path = item.FilePath;
@@ -1312,7 +1771,7 @@ public class UmaViewerBuilder : MonoBehaviour
{
string value = $"live/jacket/jacket_icon_l_{musicid}";
var entry = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name.Equals(value));
if(entry == null) return null;
if (entry == null) return null;
string path = entry.FilePath;
if (File.Exists(path))
{
@@ -1378,6 +1837,89 @@ public class UmaViewerBuilder : MonoBehaviour
}
}
private void SetMaskColor(Material mat, DataRow colordata, bool IsMob)
{
mat.EnableKeyword("USE_MASK_COLOR");
Color c1, c2, c3, c4, c5, c6, t1, t2, t3, t4, t5, t6;
if (IsMob)
{
ColorUtility.TryParseHtmlString(colordata["color_r1"].ToString(), out c1);
ColorUtility.TryParseHtmlString(colordata["color_r2"].ToString(), out c2);
ColorUtility.TryParseHtmlString(colordata["color_g1"].ToString(), out c3);
ColorUtility.TryParseHtmlString(colordata["color_g2"].ToString(), out c4);
ColorUtility.TryParseHtmlString(colordata["color_b1"].ToString(), out c5);
ColorUtility.TryParseHtmlString(colordata["color_b2"].ToString(), out c6);
ColorUtility.TryParseHtmlString(colordata["toon_color_r1"].ToString(), out t1);
ColorUtility.TryParseHtmlString(colordata["toon_color_r2"].ToString(), out t2);
ColorUtility.TryParseHtmlString(colordata["toon_color_g1"].ToString(), out t3);
ColorUtility.TryParseHtmlString(colordata["toon_color_g2"].ToString(), out t4);
ColorUtility.TryParseHtmlString(colordata["toon_color_b1"].ToString(), out t5);
ColorUtility.TryParseHtmlString(colordata["toon_color_b2"].ToString(), out t6);
}
else
{
ColorUtility.TryParseHtmlString("#" + colordata["image_color_main"].ToString(), out c1);
ColorUtility.TryParseHtmlString("#" + colordata["image_color_sub"].ToString(), out c2);
ColorUtility.TryParseHtmlString("#" + colordata["ui_color_sub"].ToString(), out c3);
ColorUtility.TryParseHtmlString("#" + colordata["ui_color_sub"].ToString(), out c4);
ColorUtility.TryParseHtmlString("#" + colordata["ui_training_color_1"].ToString(), out c5);
ColorUtility.TryParseHtmlString("#" + colordata["ui_training_color_2"].ToString(), out c6);
float toonstrength = 0.8f;
t1 = c1 * toonstrength;
t2 = c2 * toonstrength;
t3 = c3 * toonstrength;
t4 = c4 * toonstrength;
t5 = c5 * toonstrength;
t6 = c6 * toonstrength;
}
mat.SetColor("_MaskColorR1", c1);
mat.SetColor("_MaskColorR2", c2);
mat.SetColor("_MaskColorG1", c3);
mat.SetColor("_MaskColorG2", c4);
mat.SetColor("_MaskColorB1", c5);
mat.SetColor("_MaskColorB2", c6);
mat.SetColor("_MaskToonColorR1", t1);
mat.SetColor("_MaskToonColorR2", t2);
mat.SetColor("_MaskToonColorG1", t3);
mat.SetColor("_MaskToonColorG2", t4);
mat.SetColor("_MaskToonColorB1", t5);
mat.SetColor("_MaskToonColorB2", t6);
}
private void SetMaskColor(Material mat, DataRow colordata, string prefix,bool hastoon)
{
mat.EnableKeyword("USE_MASK_COLOR");
Color c1, c2, c3, c4, c5, c6, t1, t2, t3, t4, t5, t6;
ColorUtility.TryParseHtmlString(colordata[$"{prefix}_color_r1"].ToString(), out c1);
ColorUtility.TryParseHtmlString(colordata[$"{prefix}_color_r2"].ToString(), out c2);
ColorUtility.TryParseHtmlString(colordata[$"{prefix}_color_g1"].ToString(), out c3);
ColorUtility.TryParseHtmlString(colordata[$"{prefix}_color_g2"].ToString(), out c4);
ColorUtility.TryParseHtmlString(colordata[$"{prefix}_color_b1"].ToString(), out c5);
ColorUtility.TryParseHtmlString(colordata[$"{prefix}_color_b2"].ToString(), out c6);
mat.SetColor("_MaskColorR1", c1);
mat.SetColor("_MaskColorR2", c2);
mat.SetColor("_MaskColorG1", c3);
mat.SetColor("_MaskColorG2", c4);
mat.SetColor("_MaskColorB1", c5);
mat.SetColor("_MaskColorB2", c6);
if (hastoon)
{
ColorUtility.TryParseHtmlString(colordata[$"{prefix}_toon_color_r1"].ToString(), out t1);
ColorUtility.TryParseHtmlString(colordata[$"{prefix}_toon_color_r2"].ToString(), out t2);
ColorUtility.TryParseHtmlString(colordata[$"{prefix}_toon_color_g1"].ToString(), out t3);
ColorUtility.TryParseHtmlString(colordata[$"{prefix}_toon_color_g2"].ToString(), out t4);
ColorUtility.TryParseHtmlString(colordata[$"{prefix}_toon_color_b1"].ToString(), out t5);
ColorUtility.TryParseHtmlString(colordata[$"{prefix}_toon_color_b2"].ToString(), out t6);
mat.SetColor("_MaskToonColorR1", t1);
mat.SetColor("_MaskToonColorR2", t2);
mat.SetColor("_MaskToonColorG1", t3);
mat.SetColor("_MaskToonColorG2", t4);
mat.SetColor("_MaskToonColorB1", t5);
mat.SetColor("_MaskToonColorB2", t6);
}
}
private void FixedUpdate()
{
if (AnimationCamera && AnimationCamera.enabled == true)
+26
View File
@@ -1,5 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
@@ -26,6 +28,30 @@ public class UmaViewerDownload : MonoBehaviour
}
}
public static void DownloadAssetSync(UmaDatabaseEntry entry,string path, Action<string> callback = null)
{
string baseurl = GetAssetRequestUrl(entry.Url);
if (!string.IsNullOrEmpty(Path.GetExtension(entry.Name)))
{
baseurl = GetGenericRequestUrl(entry.Url);
}
using UnityWebRequest www = UnityWebRequest.Get(baseurl);
www.SendWebRequest();
while (!www.isDone) { }
if (www.result != UnityWebRequest.Result.Success)
{
Debug.LogError(www.error);
callback?.Invoke($"Failed to download resources : {www.error}");
}
else
{
Debug.Log("saving " + entry.Url);
Directory.CreateDirectory(Path.GetDirectoryName(path));
File.WriteAllBytes(path, www.downloadHandler.data);
}
}
public static string GetManifestRequestUrl(string hash)
{
return $"{MANIFEST_ROOT_URL}/{hash.Substring(0, 2)}/{hash}";
+2 -1
View File
@@ -50,7 +50,7 @@ public class UmaViewerGlobalShader : MonoBehaviour
public Vector4 _Global_FogLength;
public float _RimHorizonOffset;
public float _UVEmissivePower;
public Color _AmbientColor;
public Vector2 scrollPosition = Vector2.zero;
@@ -74,6 +74,7 @@ public class UmaViewerGlobalShader : MonoBehaviour
Shader.SetGlobalFloat("_GlobalCameraFov", _GlobalCameraFov);
Shader.SetGlobalFloat("_CylinderBlend", _CylinderBlend);
Shader.SetGlobalFloat("_RimHorizonOffset", _RimHorizonOffset);
Shader.SetGlobalFloat("_UVEmissivePower", _UVEmissivePower);
//Vector Array
_MainParam.Clear();
_MainParam.Add(_MainParam_0);
+26 -2
View File
@@ -16,6 +16,7 @@ public class UmaViewerMain : MonoBehaviour
private UmaViewerBuilder Builder => UmaViewerBuilder.Instance;
public List<CharaEntry> Characters = new List<CharaEntry>();
public List<CharaEntry> MobCharacters = new List<CharaEntry>();
public List<LiveEntry> Lives = new List<LiveEntry>();
public List<CostumeEntry> Costumes = new List<CostumeEntry>();
public List<UmaDatabaseEntry> AbList = new List<UmaDatabaseEntry>();
@@ -78,6 +79,24 @@ public class UmaViewerMain : MonoBehaviour
}
}
var MobCharaData = UmaDatabaseController.Instance.MobCharaData;
foreach (var item in MobCharaData)
{
if (Convert.ToInt32(item["use_live"]) == 0)
{
continue;
}
var id = Convert.ToInt32(item["mob_id"]);
MobCharacters.Add(new CharaEntry()
{
Name = $"Mob_{id}",
Icon = UmaViewerBuilder.Instance.LoadMobCharaIcon(id.ToString()),
Id = id,
IsMob = true
});
}
foreach (var item in CostumeList)
{
var costume = new CostumeEntry();
@@ -94,6 +113,7 @@ public class UmaViewerMain : MonoBehaviour
if (costume != null)
{
costume.CharaId = Convert.ToInt32(data["chara_id"]);
costume.DressName = data["dressname"].ToString();
costume.BodyType = Convert.ToInt32(data["body_type"]);
costume.BodyTypeSub = Convert.ToInt32(data["body_type_sub"]);
}
@@ -104,7 +124,6 @@ public class UmaViewerMain : MonoBehaviour
UI.LoadPropPanel();
UI.LoadMapPanel();
var asset = AbList.FirstOrDefault(a => a.Name.Equals("livesettings"));
if (asset != null)
{
@@ -116,6 +135,9 @@ public class UmaViewerMain : MonoBehaviour
{
var musicId = Convert.ToInt32(item["music_id"]);
var songName = item["songname"].ToString();
var membercount = Convert.ToInt32(item["live_member_number"]);
var defaultdress = Convert.ToInt32(item["default_main_dress"]);
if (!Lives.Where(c => c.MusicId == musicId).Any())
{
if (bundle.Contains(musicId.ToString()))
@@ -126,8 +148,10 @@ public class UmaViewerMain : MonoBehaviour
{
MusicId = musicId,
SongName = songName,
MemberCount = membercount,
DefaultDress = defaultdress,
Icon = UmaViewerBuilder.Instance.LoadLiveIcon(musicId)
});
});
}
}
}
+250 -90
View File
@@ -1,4 +1,5 @@
using Gallop;
using SFB;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -14,27 +15,35 @@ public class UmaViewerUI : MonoBehaviour
public static UmaViewerUI Instance;
private UmaViewerMain Main => UmaViewerMain.Instance;
private UmaViewerBuilder Builder => UmaViewerBuilder.Instance;
public CanvasScaler canvasScaler;
[Header("normal models")]
public ScrollRect CharactersList;
public ScrollRect MobCharactersList;
public PageManager MobCharactersPageCtrl;
public ScrollRect CostumeList;
public ScrollRect MobCostumeList;
public ScrollRect AnimationSetList;
public ScrollRect AnimationList;
public PageManager AnimationPageCtrl;
[Header("mini models")]
public ScrollRect MiniCharactersList;
public ScrollRect MiniCostumeList;
public ScrollRect MiniAnimationSetList;
public ScrollRect MiniAnimationList;
public PageManager MiniAnimationPageCtrl;
[Header("other")]
public ScrollRect PropList;
public PageManager PropPageCtrl;
public ScrollRect SceneList;
public PageManager ScenePageCtrl;
public GameObject MessagePannel;
public Text MessageText;
[Header("lists")]
public ScrollRect EmotionList;
public Transform FacialList;
public ScrollRect EarList;
@@ -49,6 +58,7 @@ public class UmaViewerUI : MonoBehaviour
public ScrollRect NormalSubSoundList;
public PageManager NormalSoundCtrl;
[Header("audio")]
public Slider AudioSlider;
public Button AudioPlayButton;
@@ -71,6 +81,18 @@ public class UmaViewerUI : MonoBehaviour
public GameObject BG_HSVPickerObj;
public Image BG_Image;
[Header("live settings")]
public Sprite CharaIconDefault;
public Sprite CostumeIconDefault;
public LiveCharacterSelect CurrentSeletChara;
public GameObject LiveSelectPrefab;
public GameObject LiveSelectPannel;
public GameObject SelectCharacterPannel;
public ScrollRect LiveSelectList;
public Image LiveSelectImage;
public Text LiveSelectInfoText;
private LiveEntry currentLive;
[Header("settings")]
public TMP_InputField SSWidth;
public TMP_InputField SSHeight;
@@ -80,18 +102,21 @@ public class UmaViewerUI : MonoBehaviour
public Toggle GifTransparent;
public Slider GifQuality;
public TextMeshProUGUI GifQualityLabel;
public Slider GifSlider;
public Button GifButton;
public Button VMDButton;
public Button UpdateDBButton;
public TMP_Dropdown WorkModeDropdown;
public List<GameObject> TogglablePanels = new List<GameObject>();
public List<GameObject> TogglableFacials = new List<GameObject>();
[Header("prefabs")]
public GameObject UmaContainerPrefab;
public GameObject UmaContainerCostumePrefab;
public GameObject UmaContainerLivePrefab;
public GameObject UmaContainerSliderPrefab;
public GameObject UmaContainerAssetsPrefab;
private int LoadedAssetCount = 0;
[SerializeField] private RectTransform LoadedAssetsPanel;
@@ -116,6 +141,11 @@ public class UmaViewerUI : MonoBehaviour
if (Application.platform == RuntimePlatform.Android)
canvasScaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Shrink;
}
private void Start()
{
WorkModeDropdown.SetValueWithoutNotify((int)Config.Instance.WorkMode);
UpdateDBButton.interactable = (Config.Instance.WorkMode == WorkMode.Standalone);
}
private void Update()
{
@@ -131,7 +161,6 @@ public class UmaViewerUI : MonoBehaviour
}
}
if (Builder.CurrentUMAContainer != null && Builder.CurrentUMAContainer.OverrideController != null)
{
if (Builder.CurrentUMAContainer.OverrideController["clip_2"].name != "clip_2")
@@ -142,7 +171,6 @@ public class UmaViewerUI : MonoBehaviour
if (AnimeClip && Builder.CurrentUMAContainer.UmaAnimator.speed != 0)
{
var normalizedTime = (isLoop) ? Mathf.Repeat(AnimeState.normalizedTime, 1) : Mathf.Min(AnimeState.normalizedTime, 1);
AnimationTitleText.text = AnimeClip.name;
AnimationProgressText.text = string.Format("{0} / {1}", ToFrameFormat(normalizedTime * AnimeClip.length, AnimeClip.frameRate), ToFrameFormat(AnimeClip.length, AnimeClip.frameRate));
AnimationSlider.SetValueWithoutNotify(normalizedTime);
@@ -169,9 +197,9 @@ public class UmaViewerUI : MonoBehaviour
LoadedAssetCount++;
string filePath = entry.FilePath;
var container = Instantiate(UmaContainerAssetsPrefab, LoadedAssetsPanel).GetComponent<UmaUIContainer>();
var container = Instantiate(UmaContainerAssetsPrefab, LoadedAssetsPanel).GetComponent<UmaUIContainer>();
container.Name = Path.GetFileName(entry.Name);
container.Button.onClick.AddListener(() => {Process.Start("explorer.exe", "/select," + filePath);});
container.Button.onClick.AddListener(() => { Process.Start("explorer.exe", "/select," + filePath); });
LoadedAssetsPanel.sizeDelta = new Vector2(0, LoadedAssetCount * 35);
}
@@ -189,14 +217,16 @@ public class UmaViewerUI : MonoBehaviour
{
var container1 = Instantiate(UmaContainerPrefab, AnimationSetList.content).GetComponent<UmaUIContainer>();
container1.Name = container1.name = "Generic";
container1.Button.onClick.AddListener(() => {
container1.Button.onClick.AddListener(() =>
{
HighlightChildImage(AnimationSetList.content, container1);
ListAnimations(-1, false);
});
var container2 = Instantiate(UmaContainerPrefab, AnimationSetList.content).GetComponent<UmaUIContainer>();
container2.Name = container2.name = "Tail";
container2.Button.onClick.AddListener(() => {
container2.Button.onClick.AddListener(() =>
{
HighlightChildImage(AnimationSetList.content, container2);
ListAnimations(-2, false);
});
@@ -207,37 +237,60 @@ public class UmaViewerUI : MonoBehaviour
var container3 = Instantiate(UmaContainerPrefab, CharactersList.content).GetComponent<UmaUIContainer>();
container3.Name = container3.name = chara.Id + " " + chara.Name;
container3.Button.onClick.AddListener(() => {
container3.Button.onClick.AddListener(() =>
{
HighlightChildImage(CharactersList.content, container3);
ListCostumes(charaInstance.Id, false);
ListCostumes(charaInstance, false);
});
if (chara.Icon)
{
container3.Image.sprite = chara.Icon;
container3.Image.sprite = (chara.Icon == null ? CharaIconDefault : chara.Icon);
container3.Image.enabled = true;
}
var container4 = Instantiate(UmaContainerPrefab, AnimationSetList.content).GetComponent<UmaUIContainer>();
container4.Name = container4.name = chara.Id + " " + chara.Name;
container4.Button.onClick.AddListener(() => {
container4.Button.onClick.AddListener(() =>
{
HighlightChildImage(AnimationSetList.content, container4);
ListAnimations(charaInstance.Id, false);
});
if (chara.Icon)
{
container4.Image.sprite = chara.Icon;
container4.Image.sprite = (chara.Icon == null ? CharaIconDefault : chara.Icon);
container4.Image.enabled = true;
}
}
var pageentrys = new List<PageManager.Entry>();
foreach (var chara in Main.MobCharacters.OrderBy(c => c.Id))
{
var charaInstance = chara;
var pageentry = new PageManager.Entry();
pageentry.Name = chara.Name;
pageentry.OnClick = (container) =>
{
HighlightChildImage(MobCharactersList.content, container);
ListCostumes(charaInstance, false);
};
if (chara.Icon)
{
pageentry.Sprite = chara.Icon;
}
pageentrys.Add(pageentry);
}
MobCharactersPageCtrl.Initialize(pageentrys, MobCharactersList);
}
public void LoadMiniModelPanels()
{
var container1 = Instantiate(UmaContainerPrefab, MiniAnimationSetList.content).GetComponent<UmaUIContainer>();
container1.Name = container1.name = "General";
container1.Button.onClick.AddListener(() => {
container1.Button.onClick.AddListener(() =>
{
HighlightChildImage(MiniAnimationSetList.content, container1);
ListAnimations(-1, true);
});
@@ -247,9 +300,10 @@ public class UmaViewerUI : MonoBehaviour
var charaInstance = chara;
var container2 = Instantiate(UmaContainerPrefab, MiniCharactersList.content).GetComponent<UmaUIContainer>();
container2.Name = container2.name = chara.Id + " " + chara.Name;
container2.Button.onClick.AddListener(() => {
container2.Button.onClick.AddListener(() =>
{
HighlightChildImage(MiniCharactersList.content, container2);
ListCostumes(charaInstance.Id, true);
ListCostumes(charaInstance, true);
});
if (chara.Icon)
@@ -260,7 +314,8 @@ public class UmaViewerUI : MonoBehaviour
var container3 = Instantiate(UmaContainerPrefab, MiniAnimationSetList.content).GetComponent<UmaUIContainer>();
container3.Name = container3.name = chara.Id + " " + chara.Name;
container3.Button.onClick.AddListener(() => {
container3.Button.onClick.AddListener(() =>
{
HighlightChildImage(MiniAnimationSetList.content, container3);
ListAnimations(charaInstance.Id, true);
});
@@ -277,9 +332,9 @@ public class UmaViewerUI : MonoBehaviour
{
foreach (FacialMorph morph in targetMorph)
{
if(morph is FacialOtherMorph extraMorph)
if (morph is FacialOtherMorph extraMorph)
{
foreach(var prop in extraMorph.BindProperties)
foreach (var prop in extraMorph.BindProperties)
{
var container = Instantiate(UmaContainerSliderPrefab, TargetList.content).GetComponent<UmaUIContainer>();
container.Name = $"{morph.locator.name}({prop.Type})";
@@ -298,7 +353,7 @@ public class UmaViewerUI : MonoBehaviour
break;
case BindProperty.BindType.EyeSelect:
container.Slider.wholeNumbers = true;
container.Slider.maxValue = prop.BindPrefab.Count/2 - 1;
container.Slider.maxValue = prop.BindPrefab.Count / 2 - 1;
container.Slider.minValue = 0;
break;
case BindProperty.BindType.Enable:
@@ -317,9 +372,10 @@ public class UmaViewerUI : MonoBehaviour
container.Slider.minValue = 0;
break;
}
container.Slider.onValueChanged.AddListener((a) => {
container.Slider.onValueChanged.AddListener((a) =>
{
target.ChangeMorphWeight(prop, a);
if(prop.Type == BindProperty.BindType.Enable&& morph.name.Contains("Manga"))
if (prop.Type == BindProperty.BindType.Enable && morph.name.Contains("Manga"))
{
target.ChangeMorphWeight(target.EyeMorphs[42], container.Slider.value > 0 ? 1 : 0);
target.ChangeMorphWeight(target.EyeMorphs[43], container.Slider.value > 0 ? 1 : 0);
@@ -383,12 +439,12 @@ public class UmaViewerUI : MonoBehaviour
{
mat.mainTextureOffset = new Vector2(0.25f * (val % 4), -0.25f * (val / 4));
}
else if(type == 1)
else if (type == 1)
{
var vector = mat.GetVector("_UVOffset");
mat.SetVector("_UVOffset", new Vector4(0.25f * (val % 4), -0.25f * (val / 4), vector.z, vector.w));
}
else if(type == 2)
else if (type == 2)
{
var vector = mat.GetVector("_UVOffset");
mat.SetVector("_UVOffset", new Vector4(vector.x, vector.y, 0.25f * (val % 4), -0.25f * (val / 4)));
@@ -405,8 +461,8 @@ public class UmaViewerUI : MonoBehaviour
public void UpdateFacialPanels()
{
if(currentFaceDrivenKeyTarget)
LoadFacialPanels(currentFaceDrivenKeyTarget);
if (currentFaceDrivenKeyTarget)
LoadFacialPanels(currentFaceDrivenKeyTarget);
}
public void LoadEmotionPanels(FaceEmotionKeyTarget target)
@@ -418,7 +474,7 @@ public class UmaViewerUI : MonoBehaviour
if (target == null) return;
foreach(var emotion in target.FaceEmotionKey)
foreach (var emotion in target.FaceEmotionKey)
{
if (emotion.label == "Base")
{
@@ -439,19 +495,21 @@ public class UmaViewerUI : MonoBehaviour
{
var liveInstance = live;
var container = Instantiate(UmaContainerLivePrefab, LiveList.content).GetComponent<UmaUIContainer>();
container.Name = " "+ live.MusicId + " " + live.SongName;
container.Name = " " + live.MusicId + " " + live.SongName;
container.Image.sprite = live.Icon;
container.Image.enabled = container.Image.sprite;
container.Button.onClick.AddListener(() => {
container.Button.onClick.AddListener(() =>
{
HighlightChildImage(LiveList.content, container);
Builder.LoadLive(live);
ShowLiveSelectPannel(live);
});
var CharaContainer = Instantiate(UmaContainerLivePrefab, LiveSoundList.content).GetComponent<UmaUIContainer>();
CharaContainer.Name = " " + live.MusicId + " " + live.SongName;
CharaContainer.Image.sprite = live.Icon;
CharaContainer.Image.enabled = CharaContainer.Image.sprite;
CharaContainer.Button.onClick.AddListener(() => {
CharaContainer.Button.onClick.AddListener(() =>
{
HighlightChildImage(LiveSoundList.content, container);
ListLiveSounds(live.MusicId);
});
@@ -475,11 +533,11 @@ public class UmaViewerUI : MonoBehaviour
}
NormalSoundCtrl.Initialize(pageentrys, NormalSoundList);
}
public void LoadPropPanel()
{
var pageentrys = new List<PageManager.Entry>();
foreach (var prop in Main.AbList.Where(a=>a.Name.Contains("pfb_chr_prop") && !a.Name.Contains("clothes")))
foreach (var prop in Main.AbList.Where(a => a.Name.Contains("pfb_chr_prop") && !a.Name.Contains("clothes")))
{
var pageentry = new PageManager.Entry();
pageentry.Name = Path.GetFileName(prop.Name);
@@ -490,7 +548,7 @@ public class UmaViewerUI : MonoBehaviour
};
pageentrys.Add(pageentry);
}
PropPageCtrl.Initialize(pageentrys,PropList);
PropPageCtrl.Initialize(pageentrys, PropList);
}
public void LoadMapPanel()
@@ -511,34 +569,86 @@ public class UmaViewerUI : MonoBehaviour
ScenePageCtrl.Initialize(pageentrys, SceneList);
}
void ListCostumes(int umaId, bool mini)
public void PlayLive()
{
ScrollRect costumeList = mini ? MiniCostumeList : CostumeList;
if (currentLive == null) return;
var selectlist = LiveSelectList.content.GetComponentsInChildren<LiveCharacterSelect>();
if (selectlist != null)
{
Builder.LoadLive(currentLive, new List<LiveCharacterSelect>(selectlist));
LiveSelectPannel.SetActive(false);
}
}
void ShowLiveSelectPannel(LiveEntry entry)
{
LiveSelectPannel.SetActive(true);
for (int i = LiveSelectList.content.childCount - 1; i >= 0; i--)
{
Destroy(LiveSelectList.content.GetChild(i).gameObject);
}
currentLive = entry;
LiveSelectImage.sprite = entry.Icon;
LiveSelectInfoText.text = $"{entry.SongName}\nMembers Count: {entry.MemberCount}";
for (int i = 0; i < entry.MemberCount; i++)
{
var chara = Instantiate(LiveSelectPrefab, LiveSelectList.content).GetComponent<LiveCharacterSelect>();
chara.IndexText.text = (i + 1).ToString();
chara.GetComponent<Button>().onClick.AddListener(() =>
{
chara.SelectChara(this);
foreach (var t in LiveSelectList.content.GetComponentsInChildren<LiveCharacterSelect>())
{
t.GetComponentInChildren<Text>().color = (t == chara ? Color.white : Color.black);
}
});
}
}
void ListCostumes(CharaEntry chara, bool mini)
{
ScrollRect costumeList = mini ? MiniCostumeList : chara.IsMob ? MobCostumeList : CostumeList;
for (int i = costumeList.content.childCount - 1; i >= 0; i--)
{
Destroy(costumeList.content.GetChild(i).gameObject);
}
string nameVar = mini ? $"pfb_mbdy{umaId}" : $"pfb_bdy{umaId}";
foreach (var entry in Main.AbList.Where(a => !a.Name.Contains("clothes") && a.Name.Contains(nameVar)))
{
var container = Instantiate(UmaContainerCostumePrefab, costumeList.content).GetComponent<UmaUIContainer>();
string[] split = entry.Name.Split('_');
string costumeId = split[split.Length - 1];
container.Name = container.name = GetCostumeName(costumeId);
container.Button.onClick.AddListener(() => {
HighlightChildImage(costumeList.content, container);
StartCoroutine(Builder.LoadUma(umaId, costumeId, mini));
});
var icon = Main.Costumes.FirstOrDefault(a => (a.CharaId == umaId&&a.BodyTypeSub == int.Parse(costumeId)));
if (icon == null) icon = Main.Costumes[0];
container.Image.sprite = icon.Icon;
container.Image.enabled = true;
Action<CharaEntry> action = delegate (CharaEntry achara)
{
string nameVar = mini ? $"pfb_mbdy{achara.Id}" : $"pfb_bdy{achara.Id}";
foreach (var entry in Main.AbList.Where(a => !a.Name.Contains("clothes") && a.Name.Contains(nameVar)))
{
var container = Instantiate(UmaContainerCostumePrefab, costumeList.content).GetComponent<UmaUIContainer>();
string[] split = entry.Name.Split('_');
string costumeId = split[split.Length - 1];
var dressdata = Main.Costumes.FirstOrDefault(a => (a.CharaId == achara.Id && a.BodyTypeSub == int.Parse(costumeId)));
container.Name = container.name = GetCostumeName(costumeId, (dressdata == null ? costumeId : dressdata.DressName));
container.Image.sprite = (dressdata == null ? CostumeIconDefault : dressdata.Icon);
container.Image.enabled = true;
container.Button.onClick.AddListener(() =>
{
if (LiveSelectPannel.activeInHierarchy && CurrentSeletChara)
{
CurrentSeletChara.SetValue(achara, costumeId, container.Image.sprite);
}
else
{
HighlightChildImage(costumeList.content, container);
StartCoroutine(Builder.LoadUma(achara, costumeId, mini));
}
});
}
};
if (!chara.IsMob)
{
action.Invoke(chara);
}
//Common costumes
List<string> costumes = new List<string>();
nameVar = mini ? "pfb_mbdy0" : $"pfb_bdy0";
var nameVar = mini ? "pfb_mbdy0" : $"pfb_bdy0";
foreach (var entry in Main.AbChara.Where(a => a.Name.Contains("/body/") && !a.Name.Contains("/clothes/") && a.Name.Contains(nameVar)))
{
string id = Path.GetFileName(entry.Name);
@@ -548,19 +658,26 @@ public class UmaViewerUI : MonoBehaviour
costumes.Add(id);
string costumeId = id;
var container = Instantiate(UmaContainerCostumePrefab, costumeList.content).GetComponent<UmaUIContainer>();
container.Name = container.name = GetCostumeName(id);
container.Button.onClick.AddListener(() => {
HighlightChildImage(costumeList.content, container);
StartCoroutine(Builder.LoadUma(umaId, costumeId, mini));
});
var data = costumeId.Split('_');
var bodytype = int.Parse(data[0]);
var bodysub = int.Parse(data[1]);
var icon = Main.Costumes.FirstOrDefault(a => a.BodyType == bodytype&& a.BodyTypeSub == bodysub);
if (icon == null) icon = Main.Costumes[0];
container.Image.sprite = icon.Icon;
var dressdata = Main.Costumes.FirstOrDefault(a => a.BodyType == bodytype && a.BodyTypeSub == bodysub);
container.Name = container.name = GetCostumeName(id, (dressdata == null ? id : dressdata.DressName));
container.Image.sprite = (dressdata == null ? CostumeIconDefault : dressdata.Icon);
container.Image.enabled = true;
container.Button.onClick.AddListener(() =>
{
if (LiveSelectPannel.activeInHierarchy && CurrentSeletChara)
{
CurrentSeletChara.SetValue(chara, costumeId, container.Image.sprite);
}
else
{
HighlightChildImage(costumeList.content, container);
StartCoroutine(Builder.LoadUma(chara, costumeId, mini));
}
});
}
}
}
@@ -586,7 +703,8 @@ public class UmaViewerUI : MonoBehaviour
container.Image.enabled = true;
}
container.Button.onClick.AddListener(() => {
container.Button.onClick.AddListener(() =>
{
HighlightChildImage(LiveCharaSoundList.content, container);
if (isCriware)
{
@@ -610,11 +728,12 @@ public class UmaViewerUI : MonoBehaviour
var subSounds = Builder.LoadAudio(awb);
foreach(var sound in subSounds)
foreach (var sound in subSounds)
{
var container = Instantiate(UmaContainerPrefab, NormalSubSoundList.content).GetComponent<UmaUIContainer>();
container.Name = $"Clip_{subSounds.IndexOf(sound)}";
container.Button.onClick.AddListener(() => {
container.Button.onClick.AddListener(() =>
{
HighlightChildImage(NormalSubSoundList.content, container);
Builder.PlaySound(awb, subSounds.IndexOf(sound));
});
@@ -641,12 +760,13 @@ public class UmaViewerUI : MonoBehaviour
if (umaId == -1)
{
var pageentrys = new List<PageManager.Entry>();
foreach (var entry in filteredList.Where(a => (a.Name.Contains($"/type0") || a.Name.Contains($"/type99") || a.Name.Contains($"anm_sty_")) && !a.Name.Contains($"/tail") && !a.Name.EndsWith($"_pos") && !a.Name.EndsWith($"_prop") && !a.Name.EndsWith($"_pose") && !a.Name.Contains($"_defaultmotion")))
foreach (var entry in filteredList.Where(a => (a.Name.Contains($"/type0") || a.Name.Contains($"/type99") || a.Name.Contains($"anm_sty_")) && !a.Name.Contains($"/tail") && !a.Name.EndsWith($"_pos") && !a.Name.Contains($"prop") && !a.Name.EndsWith($"_pose") && !a.Name.Contains($"_defaultmotion")))
{
var pageentry = new PageManager.Entry();
pageentry.Name = Path.GetFileName(entry.Name);
pageentry.FontSize = 20;
pageentry.OnClick = (container) => {
pageentry.OnClick = (container) =>
{
HighlightChildImage(animationList.content, container);
Builder.LoadAsset(entry);
LoadedAnimation();
@@ -663,7 +783,8 @@ public class UmaViewerUI : MonoBehaviour
var container = Instantiate(UmaContainerPrefab, animationList.content).GetComponent<UmaUIContainer>();
container.Name = container.name = Path.GetFileName(entry.Name);
container.FontSize = 20;
container.Button.onClick.AddListener(() => {
container.Button.onClick.AddListener(() =>
{
HighlightChildImage(animationList.content, container);
Builder.LoadAsset(entryInstance);
LoadedAnimation();
@@ -680,7 +801,8 @@ public class UmaViewerUI : MonoBehaviour
var container = Instantiate(UmaContainerPrefab, animationList.content).GetComponent<UmaUIContainer>();
container.Name = container.name = Path.GetFileName(entry.Name);
container.FontSize = 20;
container.Button.onClick.AddListener(() => {
container.Button.onClick.AddListener(() =>
{
HighlightChildImage(animationList.content, container);
Builder.LoadAsset(entryInstance);
LoadedAnimation();
@@ -694,7 +816,8 @@ public class UmaViewerUI : MonoBehaviour
var container = Instantiate(UmaContainerPrefab, animationList.content).GetComponent<UmaUIContainer>();
container.Name = container.name = Path.GetFileName(entry.Name);
container.FontSize = 20;
container.Button.onClick.AddListener(() => {
container.Button.onClick.AddListener(() =>
{
HighlightChildImage(animationList.content, container);
Builder.LoadAsset(entryInstance);
LoadedAnimation();
@@ -714,13 +837,14 @@ public class UmaViewerUI : MonoBehaviour
pageentry.Name = Path.GetFileName(entry.Name);
pageentry.Sprite = Builder.LoadSprite(entry);
if (pageentry.Sprite == null) continue;
pageentry.OnClick = (container) => {
pageentry.OnClick = (container) =>
{
HighlightChildImage(BackGroundList.content, container);
BG_Image.sprite = pageentry.Sprite;
BG_Image.SetVerticesDirty();
};
if(BG_Image.sprite == null)
if (BG_Image.sprite == null)
{
BG_Image.sprite = pageentry.Sprite;
BG_Image.SetVerticesDirty();
@@ -751,12 +875,11 @@ public class UmaViewerUI : MonoBehaviour
return (entry == null) ? id.ToString() : entry.Name;
}
public static string GetCostumeName(string costumeId)
public static string GetCostumeName(string costumeId, string defaultname)
{
switch (costumeId)
{
case "00":
return "Default";
// case "00":return "Default";
case "90":
return "Upgraded";
case "0001_00_01":
@@ -784,7 +907,7 @@ public class UmaViewerUI : MonoBehaviour
case "0004_01_00":
return "Towel";
default:
return costumeId;
return (defaultname == "00")? "Default" : defaultname;
}
}
@@ -877,7 +1000,7 @@ public class UmaViewerUI : MonoBehaviour
public void AudioPause()
{
if (Builder.CurrentAudioSources.Count>0)
if (Builder.CurrentAudioSources.Count > 0)
{
AudioSource MainSource = Builder.CurrentAudioSources[0];
var state = MainSource.isPlaying;
@@ -901,7 +1024,7 @@ public class UmaViewerUI : MonoBehaviour
public void AudioProgressChange(float val)
{
if (Builder.CurrentAudioSources.Count>0)
if (Builder.CurrentAudioSources.Count > 0)
{
foreach (AudioSource source in Builder.CurrentAudioSources)
{
@@ -951,7 +1074,7 @@ public class UmaViewerUI : MonoBehaviour
animator_face.Play(0, 1, 0);
}
}
}
}
@@ -964,13 +1087,16 @@ public class UmaViewerUI : MonoBehaviour
if (animator != null)
{
var AnimeClip = Builder.CurrentUMAContainer.OverrideController["clip_2"];
// Pause and Seek;
animator.speed = 0;
animator.Play(0, 0, val);
animator.Play(0, 2, val);
animator_cam.speed = 0;
animator_cam.Play(0, -1, val);
if (animator_cam.runtimeAnimatorController)
{
animator_cam.speed = 0;
animator_cam.Play(0, -1, val);
}
if (animator_face)
{
animator_face.speed = 0;
@@ -1004,7 +1130,7 @@ public class UmaViewerUI : MonoBehaviour
public static string ToTimeFormat(float time)
{
int seconds = (int)time;
int hour = seconds / 3600;
int minute = seconds % 3600 / 60;
@@ -1023,9 +1149,9 @@ public class UmaViewerUI : MonoBehaviour
public string GetCurrentLyrics(float time)
{
for(int i = Builder.CurrentLyrics.Count-1; i >=0; i--)
for (int i = Builder.CurrentLyrics.Count - 1; i >= 0; i--)
{
if(Builder.CurrentLyrics[i].time< time)
if (Builder.CurrentLyrics[i].time < time)
{
return Builder.CurrentLyrics[i].text;
}
@@ -1036,7 +1162,7 @@ public class UmaViewerUI : MonoBehaviour
public void RecordVMD()
{
var buttonText = VMDButton.GetComponentInChildren<TextMeshProUGUI>();
if (!UmaViewerBuilder.Instance.CurrentUMAContainer|| UmaViewerBuilder.Instance.CurrentUMAContainer.IsMini)
if (!UmaViewerBuilder.Instance.CurrentUMAContainer || UmaViewerBuilder.Instance.CurrentUMAContainer.IsMini)
{
buttonText.text = string.Format("<color=#FF0000>{0}</color>", "Need Normal UMA");
return;
@@ -1046,7 +1172,7 @@ public class UmaViewerUI : MonoBehaviour
var camera = UmaViewerBuilder.Instance.AnimationCamera;
var rootbone = container.transform.Find("Position");
if(rootbone.gameObject.TryGetComponent(out UnityHumanoidVMDRecorder recorder))
if (rootbone.gameObject.TryGetComponent(out UnityHumanoidVMDRecorder recorder))
{
if (recorder.IsRecording)
{
@@ -1080,12 +1206,46 @@ public class UmaViewerUI : MonoBehaviour
}
}
public void UpdateGameDB() {
if (UpdateResVerCoroutine != null) return;
public void UpdateGameDB()
{
if (UpdateResVerCoroutine != null && Config.Instance.WorkMode != WorkMode.Standalone) return;
UmaDatabaseController.Instance.CloseAllConnection();
ManifestDB dB = new ManifestDB();
UpdateResVerCoroutine = dB.UpdateResourceVersion(delegate (string msg) { LyricsText.text = msg; });
UpdateResVerCoroutine = dB.UpdateResourceVersion(delegate (string msg) { ShowMessage(msg); });
StartCoroutine(UpdateResVerCoroutine);
}
public void ChangeWorkMode(int mode)
{
if ((int)Config.Instance.WorkMode != mode)
{
Config.Instance.WorkMode = (WorkMode)mode;
Config.Instance.UpdateConfig();
}
}
public void ChangeMainPath()
{
var path = StandaloneFileBrowser.OpenFolderPanel("Select Folder", Config.Instance.MainPath, false);
if (path != null && path.Length > 0 && !string.IsNullOrEmpty(path[0]))
{
if (path[0] != Config.Instance.MainPath)
{
Config.Instance.MainPath = path[0];
Config.Instance.UpdateConfig();
}
}
}
public void ChangeOutlineWidth(float val)
{
Shader.SetGlobalFloat("_GlobalOutlineWidth", val);
}
public void ShowMessage(string msg)
{
MessagePannel.SetActive(true);
MessageText.text = msg;
}
}
+3 -1
View File
@@ -4,7 +4,9 @@
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:800597811bcc5d848b15e12807d6de45",
"GUID:d60799ab2a985554ea1a39cd38695018"
"GUID:d60799ab2a985554ea1a39cd38695018",
"GUID:145e2572884581c48a08acf566c1a1d6",
"GUID:fd1d627189c561043911a07470238b9c"
],
"includePlatforms": [],
"excludePlatforms": [],
-22
View File
@@ -1,22 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class A2U
{
public enum Blend
{
Normal = 0,
Add = 1,
Multiply = 2,
Screen = 3,
Overlay = 4
}
public enum Order
{
PreImageEffect = 0,
InImageEffect = 1,
PostImageEffect = 2
}
}
@@ -0,0 +1,44 @@
using System;
using UnityEngine;
namespace Gallop
{
[Serializable]
public class CharaShaderEffectData : ScriptableObject
{
[SerializeField]
private SettingData[] _settingDataArray;
[Serializable]
public class SettingData
{
public EffectType Type;
public Material TargetMaterial;
public int[] ParamArray;
public AnimationCurve[] ParamCurveArray;
}
public enum EffectType
{
UVScrollEmissive = 0,
ReflectionMap = 1
}
public void Initialize()
{
foreach(var settingData in _settingDataArray)
{
if (settingData.TargetMaterial)
{
var mat = settingData.TargetMaterial;
if (settingData.Type == EffectType.UVScrollEmissive)
{
var p = settingData.ParamArray;
mat.SetVector("_UVEmissiveRange", new Vector4(p[0], p[1], p[2],p[3]));
//mat.SetVector("_UVEmissiveScroll", new Vector4(p[4], p[5], p[6], p[7]));
}
}
}
}
}
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 0541e5904daeb65468ed1c36718747fd
guid: c646073cb80c388489345c22e65f9425
MonoImporter:
externalObjects: {}
serializedVersion: 2
@@ -0,0 +1,9 @@
using UnityEngine;
namespace Gallop
{
public class CharaTransformProcessData : ScriptableObject
{
}
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: cfd1b235ed88e1445a56e29b4f2a549c
guid: ad24e221a99993948ae4740c38a0a377
MonoImporter:
externalObjects: {}
serializedVersion: 2
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 593ab9e85604a4648b0a0e8878793796
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6f1a2a3c0634d0947a0b1fd6a5ff4506
folderAsset: yes
timeCreated: 1531897059
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,96 @@
using System;
using System.IO;
using System.Threading;
using DereTore.Exchange.Audio.HCA;
using DereTore.Exchange.Archive.ACB;
public class DecodeACB
{
public static class CgssCipher
{
/* ミリシタ
public static readonly uint Key1 = 0xBC731A85;
public static readonly uint Key2 = 0x0002B875;
*/
//デレステ
public static readonly uint Key1 = 0xf27e3b22;
public static readonly uint Key2 = 0x00003657;
}
public delegate void AsyncDecode(byte[] inData, string outstr);
public static void Decode(string inputfilename, string outputfilename)
{
if (!File.Exists(inputfilename)) { return; }
if (File.Exists(outputfilename)) { return; }
byte[] inData = File.ReadAllBytes(inputfilename);
Decode(inData, outputfilename);
}
public static void Decode(byte[] inputData, string outputfilename)
{
if (inputData != null)
{
AsyncDecode asyncDecode = DecodeProc;
asyncDecode.BeginInvoke(inputData, outputfilename, null, null); //非同期で実行
}
}
private static void DecodeProc(byte[] inputData, string outputfilename)
{
//復号Keyをセット
var decodeParams = DecodeParams.CreateDefault();
decodeParams.Key1 = CgssCipher.Key1;
decodeParams.Key2 = CgssCipher.Key2;
//HCAの出力設定
var audioParams = AudioParams.CreateDefault();
audioParams.InfiniteLoop = false;
audioParams.SimulatedLoopCount = 0; //ループ回数
audioParams.OutputWaveHeader = true;
//Streamの生成
MemoryStream memoryStream = new MemoryStream(inputData);
//acbファイルを展開
using (AcbFile acb = AcbFile.FromStream(memoryStream,0,inputData.Length,"default",true))
{
var fileNames = acb.GetFileNames();
var s = fileNames[0];
byte[] outdata = null;
//hcaファイルを展開
using (var source = acb.OpenDataStream(s))
{
try
{
using (var hcaStream = new HcaAudioStream(source, decodeParams, audioParams))
{
//出力
outdata = new byte[hcaStream.Length];
hcaStream.Read(outdata, 0, (int)hcaStream.Length);
}
}
catch (Exception e)
{
Console.WriteLine("HCA Decodeでエラーが発生しました。");
Console.WriteLine("File : " + s);
Console.WriteLine(e);
return;
}
}
if (outdata != null)
{
string tmpfile = outputfilename + ".tmp";
File.WriteAllBytes(tmpfile, outdata);
File.Move(tmpfile, outputfilename);
}
Console.WriteLine(s);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: da7bf8ee0c95a8343a31634e5937040d
timeCreated: 1532218344
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 92850131af35f784f8f3e438824fb74a
folderAsset: yes
timeCreated: 1531897074
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,20 @@
namespace DereTore.Exchange.Archive.ACB {
public sealed class AcbCueRecord {
internal AcbCueRecord() {
}
public uint CueId { get; set; }
public byte ReferenceType { get; set; }
public ushort ReferenceIndex { get; set; }
public bool IsWaveformIdentified { get; set; }
public ushort WaveformIndex { get; set; }
public ushort WaveformId { get; set; }
public byte EncodeType { get; set; }
public bool IsStreaming { get; set; }
public string CueName { get; set; }
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 30a227313ddb56a4abfa993a99360d4c
timeCreated: 1531897074
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
using System;
namespace DereTore.Exchange.Archive.ACB {
public class AcbException : ApplicationException {
public AcbException() {
}
public AcbException(string message)
: base(message) {
}
public AcbException(string message, Exception innerException)
: base(message, innerException) {
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3d65846458ed4f6498c1841f755eae16
timeCreated: 1531897074
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,15 @@
using System;
namespace DereTore.Exchange.Archive.ACB {
public class AcbFieldMissingException : AcbException {
public AcbFieldMissingException(string fieldName)
: base("Missing" + fieldName + "field.") {
}
public AcbFieldMissingException(string fieldName, Exception innerException)
: base("Missing" + fieldName + "field.", innerException) {
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7e6aff4b2afdd3e4ca3ca7314d15b1db
timeCreated: 1531897075
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,289 @@
using System;
using System.Collections.Generic;
using System.IO;
using DereTore.Common;
namespace DereTore.Exchange.Archive.ACB {
public partial class AcbFile {
internal override void Initialize() {
base.Initialize();
InitializeAcbTables();
InitializeCueNameToWaveformTable();
InitializeAwbArchives();
}
protected override void Dispose(bool disposing) {
if(_internalAwb != null) { _internalAwb.Dispose(); }
if(_externalAwb != null) { _externalAwb.Dispose(); }
base.Dispose(disposing);
}
private AcbFile(Stream stream, long offset, long size, string acbFileName, bool disposeStream)
: this(stream, offset, size, acbFileName, false, disposeStream) {
}
private AcbFile(Stream stream, long offset, long size, string acbFileName, bool includeCueIdInFileName, bool disposeStream)
: base(stream, offset, size, acbFileName, disposeStream) {
_includeCueIdInFileName = includeCueIdInFileName;
Initialize();
}
private void InitializeAcbTables() {
var stream = Stream;
long refItemOffset = 0, refItemSize = 0, refCorrection = 0;
var tables = new Dictionary<string, UtfTable>();
_tables = tables;
var cueTable = GetTable("CueTable");
var waveformTable = GetTable("WaveformTable");
var synthTable = GetTable("SynthTable");
var cues = new AcbCueRecord[cueTable.Rows.Length];
_cues = cues;
for (var i = 0; i < cues.Length; ++i) {
var cue = new AcbCueRecord();
cue.IsWaveformIdentified = false;
cue.CueId = cueTable.GetFieldValueAsNumber<uint>(i, "CueId").Value;
cue.ReferenceType = cueTable.GetFieldValueAsNumber<byte>(i, "ReferenceType").Value;
cue.ReferenceIndex = cueTable.GetFieldValueAsNumber<ushort>(i, "ReferenceIndex").Value;
cues[i] = cue;
switch (cue.ReferenceType) {
case 2:
refItemOffset = synthTable.GetFieldOffset(cue.ReferenceIndex, "ReferenceItems").Value;
refItemSize = synthTable.GetFieldSize(cue.ReferenceIndex, "ReferenceItems").Value;
refCorrection = refItemSize + 2;
break;
case 3:
case 8:
if (i == 0) {
var refItemOffsetNullable = synthTable.GetFieldOffset(0, "ReferenceItems");
if (refItemOffsetNullable == null) {
throw new AcbFieldMissingException("ReferenceItems");
}
refItemOffset = refItemOffsetNullable.Value;
var refItemSizeNullable = synthTable.GetFieldSize(0, "ReferenceItems");
if (refItemSizeNullable == null) {
throw new AcbFieldMissingException("ReferenceItems");
}
refItemSize = refItemSizeNullable.Value;
refCorrection = refItemSize - 2;
} else {
refCorrection += 4;
}
break;
default:
throw new FormatException(string.Format("Unexpected ReferenceType '{0}' for CueIndex: '{1}.'", cues[i].ReferenceType, i));
}
if (refItemSize != 0) {
cue.WaveformIndex = stream.PeekUInt16BE(refItemOffset + refCorrection);
var isStreamingNullable = waveformTable.GetFieldValueAsNumber<byte>(cue.WaveformIndex, "Streaming");
if (isStreamingNullable != null) {
cue.IsStreaming = isStreamingNullable.Value != 0;
var waveformIdNullable = waveformTable.GetFieldValueAsNumber<ushort>(cue.WaveformIndex, "Id");
if (waveformIdNullable != null) {
cue.WaveformId = waveformIdNullable.Value;
} else if (cue.IsStreaming) {
waveformIdNullable = waveformTable.GetFieldValueAsNumber<ushort>(cue.WaveformIndex, "StreamAwbId");
if (waveformIdNullable == null) {
throw new AcbFieldMissingException("StreamAwbId");
}
cue.WaveformId = waveformIdNullable.Value;
} else {
// MemoryAwbId is for ADX2LE encoder.
waveformIdNullable = waveformTable.GetFieldValueAsNumber<ushort>(cue.WaveformIndex, "MemoryAwbId");
if (waveformIdNullable == null) {
throw new AcbFieldMissingException("MemoryAwbId");
}
cue.WaveformId = waveformIdNullable.Value;
}
var encTypeNullable = waveformTable.GetFieldValueAsNumber<byte>(cue.WaveformIndex, "EncodeType");
if (encTypeNullable == null) {
throw new AcbFieldMissingException("EncodeType");
}
cue.EncodeType = encTypeNullable.Value;
cue.IsWaveformIdentified = true;
}
}
}
}
private void InitializeCueNameToWaveformTable() {
var cueNameTable = GetTable("CueNameTable");
var cues = Cues;
var includeCueIdInFileName = _includeCueIdInFileName;
var cueNameToWaveform = new Dictionary<string, ushort>();
//_cueNameToWaveform = cueNameToWaveform;
for (var i = 0; i < cueNameTable.Rows.Length; ++i) {
var cueIndexNullable = cueNameTable.GetFieldValueAsNumber<ushort>(i, "CueIndex");
if (cueIndexNullable == null) {
throw new AcbFieldMissingException("CueIndex");
}
var cueIndex = cueIndexNullable.Value;
var cue = cues[cueIndex];
if (cue.IsWaveformIdentified) {
var cueName = cueNameTable.GetFieldValueAsString(i, "CueName");
if (cueName == null) {
throw new AcbFieldMissingException("CueName");
}
cueName += GetExtensionForEncodeType(cue.EncodeType);
if (includeCueIdInFileName) {
cueName = cue.CueId.ToString("D5") + "_" + cueName;
}
cue.CueName = cueName;
cueNameToWaveform.Add(cueName, cue.WaveformId);
}
}
}
private void InitializeAwbArchives() {
var internalAwbSize = GetFieldSize(0, "AwbFile");
if (internalAwbSize.HasValue && internalAwbSize.Value > 0) {
_internalAwb = GetInternalAwbArchive();
}
var externalAwbSize = GetFieldSize(0, "StreamAwbAfs2Header");
if (externalAwbSize.HasValue && externalAwbSize.Value > 0) {
_externalAwb = GetExternalAwbArchive();
}
}
private Stream GetDataStreamFromCueInfo(AcbCueRecord cue, string fileNameForErrorInfo) {
if (!cue.IsWaveformIdentified) {
throw new InvalidOperationException(string.Format("File '{0}' is not identified.", fileNameForErrorInfo));
}
if (cue.IsStreaming) {
var externalAwb = ExternalAwb;
if (externalAwb == null) {
throw new InvalidOperationException(string.Format("External AWB does not exist for streaming file '{0}'.", fileNameForErrorInfo));
}
if (!externalAwb.Files.ContainsKey(cue.WaveformId)) {
throw new InvalidOperationException(string.Format("Waveform ID {0} is not found in AWB file {1}.", cue.WaveformId, externalAwb.FileName));
}
var targetExternalFile = externalAwb.Files[cue.WaveformId];
using (var fs = File.Open(externalAwb.FileName, FileMode.Open, FileAccess.Read)) {
return AcbHelper.ExtractToNewStream(fs, targetExternalFile.FileOffsetAligned, (int)targetExternalFile.FileLength);
}
} else {
var internalAwb = InternalAwb;
if (internalAwb == null) {
throw new InvalidOperationException(string.Format("Internal AWB is not found for memory file '{0}' in '{1}'.", fileNameForErrorInfo, AcbFileName));
}
if (!internalAwb.Files.ContainsKey(cue.WaveformId)) {
throw new InvalidOperationException(string.Format("Waveform ID {0} is not found in internal AWB in {1}.", cue.WaveformId, AcbFileName));
}
var targetInternalFile = internalAwb.Files[cue.WaveformId];
return AcbHelper.ExtractToNewStream(Stream, targetInternalFile.FileOffsetAligned, (int)targetInternalFile.FileLength);
}
}
private Afs2Archive GetInternalAwbArchive() {
var internalAwbOffset = GetFieldOffset(0, "AwbFile");
if (internalAwbOffset == null) {
throw new AcbFieldMissingException("AwbFile");
}
var internalAwb = new Afs2Archive(Stream, internalAwbOffset.Value, AcbFileName, false);
internalAwb.Initialize();
return internalAwb;
}
private Afs2Archive GetExternalAwbArchive() {
var acbFileName = AcbFileName;
var awbDirPath = Path.GetDirectoryName(acbFileName);
var awbBaseFileName = Path.GetFileNameWithoutExtension(acbFileName);
string[] awbFiles = null;
string awbMask1 = null, awbMask2 = null, awbMask3 = null;
if (awbFiles == null || awbFiles.Length < 1) {
awbMask1 = string.Format(AwbFileNameFormats.Format1, awbBaseFileName);
awbFiles = Directory.GetFiles(awbDirPath, awbMask1, SearchOption.TopDirectoryOnly);
}
if (awbFiles == null || awbFiles.Length < 1) {
awbMask2 = string.Format(AwbFileNameFormats.Format2, awbBaseFileName);
awbFiles = Directory.GetFiles(awbDirPath, awbMask2, SearchOption.TopDirectoryOnly);
}
if (awbFiles == null || awbFiles.Length < 1) {
awbMask3 = string.Format(AwbFileNameFormats.Format3, awbBaseFileName);
awbFiles = Directory.GetFiles(awbDirPath, awbMask3, SearchOption.TopDirectoryOnly);
}
if (awbFiles.Length < 1) {
throw new FileNotFoundException(string.Format("Cannot find AWB file. Please verify corresponding AWB file is named '{0}', '{1}', or '{2}'.", awbMask1, awbMask2, awbMask3));
}
if (awbFiles.Length > 1) {
throw new FileNotFoundException(string.Format("More than one matching AWB file for this ACB. Please verify only one AWB file is named '{0}', '{1}', or '{2}'.", awbMask1, awbMask2, awbMask3));
}
var externalAwbHash = GetFieldValueAsData(0, "StreamAwbHash");
var fs = File.Open(awbFiles[0], FileMode.Open, FileAccess.Read);
var awbHash = AcbHelper.GetMd5Checksum(fs);
Afs2Archive archive;
if (AcbHelper.AreDataIdentical(awbHash, externalAwbHash)) {
archive = new Afs2Archive(fs, 0, fs.Name, true);
archive.Initialize();
} else {
fs.Dispose();
throw new FormatException(string.Format("Checksum of AWB file '{0}' ({1}) does not match MD5 checksum inside ACB file '{2}' ({3}).", fs.Name, BitConverter.ToString(awbHash), acbFileName, BitConverter.ToString(externalAwbHash)));
}
return archive;
}
private UtfTable ResolveTable(string tableName) {
var tableOffset = GetFieldOffset(0, tableName);
if (!tableOffset.HasValue) {
return null;
}
var tableSize = GetFieldSize(0, tableName);
if (!tableSize.HasValue) {
return null;
}
var table = new UtfTable(Stream, tableOffset.Value, tableSize.Value, AcbFileName, false);
table.Initialize();
return table;
}
private static string GetExtensionForEncodeType(byte encodeType) {
string ext;
switch ((WaveformEncodeType)encodeType) {
case WaveformEncodeType.Adx:
ext = ".adx";
break;
case WaveformEncodeType.Hca:
ext = ".hca";
break;
case WaveformEncodeType.Atrac3:
ext = ".at3";
break;
case WaveformEncodeType.Vag:
ext = ".vag";
break;
case WaveformEncodeType.BcWav:
ext = ".bcwav";
break;
case WaveformEncodeType.NintendoDsp:
ext = ".dsp";
break;
default:
ext = string.Format(".et-{0}.bin", encodeType.ToString("D2"));
break;
}
return ext;
}
private readonly bool _includeCueIdInFileName;
private Dictionary<string, UtfTable> _tables;
//private Dictionary<string, ushort> _cueNameToWaveform;
private AcbCueRecord[] _cues;
private Afs2Archive _internalAwb;
private Afs2Archive _externalAwb;
private string[] _fileNames;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bf2e5893cf0c0744ab2b0d6fb80aae47
timeCreated: 1531897075
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace DereTore.Exchange.Archive.ACB {
public sealed partial class AcbFile : UtfTable {
public static AcbFile FromStream(FileStream stream) {
return FromStream(stream, 0, stream.Length, false);
}
public static AcbFile FromStream(FileStream stream, bool disposeStream) {
return FromStream(stream, 0, stream.Length, disposeStream);
}
public static AcbFile FromStream(FileStream stream, long offset, long size) {
return new AcbFile(stream, offset, size, stream.Name, false);
}
public static AcbFile FromStream(FileStream stream, long offset, long size, bool disposeStream) {
return new AcbFile(stream, offset, size, stream.Name, disposeStream);
}
public static AcbFile FromStream(FileStream stream, long offset, long size, bool includeCueIdInFileName, bool disposeStream) {
return new AcbFile(stream, offset, size, stream.Name, includeCueIdInFileName, disposeStream);
}
public static AcbFile FromStream(Stream stream, string acbFileName, bool disposeStream) {
return FromStream(stream, 0, stream.Length, acbFileName, disposeStream);
}
public static AcbFile FromStream(Stream stream, long offset, long size, string acbFileName, bool disposeStream) {
return new AcbFile(stream, offset, size, acbFileName, disposeStream);
}
public static AcbFile FromStream(Stream stream, long offset, long size, string acbFileName, bool includeCueIdInFileName, bool disposeStream) {
return new AcbFile(stream, offset, size, acbFileName, includeCueIdInFileName, disposeStream);
}
public static AcbFile FromFile(string fileName) {
var fs = File.Open(fileName, FileMode.Open, FileAccess.Read);
return FromStream(fs, false);
}
public Dictionary<string, UtfTable> Tables
{
get
{
return _tables;
}
}
public AcbCueRecord[] Cues
{
get
{
return _cues;
}
}
public Afs2Archive InternalAwb
{
get
{
return _internalAwb;
}
}
public Afs2Archive ExternalAwb
{
get
{
return _externalAwb;
}
}
public UtfTable GetTable(string tableName) {
if (_tables == null) {
return null;
}
var tables = _tables;
UtfTable table;
if (tables.ContainsKey(tableName)) {
table = tables[tableName];
} else {
table = ResolveTable(tableName);
if (table != null) {
tables.Add(tableName, table);
}
}
return table;
}
public string[] GetFileNames() {
if (_cues != null)
{
_fileNames = Cues.Select(cue => cue.CueName).ToArray();
}
return _fileNames;
}
public bool FileExists(string fileName) {
return _fileNames != null && _fileNames.Contains(fileName);
}
public Stream OpenDataStream(string fileName) {
AcbCueRecord cue;
try {
cue = Cues.Single(c => c.CueName == fileName);
} catch (InvalidOperationException ex) {
throw new InvalidOperationException(string.Format("File '{0}' is not found or it has multiple entries.", fileName), ex);
}
return GetDataStreamFromCueInfo(cue, fileName);
}
public Stream OpenDataStream(uint cueId) {
AcbCueRecord cue;
var tempFileName = string.Format("cue #{0}", cueId);
try {
cue = Cues.Single(c => c.CueId == cueId);
} catch (InvalidOperationException ex) {
throw new InvalidOperationException(string.Format("File '{0}' is not found or it has multiple entries.", tempFileName), ex);
}
return GetDataStreamFromCueInfo(cue, tempFileName);
}
public static string GetSymbolicFileNameFromCueId(uint cueId) {
return string.Format("dat_{0:000000}.bin", cueId);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ea2e9f6906272ac4e8c27ad50b313b98
timeCreated: 1531897076
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,107 @@
using System;
using System.Linq.Expressions;
using System.IO;
using System.Security.Cryptography;
namespace DereTore.Exchange.Archive.ACB {
internal static class AcbHelper {
public static string NameOf<T>(Expression<Func<T>> e)
{
return ((MemberExpression)e.Body).Member.Name;
}
public static bool AreDataIdentical(byte[] array1, long offset1, byte[] array2, long offset2, long length) {
if (length <= 0) {
throw new ArgumentOutOfRangeException(NameOf(() => length));
}
if (offset1 < 0) {
throw new ArgumentOutOfRangeException(NameOf(() => offset1));
}
if (offset2 < 0) {
throw new ArgumentOutOfRangeException(NameOf(() => offset2));
}
long end1 = offset1 + length, end2 = offset2 + length;
if (end1 > array1.LongLength) {
throw new IndexOutOfRangeException("Length of array 1 is not enough.");
}
if (end2 > array2.LongLength) {
throw new IndexOutOfRangeException("Length of array 2 is not enough.");
}
for (; offset1 < end1; ++offset1, ++offset2) {
if (array1[offset1] != array2[offset2]) {
return false;
}
}
return true;
}
public static bool AreDataIdentical(byte[] array1, int offset1, byte[] array2, int offset2, int length) {
return AreDataIdentical(array1, offset1, array2, offset2, (long)length);
}
public static bool AreDataIdentical(byte[] array1, byte[] array2, long length) {
return AreDataIdentical(array1, 0, array2, 0, length);
}
public static bool AreDataIdentical(byte[] array1, byte[] array2, int length) {
return AreDataIdentical(array1, 0, array2, 0, (long)length);
}
public static bool AreDataIdentical(byte[] array1, byte[] array2) {
return AreDataIdentical(array1, 0, array2, 0, array1.LongLength);
}
public static int RoundUpToAlignment(int valueToRound, int byteAlignment) {
var roundedValue = (valueToRound + byteAlignment - 1) / byteAlignment * byteAlignment;
return roundedValue;
}
public static uint RoundUpToAlignment(uint valueToRound, uint byteAlignment) {
var roundedValue = (valueToRound + byteAlignment - 1) / byteAlignment * byteAlignment;
return roundedValue;
}
public static long RoundUpToAlignment(long valueToRound, long byteAlignment) {
var roundedValue = (valueToRound + byteAlignment - 1) / byteAlignment * byteAlignment;
return roundedValue;
}
public static ulong RoundUpToAlignment(ulong valueToRound, ulong byteAlignment) {
var roundedValue = (valueToRound + byteAlignment - 1) / byteAlignment * byteAlignment;
return roundedValue;
}
public static byte[] GetMd5Checksum(Stream stream) {
return Md5.ComputeHash(stream);
}
public static byte[] GetMd5Checksum(byte[] data) {
return Md5.ComputeHash(data);
}
public static Stream ExtractToNewStream(Stream stream, long offset, int length) {
var originalPosition = stream.Position;
stream.Seek(offset, SeekOrigin.Begin);
var buffer = new byte[length];
var memory = new byte[length];
long currentIndex = 0;
var bytesLeft = length;
do {
var read = stream.Read(buffer, 0, bytesLeft);
Array.Copy(buffer, 0, memory, currentIndex, read);
currentIndex += read;
bytesLeft -= read;
} while (bytesLeft > 0);
stream.Position = originalPosition;
var memoryStream = new MemoryStream(memory, false) {
Capacity = length
};
memoryStream.Seek(0, SeekOrigin.Begin);
return memoryStream;
}
private static readonly MD5 Md5 = new MD5CryptoServiceProvider();
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2154610d9ad88364a9deafa2a52bcf8f
timeCreated: 1531897074
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
namespace DereTore.Exchange.Archive.ACB {
public sealed class AcbInfo {
internal AcbInfo() {
}
public string Name { get; set; }
public string VersionString { get; set; }
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6ffc9d74917f4d1408797d11b62fb3d8
timeCreated: 1531897075
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.IO;
using DereTore.Common;
namespace DereTore.Exchange.Archive.ACB {
public sealed class Afs2Archive : DisposableBase {
public Afs2Archive(Stream stream, long offset, string fileName, bool disposeStream) {
_fileName = fileName;
_stream = stream;
_streamOffset = offset;
_disposeStream = disposeStream;
}
public void Initialize() {
var stream = _stream;
var offset = _streamOffset;
var acbFileName = _fileName;
if (!IsAfs2Archive(stream, offset)) {
throw new FormatException("File '" + acbFileName + "' does not contain a valid AFS2 archive at offset {offset}.");
}
var fileCount = (int)stream.PeekUInt32LE(offset + 8);
if (fileCount > ushort.MaxValue) {
throw new IndexOutOfRangeException("File count " + fileCount + " exceeds maximum possible value (65535).");
}
var files = new Dictionary<int, Afs2FileRecord>(fileCount);
_files = files;
var byteAlignment = stream.PeekUInt32LE(offset + 12);
_byteAlignment = byteAlignment;
var version = stream.PeekUInt32LE(offset + 4);
_version = version;
var offsetFieldSize = (int)(version >> 8) & 0xff; // versionBytes[1], always 4?
uint offsetMask = 0;
for (var j = 0; j < offsetFieldSize; j++) {
offsetMask |= (uint)(0xff << (j * 8));
}
const int invalidCueId = -1;
var previousCueId = invalidCueId;
var fileOffsetFieldBase = 0x10 + fileCount * 2;
for (ushort i = 0; i < fileCount; ++i) {
var currentFileOffsetBase = fileOffsetFieldBase + offsetFieldSize * i;
var record = new Afs2FileRecord {
CueId = stream.PeekUInt16LE(offset + (0x10 + 2 * i)),
// TODO: Dynamically judge if the field is U32/U16 or else (see offsetFieldSize).
FileOffsetRaw = stream.PeekUInt32LE(offset + currentFileOffsetBase)
};
record.FileOffsetRaw &= offsetMask;
record.FileOffsetRaw += offset;
record.FileOffsetAligned = AcbHelper.RoundUpToAlignment(record.FileOffsetRaw, ByteAlignment);
if (i == fileCount - 1) {
record.FileLength = stream.PeekUInt32LE(offset + currentFileOffsetBase + offsetFieldSize) + offset - record.FileOffsetAligned;
}
if (previousCueId != invalidCueId) {
files[previousCueId].FileLength = record.FileOffsetRaw - files[previousCueId].FileOffsetAligned;
}
files.Add(record.CueId, record);
previousCueId = record.CueId;
}
}
public static bool IsAfs2Archive(Stream stream, long offset) {
var fileSignature = stream.PeekBytes(offset, 4);
return AcbHelper.AreDataIdentical(fileSignature, Afs2Signature);
}
public string FileName { get { return _fileName; } }
public uint ByteAlignment { get { return _byteAlignment; } }
public Dictionary<int, Afs2FileRecord> Files { get { return _files; } }
public uint Version { get { return _version; } }
protected override void Dispose(bool disposing) {
if (_disposeStream) {
try {
_stream.Dispose();
} catch (ObjectDisposedException) {
}
}
}
public static readonly byte[] Afs2Signature = { 0x41, 0x46, 0x53, 0x32 }; // 'AFS2'
private uint _byteAlignment;
private Dictionary<int, Afs2FileRecord> _files;
private uint _version;
private readonly string _fileName;
private readonly Stream _stream;
private readonly long _streamOffset;
private readonly bool _disposeStream;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 877d9df8d8359454ab89db6127e24130
timeCreated: 1531897075
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
namespace DereTore.Exchange.Archive.ACB {
public sealed class Afs2FileRecord {
internal Afs2FileRecord() {
}
public ushort CueId { get; set; }
public long FileOffsetRaw { get; set; }
public long FileOffsetAligned { get; set; }
public long FileLength { get; set; }
public string FileName { get; set; }
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 12f45a00cf528a7499fc4607a12bf688
timeCreated: 1531897074
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
namespace DereTore.Exchange.Archive.ACB {
internal static class AwbFileNameFormats {
public static readonly string Format1 = "{0}_streamfiles.awb";
public static readonly string Format2 = "{0}.awb";
public static readonly string Format3 = "{0}_STR.awb";
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 03ed2a16422c1bd4390cfe34b919f529
timeCreated: 1531897074
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
namespace DereTore.Exchange.Archive.ACB {
public enum AwbLocation {
Unknown = 0,
Internal = 1,
External = 2
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5046b4a5c6de9ec4786f465dbcd47bf9
timeCreated: 1531897075
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
namespace DereTore.Exchange.Archive.ACB {
public enum ColumnStorage : byte {
Zero = 0x10,
Constant = 0x30,
PerRow = 0x50,
Constant2 = 0x70,
Mask = 0xf0
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 163cfd528c2fa56478013994443e0fbd
timeCreated: 1531897074
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,19 @@
namespace DereTore.Exchange.Archive.ACB {
public enum ColumnType : byte {
Byte = 0x00,
SByte = 0x01,
UInt16 = 0x02,
Int16 = 0x03,
UInt32 = 0x04,
Int32 = 0x05,
UInt64 = 0x06,
Int64 = 0x07, // not sure
Single = 0x08,
Double = 0x09, // not sure
String = 0x0a,
Data = 0x0b,
Mask = 0x0f
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1b90a05d134840b4586cc811f03749bc
timeCreated: 1531897074
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,29 @@
using System.Runtime.InteropServices;
namespace DereTore.Exchange.Archive.ACB {
[StructLayout(LayoutKind.Explicit)]
public struct NumericUnion {
[FieldOffset(0)]
public byte U8;
[FieldOffset(0)]
public sbyte S8;
[FieldOffset(0)]
public short S16;
[FieldOffset(0)]
public ushort U16;
[FieldOffset(0)]
public int S32;
[FieldOffset(0)]
public uint U32;
[FieldOffset(0)]
public long S64;
[FieldOffset(0)]
public ulong U64;
[FieldOffset(0)]
public float R32;
[FieldOffset(0)]
public double R64;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f176cf14cdf2e9441bee89b39b26f0e7
timeCreated: 1531897076
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 009868f8c43db7746b02378159830aa2
folderAsset: yes
timeCreated: 1531897074
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,113 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
namespace DereTore.Exchange.Archive.ACB.Serialization {
public partial class AcbSerializer {
private byte[] GetTableBytes<T>(T[] tableRows) where T : UtfRowBase {
var tableImage = PrepareTable(tableRows);
byte[] buffer;
using (var memory = new MemoryStream()) {
tableImage.WriteTo(memory);
//memory.Capacity = (int)AcbHelper.RoundUpToAlignment((int)memory.Length, Alignment);
buffer = new byte[memory.Length];
//memory.GetBuffer().CopyTo(buffer, 0);
Array.Copy(memory.GetBuffer(), buffer, buffer.Length);
}
return buffer;
}
private UtfTableImage PrepareTable<T>(T[] tableRows) where T : UtfRowBase {
var tableName = GetTableName(tableRows);
var tableImage = new UtfTableImage(tableName, Alignment);
foreach (var tableRow in tableRows) {
var targetMembers = SerializationHelper.GetSearchTargetFieldsAndProperties(tableRow);
var tableImageRow = new List<UtfFieldImage>();
tableImage.Rows.Add(tableImageRow);
// TODO: Save misc data first, then the tables.
foreach (var member in targetMembers) {
var fieldInfo = member.FieldInfo;
var fieldType = fieldInfo.FieldType;
var fieldAttribute = member.FieldAttribute;
CheckFieldType(fieldType);
var fieldValue = member.FieldInfo.GetValue(tableRow);
var fieldImage = new UtfFieldImage {
Order = fieldAttribute.Order,
Name = string.IsNullOrEmpty(fieldAttribute.FieldName) ? fieldInfo.Name : fieldAttribute.FieldName,
Storage = fieldAttribute.Storage,
};
// Empty tables are treated as empty data.
if (IsTypeRowList(fieldType) && fieldValue != null && ((UtfRowBase[])fieldValue).Length > 0) {
var tableBytes = GetTableBytes((UtfRowBase[])fieldValue);
fieldImage.SetValue(tableBytes);
fieldImage.IsTable = true;
} else if (fieldType == typeof(byte[]) && member.ArchiveAttribute != null) {
var files = new List<byte[]> {
(byte[])fieldValue
};
var archiveBytes = SerializationHelper.GetAfs2ArchiveBytes(files.AsReadOnly(), Alignment);
fieldImage.SetValue(archiveBytes);
fieldImage.IsTable = true;
} else {
if (fieldValue == null) {
fieldImage.SetNullValue(MapFromRawType(fieldType));
} else {
fieldImage.SetValue(fieldValue);
}
}
tableImageRow.Add(fieldImage);
}
}
return tableImage;
}
private static void CheckFieldType(Type type) {
if (!SupportedTypes.Contains(type) && !IsTypeRowList(type)) {
throw new InvalidCastException("Unsupported type: '" + type.FullName + "'");
}
}
private static bool IsTypeRowList(Type type) {
return type.IsArray && type.HasElementType && type.GetElementType().IsSubclassOf(typeof(UtfRowBase));
}
private static ColumnType MapFromRawType(Type rawType) {
if (IsTypeRowList(rawType)) {
return ColumnType.Data;
}
var index = SupportedTypes.IndexOf(rawType);
return (ColumnType)index;
}
private static string GetTableName<T>(T[] tableRows) where T : UtfRowBase {
if (tableRows == null) {
throw new ArgumentNullException(NameOf(() => tableRows));
}
if (tableRows.Length < 1) {
throw new ArgumentException("There should be at least one row in a table.", NameOf(() => tableRows));
}
// Assuming all the rows are of the same type.
var tableType = tableRows[0].GetType();
var tableAttributes = tableType.GetCustomAttributes(typeof(UtfTableAttribute), false);
if (tableAttributes.Length == 1) {
return ((UtfTableAttribute)tableAttributes[0]).Name;
} else {
var s = tableType.Name;
if (s.EndsWith("Table")) {
s = s.Substring(0, s.Length - 5);
}
return s;
}
}
private static readonly Type[] SupportedTypes = {
typeof(byte), typeof(sbyte), typeof(ushort), typeof(short), typeof(uint), typeof(int), typeof(ulong), typeof(long),
typeof(float),typeof(double),
typeof(string),
typeof(byte[])
};
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6e9ed21e969c0974f852b6d63577ad04
timeCreated: 1531897075
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,41 @@
using System;
using System.IO;
using System.Linq.Expressions;
using DereTore.Common;
namespace DereTore.Exchange.Archive.ACB.Serialization {
public sealed partial class AcbSerializer {
public static string NameOf<T>(Expression<Func<T>> e)
{
return ((MemberExpression)e.Body).Member.Name;
}
public AcbSerializer() {
Alignment = 32;
}
public void Serialize<T>(T[] tableRows, Stream serializationStream) where T : UtfRowBase {
if (tableRows == null) {
throw new ArgumentNullException(NameOf(() => tableRows));
}
var tableData = GetTableBytes(tableRows).RoundUpTo(Alignment);
serializationStream.WriteBytes(tableData);
}
public uint Alignment {
get {
return _alignment;
}
set {
if (value <= 0 || value % 16 != 0) {
throw new ArgumentException("Alignment should be a positive integer, also a multiple of 16.", NameOf(() => value));
}
_alignment = value;
}
}
private uint _alignment;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 64569347a4afa7347b1e1fa83baa4ff7
timeCreated: 1531897075
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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