From 8e0ff10c7344d9f53d2f4f096ddeb7392b67f930 Mon Sep 17 00:00:00 2001 From: mob-sakai <12690315+mob-sakai@users.noreply.github.com> Date: Thu, 25 Jun 2026 12:58:14 +0900 Subject: [PATCH] feat: project-wide default view size for baking close #360 --- Packages/src/Editor/UIParticleEditor.cs | 23 +++++++++++++------ Packages/src/README.md | 3 ++- Packages/src/Runtime/UIParticle.cs | 11 +++++++-- .../src/Runtime/UIParticleProjectSettings.cs | 19 +++++++++++++++ 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/Packages/src/Editor/UIParticleEditor.cs b/Packages/src/Editor/UIParticleEditor.cs index 815a8c6..14e0162 100644 --- a/Packages/src/Editor/UIParticleEditor.cs +++ b/Packages/src/Editor/UIParticleEditor.cs @@ -49,6 +49,7 @@ namespace Coffee.UIExtensions private static readonly GUIContent s_ContentRandom = new GUIContent("Random"); private static readonly GUIContent s_ContentScale = new GUIContent("Scale"); private static readonly GUIContent s_ContentPrimary = new GUIContent("Primary"); + private static readonly GUIContent s_ViewSize = new GUIContent("View Size"); private static readonly Regex s_RegexBuiltInGuid = new Regex(@"^0{16}.0{15}$", RegexOptions.Compiled); private static readonly List s_TempMaterials = new List(); @@ -246,16 +247,24 @@ namespace Coffee.UIExtensions // Custom View Size EditorGUILayout.PropertyField(_useCustomView); - EditorGUI.BeginChangeCheck(); - EditorGUI.BeginDisabledGroup(!_useCustomView.boolValue); EditorGUI.indentLevel++; - EditorGUILayout.PropertyField(_customViewSize); - EditorGUI.indentLevel--; - EditorGUI.EndDisabledGroup(); - if (EditorGUI.EndChangeCheck()) + if (_useCustomView.boolValue) { - _customViewSize.floatValue = Mathf.Max(0.1f, _customViewSize.floatValue); + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(_customViewSize); + if (EditorGUI.EndChangeCheck()) + { + _customViewSize.floatValue = Mathf.Max(0.1f, _customViewSize.floatValue); + } } + else + { + EditorGUI.BeginDisabledGroup(!_useCustomView.boolValue); + EditorGUILayout.FloatField(s_ViewSize, UIParticleProjectSettings.defaultViewSizeForBaking); + EditorGUI.EndDisabledGroup(); + } + + EditorGUI.indentLevel--; // Time Scale Multiplier EditorGUILayout.PropertyField(_timeScaleMultiplier); diff --git a/Packages/src/README.md b/Packages/src/README.md index 7825e4f..76766be 100644 --- a/Packages/src/README.md +++ b/Packages/src/README.md @@ -282,11 +282,12 @@ uiParticle.Stop(); You can adjust the project-wide settings for `UI Particle`. (`Edit > Project Settings > UI > UI Particle`) -![](https://github.com/mob-sakai/mob-sakai/releases/download/docs/1782270746550.png) +![](https://github.com/mob-sakai/mob-sakai/releases/download/docs/1782360274340.png) #### Settings - **Enable Linear To Gamma**: Automatically correct the color space of the mesh. +- **Default View Size For Baking**: Default view size for baking particle systems. #### Editor diff --git a/Packages/src/Runtime/UIParticle.cs b/Packages/src/Runtime/UIParticle.cs index 27a29a8..01d11f0 100644 --- a/Packages/src/Runtime/UIParticle.cs +++ b/Packages/src/Runtime/UIParticle.cs @@ -263,6 +263,13 @@ namespace Coffee.UIExtensions set => m_CustomViewSize = Mathf.Max(0.1f, value); } + /// + /// View size for Baking. + /// + public float viewSizeForBaking => useCustomView + ? m_CustomViewSize + : UIParticleProjectSettings.defaultViewSizeForBaking; + /// /// Time scale multiplier. /// @@ -718,7 +725,7 @@ namespace Coffee.UIExtensions if (_bakeCamera != null) { - _bakeCamera.orthographicSize = useCustomView ? customViewSize : 10; + _bakeCamera.orthographicSize = viewSizeForBaking; return _bakeCamera; } @@ -745,7 +752,7 @@ namespace Coffee.UIExtensions // Setup baking camera. _bakeCamera.enabled = false; - _bakeCamera.orthographicSize = useCustomView ? customViewSize : 10; + _bakeCamera.orthographicSize = viewSizeForBaking; _bakeCamera.transform.SetPositionAndRotation(new Vector3(0, 0, -1000), Quaternion.identity); _bakeCamera.orthographic = true; _bakeCamera.farClipPlane = 2000f; diff --git a/Packages/src/Runtime/UIParticleProjectSettings.cs b/Packages/src/Runtime/UIParticleProjectSettings.cs index 3b61337..48b84bc 100644 --- a/Packages/src/Runtime/UIParticleProjectSettings.cs +++ b/Packages/src/Runtime/UIParticleProjectSettings.cs @@ -20,6 +20,15 @@ namespace Coffee.UIExtensions set => instance.m_AutoColorCorrection = value; } + [SerializeField] + [Tooltip("Default view size for baking particle systems.")] + private float m_DefaultViewSizeForBaking = 10; + + public static float defaultViewSizeForBaking + { + get => instance.m_DefaultViewSizeForBaking; + set => instance.m_DefaultViewSizeForBaking = value; + } [Header("Editor")] [Tooltip("Hide the automatically generated objects.\n" + @@ -44,6 +53,16 @@ namespace Coffee.UIExtensions { return new PreloadedProjectSettingsProvider("Project/UI/UI Particle"); } + + [CustomEditor(typeof(UIParticleProjectSettings))] + private class UIParticleProjectSettingsEditor : Editor + { + public override void OnInspectorGUI() + { + EditorGUIUtility.labelWidth = 180; + base.OnInspectorGUI(); + } + } #endif } }