mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-28 22:04:56 -05:00
UNIGLTF_IO_AXIS
This commit is contained in:
@@ -30,6 +30,7 @@ namespace UniGLTF
|
||||
protected override void Initialize()
|
||||
{
|
||||
m_settings = ScriptableObject.CreateInstance<GltfExportSettings>();
|
||||
m_settings.InverseAxis = UniGLTFPreference.GltfIOAxis;
|
||||
m_settingsInspector = Editor.CreateEditor(m_settings);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
using UnityEditor.AssetImporters;
|
||||
#else
|
||||
@@ -13,10 +13,16 @@ namespace UniGLTF
|
||||
public class GlbScriptedImporter : ScriptedImporter
|
||||
{
|
||||
[SerializeField]
|
||||
Axises m_reverseAxis = default;
|
||||
Axises m_reverseAxis;
|
||||
|
||||
public override void OnImportAsset(AssetImportContext ctx)
|
||||
{
|
||||
var asset = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(ctx.assetPath);
|
||||
if (asset == null)
|
||||
{
|
||||
// first time. set default setting
|
||||
m_reverseAxis = UniGLTFPreference.GltfIOAxis;
|
||||
}
|
||||
ScriptedImporterImpl.Import(this, ctx, m_reverseAxis);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
using UnityEditor.AssetImporters;
|
||||
#else
|
||||
@@ -17,6 +17,12 @@ namespace UniGLTF
|
||||
|
||||
public override void OnImportAsset(AssetImportContext ctx)
|
||||
{
|
||||
var asset = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(ctx.assetPath);
|
||||
if (asset == null)
|
||||
{
|
||||
// first time. set default setting
|
||||
m_reverseAxis = UniGLTFPreference.GltfIOAxis;
|
||||
}
|
||||
ScriptedImporterImpl.Import(this, ctx, m_reverseAxis);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Linq;
|
||||
using System;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
@@ -13,13 +14,42 @@ namespace UniGLTF
|
||||
|
||||
// language
|
||||
M17N.LanguageGetter.OnGuiSelectLang();
|
||||
EditorGUILayout.HelpBox($"UniGLTF, UniVRM custom editor language setting", MessageType.Info, true);
|
||||
EditorGUILayout.HelpBox($"Custom editor language setting", MessageType.Info, true);
|
||||
|
||||
// default axis
|
||||
GltfIOAxis = (Axises)EditorGUILayout.EnumPopup("Default Invert axis", GltfIOAxis);
|
||||
EditorGUILayout.HelpBox($"Default invert axis when glb/gltf import/export", MessageType.Info, true);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
const string AXIS_KEY = "UNIGLTF_IO_AXIS";
|
||||
static Axises? s_axis;
|
||||
public static Axises GltfIOAxis
|
||||
{
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetString(AXIS_KEY, value.ToString());
|
||||
s_axis = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (!s_axis.HasValue)
|
||||
{
|
||||
var value = EditorPrefs.GetString(AXIS_KEY, default(Axises).ToString());
|
||||
if (Enum.TryParse<Axises>(value, out Axises parsed))
|
||||
{
|
||||
s_axis = parsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_axis = default(Axises);
|
||||
}
|
||||
}
|
||||
return s_axis.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user