mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-10-01 23:32:18 -05:00
Merge pull request #867 from Santarh/recommendedProjectSettingsWindow
"Recommended settings" window
This commit is contained in:
3
Assets/UniGLTF/Editor/EditorSettingsValidator.meta
Normal file
3
Assets/UniGLTF/Editor/EditorSettingsValidator.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 133086fc7a3249648756fc81cba2b2d9
|
||||
timeCreated: 1618226507
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace UniGLTF.EditorSettingsValidator
|
||||
{
|
||||
public interface IUnitySettingsValidator
|
||||
{
|
||||
bool IsValid { get; }
|
||||
string HeaderDescription { get; }
|
||||
string CurrentValueDescription { get; }
|
||||
string RecommendedValueDescription { get; }
|
||||
void Validate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13575306b7614de68d6a391a4e0617bc
|
||||
timeCreated: 1618227606
|
||||
47
Assets/UniGLTF/Editor/EditorSettingsValidator/Messages.cs
Normal file
47
Assets/UniGLTF/Editor/EditorSettingsValidator/Messages.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using MeshUtility.M17N;
|
||||
|
||||
namespace UniGLTF.EditorSettingsValidator
|
||||
{
|
||||
public enum Messages
|
||||
{
|
||||
[LangMsg(Languages.en, "Color space")]
|
||||
[LangMsg(Languages.ja, "Color space")]
|
||||
ColorSpace,
|
||||
|
||||
[LangMsg(Languages.en, "Gamma")]
|
||||
[LangMsg(Languages.ja, "Gamma")]
|
||||
ColorSpaceGamma,
|
||||
|
||||
[LangMsg(Languages.en, "Linear")]
|
||||
[LangMsg(Languages.ja, "Linear")]
|
||||
ColorSpaceLinear,
|
||||
|
||||
[LangMsg(Languages.en, "You can close this window.")]
|
||||
[LangMsg(Languages.ja, "You can close this window.")]
|
||||
YouCanCloseThisWindow,
|
||||
|
||||
[LangMsg(Languages.en, "Thank you!")]
|
||||
[LangMsg(Languages.ja, "Thank you!")]
|
||||
ThankYou,
|
||||
|
||||
[LangMsg(Languages.en, "Close")]
|
||||
[LangMsg(Languages.ja, "Close")]
|
||||
CloseWindowButton,
|
||||
|
||||
[LangMsg(Languages.en, "Recommended project settings for UniGLTF/UniVRM")]
|
||||
[LangMsg(Languages.ja, "Recommended project settings for UniGLTF/UniVRM")]
|
||||
RecommendedProjectSettingsForUniGltfAndUniVrm,
|
||||
|
||||
[LangMsg(Languages.en, "current")]
|
||||
[LangMsg(Languages.ja, "current")]
|
||||
CurrentValue,
|
||||
|
||||
[LangMsg(Languages.en, "Use recommended")]
|
||||
[LangMsg(Languages.ja, "Use recommended")]
|
||||
UseRecommended,
|
||||
|
||||
[LangMsg(Languages.en, "Accept All")]
|
||||
[LangMsg(Languages.ja, "Accept All")]
|
||||
AcceptAllButton,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fb7fb2dae3f440986a9ffbea333b902
|
||||
timeCreated: 1618229489
|
||||
@@ -0,0 +1,19 @@
|
||||
using MeshUtility.M17N;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UniGLTF.EditorSettingsValidator
|
||||
{
|
||||
public sealed class UnityColorSpaceSettingsValidator : IUnitySettingsValidator
|
||||
{
|
||||
public bool IsValid => PlayerSettings.colorSpace == UnityEngine.ColorSpace.Linear;
|
||||
public string HeaderDescription => Messages.ColorSpace.Msg();
|
||||
public string CurrentValueDescription => PlayerSettings.colorSpace == UnityEngine.ColorSpace.Linear
|
||||
? Messages.ColorSpaceLinear.Msg() : Messages.ColorSpaceGamma.Msg();
|
||||
public string RecommendedValueDescription => Messages.ColorSpaceLinear.Msg();
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
PlayerSettings.colorSpace = UnityEngine.ColorSpace.Linear;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 557eabb6ad494c2ea3b644fd0c7d6b1b
|
||||
timeCreated: 1618228567
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace UniGLTF.EditorSettingsValidator
|
||||
{
|
||||
public sealed class UnityEditorSettingsValidator
|
||||
{
|
||||
public IEnumerable<IUnitySettingsValidator> Validators { get; } = new List<IUnitySettingsValidator>
|
||||
{
|
||||
new UnityColorSpaceSettingsValidator(),
|
||||
};
|
||||
|
||||
public bool IsValid()
|
||||
{
|
||||
return Validators.All(validator => validator.IsValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce6737b0aab046408f7eff4c40d957f4
|
||||
timeCreated: 1618226473
|
||||
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using MeshUtility.M17N;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniGLTF.EditorSettingsValidator
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public sealed class UnityEditorSettingsValidatorWindow : EditorWindow
|
||||
{
|
||||
private static readonly UnityEditorSettingsValidator Validator = new UnityEditorSettingsValidator();
|
||||
|
||||
static UnityEditorSettingsValidatorWindow()
|
||||
{
|
||||
EditorApplication.update += Validate;
|
||||
}
|
||||
|
||||
private static void Validate()
|
||||
{
|
||||
if (!Validator.IsValid())
|
||||
{
|
||||
var window = GetWindow<UnityEditorSettingsValidatorWindow>(utility: true);
|
||||
window.minSize = new Vector2(320, 300);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnProjectChange()
|
||||
{
|
||||
Validate();
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (Validator.IsValid())
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
GUILayout.Label(Messages.ThankYou.Msg(), new GUIStyle(EditorStyles.boldLabel)
|
||||
{
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
fontSize = 20,
|
||||
});
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
GUILayout.BeginVertical(GUI.skin.box);
|
||||
GUILayout.Label(Messages.YouCanCloseThisWindow.Msg());
|
||||
if (GUILayout.Button(Messages.CloseWindowButton.Msg()))
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.BeginVertical(GUI.skin.box);
|
||||
GUILayout.Space(5);
|
||||
GUILayout.Label(Messages.RecommendedProjectSettingsForUniGltfAndUniVrm.Msg());
|
||||
GUILayout.Space(5);
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
foreach (var validator in Validator.Validators)
|
||||
{
|
||||
GUILayout.Label($"{validator.HeaderDescription} ({Messages.CurrentValue.Msg()} = {validator.CurrentValueDescription})");
|
||||
var oldEnabled = GUI.enabled;
|
||||
GUI.enabled = !validator.IsValid;
|
||||
if (GUILayout.Button($"{Messages.UseRecommended.Msg()} {validator.RecommendedValueDescription}"))
|
||||
{
|
||||
validator.Validate();
|
||||
}
|
||||
|
||||
GUI.enabled = oldEnabled;
|
||||
|
||||
GUILayout.Space(5);
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
GUILayout.BeginVertical(GUI.skin.box);
|
||||
if (GUILayout.Button(Messages.AcceptAllButton.Msg()))
|
||||
{
|
||||
foreach (var validator in Validator.Validators)
|
||||
{
|
||||
if (!validator.IsValid)
|
||||
{
|
||||
validator.Validate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47aff4cc4cb74492a0ccd640868df48d
|
||||
timeCreated: 1618226577
|
||||
Reference in New Issue
Block a user