feat: add project settings

pull/336/head
mob-sakai 2024-09-30 01:10:58 +09:00
parent 8c1bef4373
commit 20b9085ca1
4 changed files with 55 additions and 3 deletions

View File

@ -732,7 +732,7 @@ namespace Coffee.UIExtensions
_bakeCamera.useOcclusionCulling = false;
_bakeCamera.gameObject.SetActive(false);
_bakeCamera.gameObject.hideFlags = HideFlags.HideAndDontSave;
_bakeCamera.gameObject.hideFlags = UIParticleProjectSettings.globalHideFlags;
return _bakeCamera;
}

View File

@ -0,0 +1,40 @@
#pragma warning disable CS0414
using Coffee.UIParticleInternal;
using UnityEditor;
using UnityEngine;
namespace Coffee.UIExtensions
{
public class UIParticleProjectSettings : PreloadedProjectSettings<UIParticleProjectSettings>
{
[Header("Setting")]
[SerializeField]
internal bool m_EnableLinearToGamma = true;
public static bool enableLinearToGamma
{
get => instance.m_EnableLinearToGamma;
set => instance.m_EnableLinearToGamma = value;
}
[Header("Editor")]
[Tooltip("Hide the automatically generated objects.\n" +
" - UIParticleRenderer\n" +
" - UIParticle BakingCamera")]
[SerializeField]
private bool m_HideGeneratedObjects = true;
public static HideFlags globalHideFlags => instance.m_HideGeneratedObjects
? HideFlags.DontSave | HideFlags.NotEditable | HideFlags.HideInHierarchy | HideFlags.HideInInspector
: HideFlags.DontSave | HideFlags.NotEditable;
#if UNITY_EDITOR
[SettingsProvider]
private static SettingsProvider CreateSettingsProvider()
{
return new PreloadedProjectSettingsProvider("Project/UI/UI Particle");
}
#endif
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f22a23b9d98e440478697f4adf30e61c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -137,6 +137,7 @@ namespace Coffee.UIExtensions
{
base.OnEnable();
hideFlags = UIParticleProjectSettings.globalHideFlags;
if (!s_CombineInstances[0].mesh)
{
s_CombineInstances[0].mesh = new Mesh
@ -161,7 +162,7 @@ namespace Coffee.UIExtensions
// Create renderer object.
var go = new GameObject("[generated] UIParticleRenderer", typeof(UIParticleRenderer))
{
hideFlags = HideFlags.HideAndDontSave,
hideFlags = UIParticleProjectSettings.globalHideFlags,
layer = parent.gameObject.layer
};
@ -416,7 +417,7 @@ namespace Coffee.UIExtensions
_lastBounds = bounds;
// Convert linear color to gamma color.
if (canvas.ShouldGammaToLinearInMesh())
if (UIParticleProjectSettings.enableLinearToGamma && canvas.ShouldGammaToLinearInMesh())
{
workerMesh.LinearToGamma();
}