Merge pull request #887 from ousttrue/feature/code_move

コード整理
This commit is contained in:
ousttrue
2021-04-19 17:35:30 +09:00
committed by GitHub
96 changed files with 72 additions and 202 deletions

View File

@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using MeshUtility;
using MeshUtility.M17N;
using UnityEditor;
using UnityEngine;

View File

@@ -1,5 +1,4 @@
using MeshUtility.M17N;

namespace UniGLTF.EditorSettingsValidator
{
public enum Messages

View File

@@ -1,5 +1,4 @@
using MeshUtility.M17N;
using UnityEditor;
using UnityEditor;
namespace UniGLTF.EditorSettingsValidator
{

View File

@@ -1,5 +1,4 @@
using System;
using MeshUtility.M17N;
using UnityEditor;
using UnityEngine;

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Reflection;
using UnityEngine;
using UnityEditor;
using MeshUtility.M17N;
using UniGLTF;
namespace MeshUtility
{

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace MeshUtility
namespace UniGLTF
{
public delegate IEnumerable<Validation> Validator(GameObject root);

View File

@@ -1,7 +1,7 @@
using System.Linq;
using UnityEngine;
namespace MeshUtility
namespace UniGLTF
{
public static class ExporterExtensions
{

View File

@@ -66,7 +66,7 @@ namespace UniGLTF
}
}
MeshUtility.ExporterDialogState m_state;
ExporterDialogState m_state;
GltfExportSettings m_settings;
Editor m_settingsInspector;
@@ -79,7 +79,7 @@ namespace UniGLTF
m_settings = ScriptableObject.CreateInstance<GltfExportSettings>();
m_settingsInspector = Editor.CreateEditor(m_settings);
m_state = new MeshUtility.ExporterDialogState();
m_state = new ExporterDialogState();
m_state.ExportRootChanged += (root) =>
{
Repaint();
@@ -120,9 +120,9 @@ namespace UniGLTF
}
private Vector2 m_ScrollPosition;
IEnumerable<MeshUtility.Validator> ValidatorFactory()
IEnumerable<Validator> ValidatorFactory()
{
yield return MeshUtility.Validators.HierarchyValidator.ValidateRoot;
yield return HierarchyValidator.ValidateRoot;
yield return AnimationValidator.Validate;
if (!m_state.ExportRoot)
{
@@ -143,7 +143,7 @@ namespace UniGLTF
EditorGUIUtility.labelWidth = 150;
// lang
MeshUtility.M17N.Getter.OnGuiSelectLang();
Getter.OnGuiSelectLang();
EditorGUILayout.LabelField("ExportRoot");
{
@@ -198,7 +198,7 @@ namespace UniGLTF
foreach (var v in m_state.Validations)
{
v.DrawGUI();
if (v.ErrorLevel == MeshUtility.ErrorLevels.Critical)
if (v.ErrorLevel == ErrorLevels.Critical)
{
// Export UI を表示しない
return false;

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using UnityEditor;
namespace MeshUtility.M17N
namespace UniGLTF
{
/// <summary>
/// 多言語対応
@@ -84,16 +84,16 @@ namespace MeshUtility.M17N
public static string Msg<T>(this T key) where T : Enum
{
return M17N.MsgCache<T>.Get(Lang, key);
return MsgCache<T>.Get(Lang, key);
}
public static void OnGuiSelectLang()
{
var lang = (M17N.Languages)EditorGUILayout.EnumPopup("lang", Lang);
var lang = (Languages)EditorGUILayout.EnumPopup("lang", Lang);
if (lang != Lang)
{
m_lang = lang;
EditorPrefs.SetString(LANG_KEY, M17N.Getter.Lang.ToString());
EditorPrefs.SetString(LANG_KEY, Getter.Lang.ToString());
}
}
}

View File

@@ -1,9 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using MeshUtility.M17N;
using UnityEngine;
namespace MeshUtility.Validators
namespace UniGLTF
{
public static class HierarchyValidator
{

View File

@@ -1,10 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using MeshUtility.M17N;
using UnityEditor;
using UnityEngine;
namespace MeshUtility.Validators
namespace UniGLTF
{
public class NameValidator
{

View File

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

View File

@@ -1,17 +0,0 @@
{
"name": "MeshUtility.Editor",
"references": [
"MeshUtility"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

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

View File

@@ -1,9 +0,0 @@
MIT License
Copyright (c) 2020 VRM Consortium
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 5759a25d3024bd94a92b0af38bac243c
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,36 +0,0 @@
# MeshUtility
Mesh processing tool in Unity platform.
## Utilities
[Details can be found here](https://vrm.dev/en/docs/univrm/gltf/mesh_utility/)
## Import MeshUtility
There are two ways to import MeshUtility into a Unity project.
### 1. Unity Package Manager (from Unity 2019)
You can add MeshUtility package via `UPM`. First click `Window` at the top of Unity Editor, then select `Package Manager`.
<img src="Documentation/images/installation_1.jpg" width="200">
In `Package Manager`, click `Add package from git URL` and paste `https://github.com/vrm-c/UniVRM.git?path=/Assets/VRMShaders` and `https://github.com/vrm-c/UniVRM.git?path=/Assets/UniGLTF`
<img src="Documentation/images/installation_2.jpg" width="200">
Now check your project window. In `Packages`, MeshUtility should be included in the `UniGLTF` folder.
### 2. Add package name and its url in manifest.json
Another way of importing MeshUtility is manually adding necessary information in manifest.json, which is in the directory of `Package folder` in your Unity project. Open manifest.json with text editor and add the followings in `dependencies`:
```json
{
"dependencies": {
"com.vrmc.vrmshaders": "https://github.com/vrm-c/UniVRM.git?path=/Assets/VRMShaders",
"com.vrmc.unigltf": "https://github.com/vrm-c/UniVRM.git?path=/Assets/UniGLTF",
}
}
```

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: febba2ec3ea2c9247ab21226ce81f924
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,2 +0,0 @@
[InternetShortcut]
URL=https://github.com/vrm-c/UniVRM/tree/master/Assets/UniGLTF/MeshUtility

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 42e2fc8311d7ef44fa3975996ba1645d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

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

View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
using UnityEditor;
#endif
namespace MeshUtility
namespace UniGLTF
{
public enum ErrorLevels
{

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 703726d4973c85447a3bd2ae30c760f0
guid: 221b6a77b68c6364a9f1387cf1ede576
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
using System.Collections.Generic;
using MeshUtility;
using UniGLTF;
using UnityEngine;
namespace VRM

View File

@@ -1,4 +1,4 @@
using MeshUtility;
using UniGLTF;
using UnityEditor;
using UnityEngine;

View File

@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MeshUtility;
using UniGLTF;
using UnityEngine;
namespace VRM

View File

@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using MeshUtility;
using MeshUtility.M17N;
using UniGLTF;
using UnityEngine;
namespace VRM

View File

@@ -2,7 +2,6 @@
using System;
using UnityEditor;
using UnityEngine;
using MeshUtility.M17N;
namespace VRM
{

View File

@@ -2,7 +2,6 @@
using System;
using UnityEditor;
using UnityEngine;
using MeshUtility.M17N;
using System.Reflection;
using System.Linq;
using System.Collections.Generic;
@@ -49,7 +48,7 @@ namespace VRM
static string Msg(Options key)
{
return MeshUtility.M17N.Getter.Msg(key);
return Getter.Msg(key);
}
public enum Options

View File

@@ -1,6 +1,5 @@
using System.Collections.Generic;
using MeshUtility;
using MeshUtility.M17N;
using UniGLTF;
using UnityEngine;
namespace VRM
@@ -32,9 +31,9 @@ namespace VRM
if (vrmMeta != null && vrmMeta.Meta != null && vrmMeta.Meta.Thumbnail != null)
{
var thumbnailName = vrmMeta.Meta.Thumbnail.name;
if (MeshUtility.Validators.NameValidator.IsFileNameLengthTooLong(thumbnailName))
if (NameValidator.IsFileNameLengthTooLong(thumbnailName))
{
yield return Validation.Error(MeshUtility.Validators.NameValidator.ValidationMessages.FILENAME_TOO_LONG.Msg() + thumbnailName);
yield return Validation.Error(NameValidator.ValidationMessages.FILENAME_TOO_LONG.Msg() + thumbnailName);
}
}
}

View File

@@ -2,9 +2,9 @@
using System.IO;
using System.Linq;
using System.Reflection;
using MeshUtility.M17N;
using UnityEditor;
using UnityEngine;
using UniGLTF;
namespace VRM
{
@@ -29,7 +29,7 @@ namespace VRM
}
Tabs _tab;
MeshUtility.ExporterDialogState m_state;
ExporterDialogState m_state;
VRMExportSettings m_settings;
VRMExportMeshes m_meshes;
@@ -73,7 +73,7 @@ namespace VRM
m_meshes = ScriptableObject.CreateInstance<VRMExportMeshes>();
m_meshesInspector = Editor.CreateEditor(m_meshes);
m_state = new MeshUtility.ExporterDialogState();
m_state = new ExporterDialogState();
m_state.ExportRootChanged += (root) =>
{
// update meta
@@ -151,13 +151,13 @@ namespace VRM
}
private Vector2 m_ScrollPosition;
IEnumerable<MeshUtility.Validator> ValidatorFactory()
IEnumerable<Validator> ValidatorFactory()
{
HumanoidValidator.MeshInformations = m_meshes.Meshes;
HumanoidValidator.EnableFreeze = m_settings.PoseFreeze;
VRMExporterValidator.ReduceBlendshape = m_settings.ReduceBlendshape;
yield return MeshUtility.Validators.HierarchyValidator.Validate;
yield return HierarchyValidator.Validate;
if (!m_state.ExportRoot)
{
yield break;
@@ -198,7 +198,7 @@ namespace VRM
EditorGUIUtility.labelWidth = 150;
// lang
MeshUtility.M17N.Getter.OnGuiSelectLang();
Getter.OnGuiSelectLang();
EditorGUILayout.LabelField("ExportRoot");
{
@@ -253,7 +253,7 @@ namespace VRM
foreach (var v in m_state.Validations)
{
v.DrawGUI();
if (v.ErrorLevel == MeshUtility.ErrorLevels.Critical)
if (v.ErrorLevel == ErrorLevels.Critical)
{
// Export UI を表示しない
return false;
@@ -270,7 +270,7 @@ namespace VRM
switch (meshInfo.VertexColor)
{
case UniGLTF.MeshExportInfo.VertexColorState.ExistsAndMixed:
MeshUtility.Validation.Warning($"{meshInfo.Renderer}: Both vcolor.multiply and not multiply unlit materials exist").DrawGUI();
Validation.Warning($"{meshInfo.Renderer}: Both vcolor.multiply and not multiply unlit materials exist").DrawGUI();
break;
}
}

View File

@@ -85,7 +85,7 @@ namespace VRM
var editor = new VRMEditorImporterContext(context, prefabPath);
foreach (var (key, textureInfo) in new VRMMaterialImporter(context.VRM).EnumerateAllTexturesDistinct(parser))
{
TextureImporterConfigurator.Configure(textureInfo, map.ToDictionary(x => x.name, x => x.texture as Texture2D));
VRMShaders.TextureImporterConfigurator.Configure(textureInfo, map.ToDictionary(x => x.name, x => x.texture as Texture2D));
}
context.Load();
editor.SaveAsAsset();

View File

@@ -62,7 +62,7 @@ namespace VRM
var editor = new VRMEditorImporterContext(context, prefabPath);
foreach (var (key, textureInfo) in new VRMMaterialImporter(context.VRM).EnumerateAllTexturesDistinct(parser))
{
TextureImporterConfigurator.Configure(textureInfo, map.ToDictionary(x => x.name, x => x.texture as Texture2D));
VRMShaders.TextureImporterConfigurator.Configure(textureInfo, map.ToDictionary(x => x.name, x => x.texture as Texture2D));
}
context.Load();
editor.SaveAsAsset();

View File

@@ -1,7 +1,7 @@
using UnityEditor;
using UnityEngine;
using MeshUtility.M17N;
using System.IO;
using UniGLTF;
namespace VRM
{
@@ -55,12 +55,12 @@ namespace VRM
static string RequiredMessage(string name)
{
switch (MeshUtility.M17N.Getter.Lang)
switch (Getter.Lang)
{
case MeshUtility.M17N.Languages.ja:
case Languages.ja:
return $"必須項目。{name} を入力してください";
case MeshUtility.M17N.Languages.en:
case Languages.en:
return $"{name} is required";
default:
@@ -162,7 +162,7 @@ namespace VRM
static string Msg(MessageKeys key)
{
return MeshUtility.M17N.Getter.Msg(key);
return Getter.Msg(key);
}
bool m_foldoutInfo = true;

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using MeshUtility;
using UniGLTF;
using UnityEngine;
namespace VRM

View File

@@ -2,14 +2,14 @@ using UnityEngine;
using UnityEditor;
using System.Linq;
namespace UniVRM10
namespace VRM
{
public static class VrmInfo
{
const string KEY_STOP_VRMASSETPOSTPROCESSOR = "StopVrmAssetPostProcessor";
const string ASSETPOSTPROCESSOR_STOP_SYMBOL = "VRM_STOP_ASSETPOSTPROCESSOR";
[PreferenceItem("UniVRM")]
[PreferenceItem("VRM0")]
private static void OnPreferenceGUI()
{
EditorGUI.BeginChangeCheck();

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 470e88d5a064e7b4f829ab5fa8449d6e
guid: e5b8946e673f54a47bc28160002646b0
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
using System.Collections.Generic;
using MeshUtility;
using UniGLTF;
using UnityEngine;

View File

@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using MeshUtility;
using UniGLTF;
using UnityEngine;

View File

@@ -1,6 +1,7 @@
using NUnit.Framework;
using System.Linq;
using System.IO;
using UniGLTF;
namespace VRM
{
@@ -14,7 +15,7 @@ namespace VRM
[TestCase("AliciaAliciaAliciaAliciaAliciaAliciaAliciaAliciaAliciaAliciaAliciaAlicia", true)]
public void DetectFileNameLength(string fileName, bool isIllegal)
{
var result = MeshUtility.Validators.NameValidator.IsFileNameLengthTooLong(fileName);
var result = NameValidator.IsFileNameLengthTooLong(fileName);
Assert.AreEqual(result, isIllegal);
}

View File

@@ -101,7 +101,7 @@ namespace UniVRM10
// settings TextureImporters
foreach (var (key, textureInfo) in Vrm10MaterialImporter.EnumerateAllTexturesDistinct(parser))
{
TextureImporterConfigurator.Configure(textureInfo, loader.TextureFactory.ExternalMap);
VRMShaders.TextureImporterConfigurator.Configure(textureInfo, loader.TextureFactory.ExternalMap);
}
loader.Load();

View File

@@ -1,6 +1,6 @@
using UnityEditor;
using UnityEngine;
using MeshUtility.M17N;
using UniGLTF;
namespace UniVRM10
{
@@ -39,7 +39,7 @@ namespace UniVRM10
depth = iterator.depth;
// using (new EditorGUI.DisabledScope("m_Script" == iterator.propertyPath))
EditorGUILayout.PropertyField(iterator, true);
EditorGUILayout.PropertyField(iterator, true);
}
}
else
@@ -82,12 +82,12 @@ namespace UniVRM10
static string RequiredMessage(string name)
{
switch (MeshUtility.M17N.Getter.Lang)
switch (Getter.Lang)
{
case MeshUtility.M17N.Languages.ja:
case Languages.ja:
return $"必須項目。{name} を入力してください";
case MeshUtility.M17N.Languages.en:
case Languages.en:
return $"{name} is required";
default:
@@ -184,7 +184,7 @@ namespace UniVRM10
static string Msg(MessageKeys key)
{
return MeshUtility.M17N.Getter.Msg(key);
return Getter.Msg(key);
}
bool m_foldoutInfo = true;

View File

@@ -32,7 +32,7 @@ namespace UniVRM10
}
Tabs _tab;
MeshUtility.ExporterDialogState m_state;
ExporterDialogState m_state;
VRM10MetaObject m_meta;
VRM10MetaObject Meta
@@ -72,7 +72,7 @@ namespace UniVRM10
m_tmpMeta = ScriptableObject.CreateInstance<VRM10MetaObject>();
m_tmpMeta.Authors = new List<string> { "" };
m_state = new MeshUtility.ExporterDialogState();
m_state = new ExporterDialogState();
m_state.ExportRootChanged += (root) =>
{
// update meta
@@ -130,9 +130,9 @@ namespace UniVRM10
}
private Vector2 m_ScrollPosition;
IEnumerable<MeshUtility.Validator> ValidatorFactory()
IEnumerable<Validator> ValidatorFactory()
{
yield return MeshUtility.Validators.HierarchyValidator.Validate;
yield return HierarchyValidator.Validate;
if (!m_state.ExportRoot)
{
yield break;
@@ -173,7 +173,7 @@ namespace UniVRM10
EditorGUIUtility.labelWidth = 150;
// lang
MeshUtility.M17N.Getter.OnGuiSelectLang();
Getter.OnGuiSelectLang();
EditorGUILayout.LabelField("ExportRoot");
{
@@ -228,7 +228,7 @@ namespace UniVRM10
foreach (var v in m_state.Validations)
{
v.DrawGUI();
if (v.ErrorLevel == MeshUtility.ErrorLevels.Critical)
if (v.ErrorLevel == ErrorLevels.Critical)
{
// Export UI を表示しない
return false;

View File

@@ -2,16 +2,16 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using VRMShaders;
namespace UniGLTF
namespace VRMShaders
{
public static class TextureImporterConfigurator
{
public static void ConfigureSize(Texture2D texture)
{
var path = UnityPath.FromAsset(texture);
if (AssetImporter.GetAtPath(path.Value) is TextureImporter textureImporter)
var path = AssetDatabase.GetAssetPath(texture);
if (AssetImporter.GetAtPath(path) is TextureImporter textureImporter)
{
var maxSize = Mathf.Max(texture.width, texture.height);
textureImporter.maxTextureSize
@@ -30,8 +30,8 @@ namespace UniGLTF
public static void ConfigureNormalMap(Texture2D texture)
{
var path = UnityPath.FromAsset(texture);
if (AssetImporter.GetAtPath(path.Value) is TextureImporter textureImporter)
var path = AssetDatabase.GetAssetPath(texture);
if (AssetImporter.GetAtPath(path) is TextureImporter textureImporter)
{
#if VRM_DEVELOP
Debug.Log($"{path} => normalmap");
@@ -47,8 +47,8 @@ namespace UniGLTF
public static void ConfigureLinear(Texture2D texture)
{
var path = UnityPath.FromAsset(texture);
if (AssetImporter.GetAtPath(path.Value) is TextureImporter textureImporter)
var path = AssetDatabase.GetAssetPath(texture);
if (AssetImporter.GetAtPath(path) is TextureImporter textureImporter)
{
#if VRM_DEVELOP
Debug.Log($"{path} => linear");

View File

@@ -1,2 +1 @@
m_EditorVersion: 2019.4.24f1
m_EditorVersionWithRevision: 2019.4.24f1 (5da6f0345e82)
m_EditorVersion: 2018.4.27f1