미리보기 이미지 백그라운드 함수 수정

This commit is contained in:
2025-09-29 17:47:59 +09:00
parent 21ce7b6c05
commit 82530c106c
16 changed files with 143 additions and 23 deletions

View File

@@ -722,6 +722,7 @@ GameObject:
- component: {fileID: 1015090130}
- component: {fileID: 1015090129}
- component: {fileID: 1015090128}
- component: {fileID: 1015090131}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
@@ -803,6 +804,50 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1015090131
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1015090127}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_RenderShadows: 1
m_RequiresDepthTextureOption: 2
m_RequiresOpaqueTextureOption: 2
m_CameraType: 0
m_Cameras: []
m_RendererIndex: -1
m_VolumeLayerMask:
serializedVersion: 2
m_Bits: 1
m_VolumeTrigger: {fileID: 0}
m_VolumeFrameworkUpdateModeOption: 2
m_RenderPostProcessing: 0
m_Antialiasing: 0
m_AntialiasingQuality: 2
m_StopNaN: 0
m_Dithering: 0
m_ClearDepth: 1
m_AllowXRRendering: 1
m_AllowHDROutput: 1
m_UseScreenCoordOverride: 0
m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0}
m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0}
m_RequiresDepthTexture: 0
m_RequiresColorTexture: 0
m_Version: 2
m_TaaSettings:
m_Quality: 3
m_FrameInfluence: 0.1
m_JitterScale: 1
m_MipBias: 0
m_VarianceClampScale: 0.9
m_ContrastAdaptiveSharpening: 0
--- !u!1 &1081897209
GameObject:
m_ObjectHideFlags: 0

View File

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

View File

@@ -0,0 +1,6 @@
using UnityEngine;
public interface IBackgroundStrategy
{
void ConfigCamera(Camera camera);
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c15031ea0953ab146b9329a0f91a505f

View File

@@ -23,7 +23,10 @@ public class AssetDataManager : MonoBehaviour
{
if (asset.thumbnail == null && asset.prefabToPlace != null)
{
asset.thumbnail = ThumbnailGenerator.Generate(asset.prefabToPlace, 256, 256);
//IBackgroundStrategy backgroundStrategy = new SolidBgStrategy(Color.white);
IBackgroundStrategy backgroundStrategy = new TransparentBgStrategy();
ThumbnailGenerator thumbnailGenerator = new ThumbnailGenerator(backgroundStrategy);
asset.thumbnail = thumbnailGenerator.Generate(asset.prefabToPlace, 256, 256);
}
}
}

View File

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

View File

@@ -0,0 +1,17 @@
using UnityEngine;
public class SolidBgStrategy : IBackgroundStrategy
{
private readonly Color _backgroundColor;
public SolidBgStrategy(Color backgroundColor)
{
_backgroundColor = backgroundColor;
}
public void ConfigCamera(Camera camera)
{
camera.clearFlags = CameraClearFlags.SolidColor;
camera.backgroundColor = _backgroundColor;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b1c08fc71a494bf4f9aa3d8df11bb88f

View File

@@ -0,0 +1,10 @@
using UnityEngine;
public class TransparentBgStrategy : IBackgroundStrategy
{
public void ConfigCamera(Camera camera)
{
camera.clearFlags = CameraClearFlags.SolidColor;
camera.backgroundColor = Color.clear;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 97f341e95cdecf644b618e08c05d1b36

View File

@@ -1,10 +1,16 @@
using UnityEngine;
public static class ThumbnailGenerator
public class ThumbnailGenerator
{
private static Vector3 offScreenPosition = new Vector3(-1000f, -1000f, -1000f);
private readonly IBackgroundStrategy backgroundStrategy;
private static readonly Vector3 offScreenPosition = new Vector3(-1000f, -1000f, -1000f);
public static Texture2D Generate(GameObject prefab, int width, int height)
public ThumbnailGenerator(IBackgroundStrategy _backgroundStrategy)
{
backgroundStrategy = _backgroundStrategy;
}
public Texture2D Generate(GameObject prefab, int width, int height)
{
if (prefab == null)
{
@@ -22,8 +28,7 @@ public static class ThumbnailGenerator
Camera camera = new GameObject("ThumbnailCamera").AddComponent<Camera>();
camera.transform.SetParent(studio.transform);
camera.clearFlags = CameraClearFlags.SolidColor;
camera.backgroundColor = Color.white;
backgroundStrategy.ConfigCamera(camera);
camera.cullingMask = 1 << prefab.layer;
GameObject instance = Object.Instantiate(prefab, studio.transform);

BIN
PE_250929_ver2.unitypackage Normal file

Binary file not shown.

View File

@@ -43,5 +43,15 @@
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.wind": "1.0.0",
"com.unity.modules.xr": "1.0.0"
},
"scopedRegistries": [
{
"name": "Shtif Registry",
"url": "http://package.binaryego.com:4873",
"scopes": [
"com.shtif"
],
"overrideBuiltIns": false
}
]
}

View File

@@ -12,11 +12,13 @@ MonoBehaviour:
m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0}
m_Name:
m_EditorClassIdentifier:
m_EnablePreviewPackages: 0
m_EnablePackageDependencies: 0
m_EnablePreReleasePackages: 0
m_AdvancedSettingsExpanded: 1
m_ScopedRegistriesSettingsExpanded: 1
m_SeeAllPackageVersions: 0
m_DismissPreviewPackagesInUse: 0
oneTimeWarningShown: 0
oneTimeDeprecatedPopUpShown: 0
m_Registries:
- m_Id: main
m_Name:
@@ -24,20 +26,20 @@ MonoBehaviour:
m_Scopes: []
m_IsDefault: 1
m_Capabilities: 7
m_UserSelectedRegistryName:
m_UserAddingNewScopedRegistry: 0
m_RegistryInfoDraft:
m_ErrorMessage:
m_Original:
m_Id:
m_Name:
m_Url:
m_Scopes: []
m_ConfigSource: 0
- m_Id: scoped:project:Shtif Registry
m_Name: Shtif Registry
m_Url: http://package.binaryego.com:4873
m_Scopes:
- com.shtif
m_IsDefault: 0
m_Capabilities: 0
m_ConfigSource: 4
m_UserSelectedRegistryName: Shtif Registry
m_UserAddingNewScopedRegistry: 0
m_RegistryInfoDraft:
m_Modified: 0
m_Name:
m_Url:
m_Scopes:
-
m_SelectedScopeIndex: 0
m_ErrorMessage:
m_UserModificationsInstanceId: -866
m_OriginalInstanceId: -868
m_LoadAssets: 0