From 12641500fe080b74a44c4ab5d29460b16a8e0336 Mon Sep 17 00:00:00 2001 From: amamagi Date: Mon, 7 Apr 2025 14:01:13 +0900 Subject: [PATCH 1/5] add capture feature to MToon10Showcase --- .../MToon10Showcase/MToon10Showcase.unity | 146 ++++++++++++++++++ .../Runtime/MToon10ShowcaseEntryPoint.cs | 64 +++++--- .../MToon10Showcase/Runtime/TopDownCapture.cs | 40 +++++ .../Runtime/TopDownCapture.cs.meta | 3 + 4 files changed, 232 insertions(+), 21 deletions(-) create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Runtime/TopDownCapture.cs create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Runtime/TopDownCapture.cs.meta diff --git a/Assets/VRM10_Samples/MToon10Showcase/MToon10Showcase.unity b/Assets/VRM10_Samples/MToon10Showcase/MToon10Showcase.unity index a7b24c366..1dbc55aa3 100644 --- a/Assets/VRM10_Samples/MToon10Showcase/MToon10Showcase.unity +++ b/Assets/VRM10_Samples/MToon10Showcase/MToon10Showcase.unity @@ -570,6 +570,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: cameraScroller: {fileID: 1644774163} + topDownCapture: {fileID: 1640562119} dependencies: {fileID: 11400000, guid: 21a44348ad7e90744a8e320392d6a0b6, type: 2} alphaModeShowcase: {fileID: 11400000, guid: 9a1685921243e0045902dd01741b2146, type: 2} renderQueueOffsetShowcase: {fileID: 11400000, guid: 029bd96435085fa4fbe25e6c987bf21e, @@ -819,6 +820,150 @@ MonoBehaviour: serializedVersion: 2 m_Bits: 4294967295 m_MaxRayIntersections: 0 +--- !u!1 &1640562115 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1640562118} + - component: {fileID: 1640562117} + - component: {fileID: 1640562116} + - component: {fileID: 1640562119} + m_Layer: 0 + m_Name: TopDownCapture + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1640562116 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1640562115} + 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!20 &1640562117 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1640562115} + m_Enabled: 0 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1640562118 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1640562115} + serializedVersion: 2 + m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} +--- !u!114 &1640562119 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1640562115} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e55e85e81e284c6894f606adcf7ddc56, type: 3} + m_Name: + m_EditorClassIdentifier: + _camera: {fileID: 1640562117} + _renderTarget: {fileID: 0} + _screenshot: {fileID: 0} --- !u!1 &1644774162 GameObject: m_ObjectHideFlags: 0 @@ -978,3 +1123,4 @@ SceneRoots: - {fileID: 867928055} - {fileID: 1948350611} - {fileID: 1644774167} + - {fileID: 1640562118} diff --git a/Assets/VRM10_Samples/MToon10Showcase/Runtime/MToon10ShowcaseEntryPoint.cs b/Assets/VRM10_Samples/MToon10Showcase/Runtime/MToon10ShowcaseEntryPoint.cs index 2f24ab8d7..dc037f868 100644 --- a/Assets/VRM10_Samples/MToon10Showcase/Runtime/MToon10ShowcaseEntryPoint.cs +++ b/Assets/VRM10_Samples/MToon10Showcase/Runtime/MToon10ShowcaseEntryPoint.cs @@ -7,6 +7,7 @@ namespace VRM10.Samples.MToon10Showcase public class MToon10ShowcaseEntryPoint : MonoBehaviour { [SerializeField] private CameraScroller cameraScroller; + [SerializeField] private TopDownCapture topDownCapture; [SerializeField] private MToon10ShowcaseDependencies dependencies; [SerializeField] private AlphaModeShowcase alphaModeShowcase; @@ -28,8 +29,8 @@ namespace VRM10.Samples.MToon10Showcase private static readonly float PrimitiveRadius = 0.3f; private static readonly float PrimitiveSpacing = 0.2f; private static readonly float LabelSpacing = 0.1f; - - private Vector3 _nextOrigin = new(-2.0f, 1.0f, 2.0f); + private static readonly Vector3 InitialOrigin = new(0f, 1.0f, 0f); + private Vector3 _nextOrigin = InitialOrigin; private void Start() { @@ -40,12 +41,13 @@ namespace VRM10.Samples.MToon10Showcase context.AlphaCutoff = entry.alphaCutoff; context.DoubleSidedMode = entry.doubleSidedMode; }); - CreateShowcase(renderQueueOffsetShowcase.entries, renderQueueOffsetShowcase.baseMaterial, (entry, context) => - { - context.AlphaMode = MToon10AlphaMode.Transparent; - context.BaseColorFactorSrgb = entry.litColor; - context.RenderQueueOffsetNumber = entry.renderQueueOffset; - }); + CreateShowcase(renderQueueOffsetShowcase.entries, renderQueueOffsetShowcase.baseMaterial, + (entry, context) => + { + context.AlphaMode = MToon10AlphaMode.Transparent; + context.BaseColorFactorSrgb = entry.litColor; + context.RenderQueueOffsetNumber = entry.renderQueueOffset; + }); CreateShowcase(litShowcase.entries, litShowcase.baseMaterial, (entry, context) => { context.BaseColorFactorSrgb = entry.litColor; @@ -71,10 +73,8 @@ namespace VRM10.Samples.MToon10Showcase context.ShadingShiftTextureScale = entry.shadingShiftTextureScale; context.ShadingShiftTexture = entry.shadingShiftTexture; }, primitiveType: PrimitiveType.Quad); - CreateShowcase(giEqualizationShowcase.entries, giEqualizationShowcase.baseMaterial, (entry, context) => - { - context.GiEqualizationFactor = entry.giEqualizationFactor; - }); + CreateShowcase(giEqualizationShowcase.entries, giEqualizationShowcase.baseMaterial, + (entry, context) => { context.GiEqualizationFactor = entry.giEqualizationFactor; }); CreateShowcase(emissionShowcase.entries, emissionShowcase.baseMaterial, (entry, context) => { context.EmissiveTexture = entry.emissiveTexture; @@ -111,13 +111,31 @@ namespace VRM10.Samples.MToon10Showcase context.UvAnimationScrollYSpeedFactor = entry.uvAnimationScrollYSpeedFactor; context.UvAnimationRotationSpeedFactor = entry.uvAnimationRotationSpeedFactor; }, PrimitiveType.Quad); - - CreateFloor(); - cameraScroller.Initialize(new Vector3(0.0f, 5.0f, 0.0f), new Vector3(0.0f, 5.0f, _nextOrigin.z), 0.5f); + var width = (PrimitiveRadius * 2 + PrimitiveSpacing) * Columns - PrimitiveSpacing; + var bottomLeft = _nextOrigin; + + CreateFloor( + InitialOrigin + new Vector3(width / 2f, -1f, 0.0f), + bottomLeft + new Vector3(width / 2f, -1f, 0.0f), + dependencies.floorPrefab); + + const float cameraHeight = 5f; + + cameraScroller.Initialize( + InitialOrigin + new Vector3(width / 2f, cameraHeight, 0.0f), + bottomLeft + new Vector3(width / 2f, cameraHeight, 0.0f), + 0.5f); + + const float captureSpacing = 0.1f; + + topDownCapture.Capture( + InitialOrigin + new Vector3(-captureSpacing, cameraHeight, 0.0f), + bottomLeft + new Vector3(width + captureSpacing, cameraHeight, 0.0f)); } - private Transform CreateShowcase(T[] entries, Material baseMaterial, Action setup, PrimitiveType primitiveType = PrimitiveType.Sphere) + private Transform CreateShowcase(T[] entries, Material baseMaterial, Action setup, + PrimitiveType primitiveType = PrimitiveType.Sphere) where T : class { const int columnCount = 4; @@ -155,18 +173,22 @@ namespace VRM10.Samples.MToon10Showcase return root.transform; } - private void CreateFloor() + private static GameObject CreateFloor(Vector3 startOrigin, Vector3 endOrigin, GameObject floorPrefab) { + if (startOrigin.z < endOrigin.z) throw new ArgumentException(); + var floors = new GameObject("Floors"); - var nextFloorOrigin = Vector3.zero; - var floorLength = 10f * dependencies.floorPrefab.transform.localScale.y; + var nextFloorOrigin = startOrigin; + var floorLength = 10f * floorPrefab.transform.localScale.y; var viewportOffset = Camera.main!.orthographicSize; - while (nextFloorOrigin.z + floorLength / 2f > _nextOrigin.z - viewportOffset) + while (endOrigin.z - viewportOffset < nextFloorOrigin.z + floorLength / 2f) { - var floor = Instantiate(dependencies.floorPrefab, floors.transform); + var floor = Instantiate(floorPrefab, floors.transform); floor.transform.position = nextFloorOrigin; nextFloorOrigin -= new Vector3(0.0f, 0.0f, floorLength); } + + return floors; } } } \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Runtime/TopDownCapture.cs b/Assets/VRM10_Samples/MToon10Showcase/Runtime/TopDownCapture.cs new file mode 100644 index 000000000..12e45c80e --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Runtime/TopDownCapture.cs @@ -0,0 +1,40 @@ +using System; +using UnityEngine; + +namespace VRM10.Samples.MToon10Showcase +{ + public sealed class TopDownCapture : MonoBehaviour + { + [SerializeField] private Camera _camera; + + [SerializeField] private RenderTexture _renderTarget; + + public RenderTexture RenderTarget => _renderTarget; + + public void Capture(Vector3 topLeft, Vector3 bottomRight) + { + if (topLeft.x > bottomRight.x) throw new ArgumentException("TopLeft.x must be less than BottomRight.x"); + if (topLeft.z < bottomRight.z) throw new ArgumentException("TopLeft.z must be greater than BottomRight.z"); + + var width = bottomRight.x - topLeft.x; + var height = topLeft.z - bottomRight.z; + var aspect = width / height; + _camera.transform.position = new Vector3(topLeft.x + width / 2f, topLeft.y, topLeft.z - height / 2f); + _camera.transform.rotation = Quaternion.Euler(90f, 0f, 0f); + _camera.orthographic = true; + _camera.orthographicSize = height / 2f; + var texWidth = 480; + var texHeight = (int)(texWidth / aspect); + + if (texWidth * texHeight > 4096 * 4096) throw new Exception("Too many pixels to capture."); + + _renderTarget = new RenderTexture(texWidth, texHeight, 16, RenderTextureFormat.ARGB32); + _camera.targetTexture = _renderTarget; + _camera.enabled = true; + _camera.Render(); + + _camera.enabled = false; + _camera.targetTexture = null; + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Runtime/TopDownCapture.cs.meta b/Assets/VRM10_Samples/MToon10Showcase/Runtime/TopDownCapture.cs.meta new file mode 100644 index 000000000..659ca09bd --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Runtime/TopDownCapture.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e55e85e81e284c6894f606adcf7ddc56 +timeCreated: 1743760457 \ No newline at end of file From 27ab83ae17f4c028c2c721f169f7c6d68a6e6a64 Mon Sep 17 00:00:00 2001 From: amamagi Date: Tue, 8 Apr 2025 14:15:26 +0900 Subject: [PATCH 2/5] add exporting captured image feature --- .../Runtime/MToon10ShowcaseEntryPoint.cs | 50 ++++++++--- .../MToon10Showcase/Runtime/TopDownCapture.cs | 90 ++++++++++++++++--- .../VRM10.Samples.MToon10Showcase.asmdef | 3 +- 3 files changed, 119 insertions(+), 24 deletions(-) diff --git a/Assets/VRM10_Samples/MToon10Showcase/Runtime/MToon10ShowcaseEntryPoint.cs b/Assets/VRM10_Samples/MToon10Showcase/Runtime/MToon10ShowcaseEntryPoint.cs index dc037f868..168737460 100644 --- a/Assets/VRM10_Samples/MToon10Showcase/Runtime/MToon10ShowcaseEntryPoint.cs +++ b/Assets/VRM10_Samples/MToon10Showcase/Runtime/MToon10ShowcaseEntryPoint.cs @@ -1,4 +1,6 @@ using System; +using System.IO; +using UniGLTF; using UnityEngine; using VRM10.MToon10; @@ -115,23 +117,51 @@ namespace VRM10.Samples.MToon10Showcase var width = (PrimitiveRadius * 2 + PrimitiveSpacing) * Columns - PrimitiveSpacing; var bottomLeft = _nextOrigin; + const float screenCenterXOffset = 2f; + var floorOffset = new Vector3(width / 2f + screenCenterXOffset, -1f, 0.0f); CreateFloor( - InitialOrigin + new Vector3(width / 2f, -1f, 0.0f), - bottomLeft + new Vector3(width / 2f, -1f, 0.0f), + InitialOrigin + floorOffset, + bottomLeft + floorOffset, dependencies.floorPrefab); const float cameraHeight = 5f; - + var cameraOffset = new Vector3(width / 2f + screenCenterXOffset, cameraHeight, 0); cameraScroller.Initialize( - InitialOrigin + new Vector3(width / 2f, cameraHeight, 0.0f), - bottomLeft + new Vector3(width / 2f, cameraHeight, 0.0f), + InitialOrigin + cameraOffset, + bottomLeft + cameraOffset, 0.5f); - const float captureSpacing = 0.1f; + const float padding = 0.1f; + var topLeft = InitialOrigin + new Vector3(-padding, 0, 0); + var bottomRight = bottomLeft + new Vector3(width + padding, 0, 0); + topDownCapture.Capture(topLeft, bottomRight); + } - topDownCapture.Capture( - InitialOrigin + new Vector3(-captureSpacing, cameraHeight, 0.0f), - bottomLeft + new Vector3(width + captureSpacing, cameraHeight, 0.0f)); + private void OnGUI() + { + if (GUI.Button(new Rect(10, 10, 150, 30), "Show Captured Image")) + { + topDownCapture.ShowCapturedImageNextToCaptureTarget(0.9f); + } + + if (GUI.Button(new Rect(10, 45, 150, 30), "Export Captured Image")) + { + var fileName = $"MToon10Showcase_{PackageVersion.VERSION}.png"; +#if UNITY_EDITOR + var path = UnityEditor.EditorUtility.SaveFilePanel("Export Screenshot", "", fileName, "png"); +#else + var path = Path.Combine(Application.dataPath, fileName); +#endif + if (string.IsNullOrEmpty(path)) + { + Debug.LogWarning("Export cancelled"); + return; + } + + topDownCapture.ExportCapturedImage(path); + Application.OpenURL(path); + Debug.Log($"Exported screenshot to {path}"); + } } private Transform CreateShowcase(T[] entries, Material baseMaterial, Action setup, @@ -176,7 +206,7 @@ namespace VRM10.Samples.MToon10Showcase private static GameObject CreateFloor(Vector3 startOrigin, Vector3 endOrigin, GameObject floorPrefab) { if (startOrigin.z < endOrigin.z) throw new ArgumentException(); - + var floors = new GameObject("Floors"); var nextFloorOrigin = startOrigin; var floorLength = 10f * floorPrefab.transform.localScale.y; diff --git a/Assets/VRM10_Samples/MToon10Showcase/Runtime/TopDownCapture.cs b/Assets/VRM10_Samples/MToon10Showcase/Runtime/TopDownCapture.cs index 12e45c80e..bdf2e98e3 100644 --- a/Assets/VRM10_Samples/MToon10Showcase/Runtime/TopDownCapture.cs +++ b/Assets/VRM10_Samples/MToon10Showcase/Runtime/TopDownCapture.cs @@ -1,40 +1,104 @@ using System; +using System.IO; using UnityEngine; +using UnityEngine.Rendering; namespace VRM10.Samples.MToon10Showcase { public sealed class TopDownCapture : MonoBehaviour { + private static readonly float CameraHeight = 5f; + private static readonly int MaxPixels = 4096 * 4096; + private static readonly int TextureWidth = 480; + [SerializeField] private Camera _camera; - [SerializeField] private RenderTexture _renderTarget; - - public RenderTexture RenderTarget => _renderTarget; + private RenderTexture _renderTarget; + private GameObject _quad; + private Vector3 _topLeftOfCaptureArea; + private Vector3 _bottomRightOfCaptureArea; public void Capture(Vector3 topLeft, Vector3 bottomRight) { if (topLeft.x > bottomRight.x) throw new ArgumentException("TopLeft.x must be less than BottomRight.x"); if (topLeft.z < bottomRight.z) throw new ArgumentException("TopLeft.z must be greater than BottomRight.z"); + // Set up render texture var width = bottomRight.x - topLeft.x; var height = topLeft.z - bottomRight.z; var aspect = width / height; - _camera.transform.position = new Vector3(topLeft.x + width / 2f, topLeft.y, topLeft.z - height / 2f); + var texHeight = (int)(TextureWidth / aspect); + if (TextureWidth * texHeight > MaxPixels) throw new Exception("Too many pixels to capture."); + if (_renderTarget != null) _renderTarget.Release(); + _renderTarget = new RenderTexture(TextureWidth, texHeight, 16, RenderTextureFormat.ARGB32); + + // Set up camera + _camera.transform.position = new Vector3(topLeft.x + width / 2f, CameraHeight, topLeft.z - height / 2f); _camera.transform.rotation = Quaternion.Euler(90f, 0f, 0f); _camera.orthographic = true; _camera.orthographicSize = height / 2f; - var texWidth = 480; - var texHeight = (int)(texWidth / aspect); - - if (texWidth * texHeight > 4096 * 4096) throw new Exception("Too many pixels to capture."); - - _renderTarget = new RenderTexture(texWidth, texHeight, 16, RenderTextureFormat.ARGB32); _camera.targetTexture = _renderTarget; - _camera.enabled = true; + + // Capture _camera.Render(); - _camera.enabled = false; - _camera.targetTexture = null; + // Save capture area for next step + _topLeftOfCaptureArea = topLeft; + _bottomRightOfCaptureArea = bottomRight; + } + + public void ShowCapturedImageNextToCaptureTarget(float xSpacing) + { + if (_renderTarget == null) + { + Debug.LogWarning("Call Capture() before ShowCaptureOnMesh()"); + return; + } + + if (_quad != null) + { + return; + } + + var offset = new Vector3(_bottomRightOfCaptureArea.x + xSpacing, 0, 0); + var topLeft = _topLeftOfCaptureArea + offset; + var bottomRight = _bottomRightOfCaptureArea + offset; + var width = bottomRight.x - topLeft.x; + var height = topLeft.z - bottomRight.z; + _quad = GameObject.CreatePrimitive(PrimitiveType.Quad); + _quad.gameObject.name = "Capture"; + _quad.transform.position = new Vector3(topLeft.x + width / 2f, topLeft.y, topLeft.z - height / 2f); + _quad.transform.rotation = Quaternion.Euler(90f, 0f, 0f); + _quad.transform.localScale = new Vector3(width, height, 1f); + var material = new Material(Shader.Find("Unlit/Texture")); + material.mainTexture = _renderTarget; + _quad.GetComponent().material = material; + } + + public void ExportCapturedImage(string path) + { + if (_renderTarget == null) + { + Debug.LogWarning("Call Capture() before ExportCapturedImage()"); + return; + } + + AsyncGPUReadback.Request(_renderTarget, 0, request => + { + if (request.hasError) + { + Debug.LogError("AsyncGPUReadback error"); + return; + } + + var texture = new Texture2D(_renderTarget.width, _renderTarget.height, TextureFormat.RGBA32, false); + var data = request.GetData(); + texture.LoadRawTextureData(data); + texture.Apply(); + var encodedData = texture.EncodeToPNG(); + File.WriteAllBytes(path, encodedData); + DestroyImmediate(texture); + }); } } } \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Runtime/VRM10.Samples.MToon10Showcase.asmdef b/Assets/VRM10_Samples/MToon10Showcase/Runtime/VRM10.Samples.MToon10Showcase.asmdef index bc5764474..afd68a0d2 100644 --- a/Assets/VRM10_Samples/MToon10Showcase/Runtime/VRM10.Samples.MToon10Showcase.asmdef +++ b/Assets/VRM10_Samples/MToon10Showcase/Runtime/VRM10.Samples.MToon10Showcase.asmdef @@ -3,7 +3,8 @@ "rootNamespace": "", "references": [ "GUID:e47c917724578cc43b5506c17a27e9a0", - "GUID:0aaf403bd13871a44b7127aef2695ff8" + "GUID:0aaf403bd13871a44b7127aef2695ff8", + "GUID:8d76e605759c3f64a957d63ef96ada7c" ], "includePlatforms": [], "excludePlatforms": [], From 8f5d826269f8866a718d2a1c715999c09d6bac21 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 9 Apr 2025 14:37:13 +0900 Subject: [PATCH 3/5] dispose function can now be executed again --- .../SpringBoneJobs/FastSpringBoneBufferCombiner.cs | 4 ++-- .../Vrm10Runtime/Vrm10FastSpringboneRuntime.cs | 2 ++ .../Vrm10FastSpringboneRuntimeStandalone.cs | 12 ++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Assets/UniGLTF/Runtime/SpringBoneJobs/FastSpringBoneBufferCombiner.cs b/Assets/UniGLTF/Runtime/SpringBoneJobs/FastSpringBoneBufferCombiner.cs index efd342140..6127beb20 100644 --- a/Assets/UniGLTF/Runtime/SpringBoneJobs/FastSpringBoneBufferCombiner.cs +++ b/Assets/UniGLTF/Runtime/SpringBoneJobs/FastSpringBoneBufferCombiner.cs @@ -118,9 +118,9 @@ namespace UniGLTF.SpringBoneJobs public void Dispose() { - if (_combinedBuffer is FastSpringBoneCombinedBuffer combined) + if (_combinedBuffer != null) { - combined.Dispose(); + _combinedBuffer.Dispose(); _combinedBuffer = null; } } diff --git a/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs b/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs index 246eb9c7c..e7a7750af 100644 --- a/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs +++ b/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs @@ -57,6 +57,8 @@ namespace UniVRM10 { m_fastSpringBoneService.BufferCombiner.Register(add: null, remove: m_fastSpringBoneBuffer); m_fastSpringBoneBuffer.Dispose(); + // #2616 + m_fastSpringBoneBuffer = null; } } diff --git a/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntimeStandalone.cs b/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntimeStandalone.cs index e1660af07..caf09e2ba 100644 --- a/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntimeStandalone.cs +++ b/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntimeStandalone.cs @@ -54,10 +54,18 @@ namespace UniVRM10 public void Dispose() { - m_bufferCombiner.Register(add: null, remove: m_fastSpringBoneBuffer); - m_fastSpringBoneBuffer.Dispose(); + if (m_fastSpringBoneBuffer != null) + { + m_bufferCombiner.Register(add: null, remove: m_fastSpringBoneBuffer); + m_fastSpringBoneBuffer.Dispose(); + // #2616 + m_fastSpringBoneBuffer = null; + } + // re-entrant ok m_fastSpringBoneScheduler.Dispose(); + + // re-entrant ok m_bufferCombiner.Dispose(); } From 91a1f6607f02cc3fc98b88b7e35b744446f2fb39 Mon Sep 17 00:00:00 2001 From: amamagi Date: Wed, 9 Apr 2025 16:31:41 +0900 Subject: [PATCH 4/5] add property drawer to showcase entry --- .../CustomEditor/AlphaModeEntryDrawer.cs | 21 ++++++++++++++++ .../CustomEditor/AlphaModeEntryDrawer.cs.meta | 3 +++ .../CustomEditor/EmissionEntryDrawer.cs | 17 +++++++++++++ .../CustomEditor/EmissionEntryDrawer.cs.meta | 3 +++ .../CustomEditor/GIEqualizationEntryDrawer.cs | 15 ++++++++++++ .../GIEqualizationEntryDrawer.cs.meta | 3 +++ .../Editor/CustomEditor/MatcapEntryDrawer.cs | 17 +++++++++++++ .../CustomEditor/MatcapEntryDrawer.cs.meta | 3 +++ .../CustomEditor/NormalMapEntryDrawer.cs | 17 +++++++++++++ .../CustomEditor/NormalMapEntryDrawer.cs.meta | 3 +++ .../Editor/CustomEditor/OutlineEntryDrawer.cs | 23 ++++++++++++++++++ .../CustomEditor/OutlineEntryDrawer.cs.meta | 3 +++ .../CustomEditor/PrametricRimEntryDrawer.cs | 20 ++++++++++++++++ .../PrametricRimEntryDrawer.cs.meta | 3 +++ .../RenderQueueOffsetEntryDrawer.cs | 16 +++++++++++++ .../RenderQueueOffsetEntryDrawer.cs.meta | 3 +++ .../CustomEditor/RimLightingEntryDrawer.cs | 19 +++++++++++++++ .../RimLightingEntryDrawer.cs.meta | 3 +++ .../CustomEditor/ShadingShiftEntryDrawer.cs | 17 +++++++++++++ .../ShadingShiftEntryDrawer.cs.meta | 3 +++ .../CustomEditor/ShadingToonyEntryDrawer.cs | 17 +++++++++++++ .../ShadingToonyEntryDrawer.cs.meta | 3 +++ .../CustomEditor/UVAnimationEntryDrawer.cs | 24 +++++++++++++++++++ .../UVAnimationEntryDrawer.cs.meta | 3 +++ ...RM10.Samples.MToon10Showcase.Editor.asmdef | 3 ++- .../ShowcaseTemplates/OutlineShowcase.cs | 2 +- 26 files changed, 262 insertions(+), 2 deletions(-) create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/AlphaModeEntryDrawer.cs create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/AlphaModeEntryDrawer.cs.meta create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/EmissionEntryDrawer.cs create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/EmissionEntryDrawer.cs.meta create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/GIEqualizationEntryDrawer.cs create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/GIEqualizationEntryDrawer.cs.meta create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/MatcapEntryDrawer.cs create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/MatcapEntryDrawer.cs.meta create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/NormalMapEntryDrawer.cs create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/NormalMapEntryDrawer.cs.meta create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/OutlineEntryDrawer.cs create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/OutlineEntryDrawer.cs.meta create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/PrametricRimEntryDrawer.cs create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/PrametricRimEntryDrawer.cs.meta create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RenderQueueOffsetEntryDrawer.cs create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RenderQueueOffsetEntryDrawer.cs.meta create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RimLightingEntryDrawer.cs create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RimLightingEntryDrawer.cs.meta create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingShiftEntryDrawer.cs create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingShiftEntryDrawer.cs.meta create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingToonyEntryDrawer.cs create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingToonyEntryDrawer.cs.meta create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/UVAnimationEntryDrawer.cs create mode 100644 Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/UVAnimationEntryDrawer.cs.meta diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/AlphaModeEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/AlphaModeEntryDrawer.cs new file mode 100644 index 000000000..3b67365f9 --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/AlphaModeEntryDrawer.cs @@ -0,0 +1,21 @@ +using UnityEditor; +using UnityEngine; + +namespace VRM10.Samples.MToon10Showcase +{ + [CustomPropertyDrawer(typeof(AlphaModeShowcase.AlphaModeEntry))] + public sealed class AlphaModeEntryDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(AlphaModeShowcase.AlphaModeEntry.alphaMode))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(AlphaModeShowcase.AlphaModeEntry.alphaCutoff))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(AlphaModeShowcase.AlphaModeEntry.doubleSidedMode))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(AlphaModeShowcase.AlphaModeEntry.transparentWithZWriteMode))); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/AlphaModeEntryDrawer.cs.meta b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/AlphaModeEntryDrawer.cs.meta new file mode 100644 index 000000000..9620d72df --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/AlphaModeEntryDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3fee9b12cbf4465e83bd9ac5cc2d477e +timeCreated: 1744177935 \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/EmissionEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/EmissionEntryDrawer.cs new file mode 100644 index 000000000..aa78bcddb --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/EmissionEntryDrawer.cs @@ -0,0 +1,17 @@ +using UnityEditor; +using UnityEngine; + +namespace VRM10.Samples.MToon10Showcase +{ + [CustomPropertyDrawer(typeof(EmissionShowcase.EmissionEntry))] + public sealed class EmissionEntryDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(EmissionShowcase.EmissionEntry.emissiveTexture))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(EmissionShowcase.EmissionEntry.emissiveFactorLinear))); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/EmissionEntryDrawer.cs.meta b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/EmissionEntryDrawer.cs.meta new file mode 100644 index 000000000..76e4c3686 --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/EmissionEntryDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 98220e137fc2407e89f281bb08beae57 +timeCreated: 1744181619 \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/GIEqualizationEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/GIEqualizationEntryDrawer.cs new file mode 100644 index 000000000..3e37002f4 --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/GIEqualizationEntryDrawer.cs @@ -0,0 +1,15 @@ +using UnityEditor; +using UnityEngine; + +namespace VRM10.Samples.MToon10Showcase +{ + [CustomPropertyDrawer(typeof(GIEqualizationShowcase.GIEqualizationEntry))] + public sealed class GIEqualizationEntryDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(GIEqualizationShowcase.GIEqualizationEntry.giEqualizationFactor))); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/GIEqualizationEntryDrawer.cs.meta b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/GIEqualizationEntryDrawer.cs.meta new file mode 100644 index 000000000..902defe7c --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/GIEqualizationEntryDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 57a82d70b56740d0bc23cc36130d9612 +timeCreated: 1744181638 \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/MatcapEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/MatcapEntryDrawer.cs new file mode 100644 index 000000000..9d32fc138 --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/MatcapEntryDrawer.cs @@ -0,0 +1,17 @@ +using UnityEditor; +using UnityEngine; + +namespace VRM10.Samples.MToon10Showcase +{ + [CustomPropertyDrawer(typeof(MatcapShowcase.MatcapEntry))] + public sealed class MatcapEntryDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(MatcapShowcase.MatcapEntry.matcapTexture))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(MatcapShowcase.MatcapEntry.matcapColorFactor))); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/MatcapEntryDrawer.cs.meta b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/MatcapEntryDrawer.cs.meta new file mode 100644 index 000000000..204461f05 --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/MatcapEntryDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: be96b3c6ab904720991f11ab006cd4ea +timeCreated: 1744181656 \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/NormalMapEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/NormalMapEntryDrawer.cs new file mode 100644 index 000000000..5475825be --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/NormalMapEntryDrawer.cs @@ -0,0 +1,17 @@ +using UnityEditor; +using UnityEngine; + +namespace VRM10.Samples.MToon10Showcase +{ + [CustomPropertyDrawer(typeof(NormalMapShowcase.NormalMapEntry))] + public class NormalMapEntryDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(NormalMapShowcase.NormalMapEntry.normalTexture))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(NormalMapShowcase.NormalMapEntry.normalTextureScale))); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/NormalMapEntryDrawer.cs.meta b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/NormalMapEntryDrawer.cs.meta new file mode 100644 index 000000000..9ce65754c --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/NormalMapEntryDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0be204fce50046c292e00c3af1133af7 +timeCreated: 1744181673 \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/OutlineEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/OutlineEntryDrawer.cs new file mode 100644 index 000000000..4570690b3 --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/OutlineEntryDrawer.cs @@ -0,0 +1,23 @@ +using UnityEditor; +using UnityEngine; + +namespace VRM10.Samples.MToon10Showcase +{ + [CustomPropertyDrawer(typeof(OutlineShowcase.OutlineEntry))] + public sealed class OutlineEntryDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(OutlineShowcase.OutlineEntry.outlineWidthMode))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(OutlineShowcase.OutlineEntry.outlineWidthFactor))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(OutlineShowcase.OutlineEntry.outlineColorFactor))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(OutlineShowcase.OutlineEntry.outlineWidthMultiplyTexture))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(OutlineShowcase.OutlineEntry.outlineLightingMixFactor))); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/OutlineEntryDrawer.cs.meta b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/OutlineEntryDrawer.cs.meta new file mode 100644 index 000000000..fb35c3d9d --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/OutlineEntryDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8d7b8324969947f695eea28f9e455443 +timeCreated: 1744181687 \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/PrametricRimEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/PrametricRimEntryDrawer.cs new file mode 100644 index 000000000..54f06da2e --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/PrametricRimEntryDrawer.cs @@ -0,0 +1,20 @@ +using UnityEditor; +using UnityEngine; + +namespace VRM10.Samples.MToon10Showcase +{ + [CustomPropertyDrawer(typeof(ParametricRimShowcase.ParametricRimEntry))] + public sealed class ParametricRimEntryDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(ParametricRimShowcase.ParametricRimEntry.parametricRimColor))); + EditorGUILayout.PropertyField(property.FindPropertyRelative(nameof(ParametricRimShowcase.ParametricRimEntry + .parametricRimFresnelPowerFactor))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(ParametricRimShowcase.ParametricRimEntry + .parametricRimLiftFactor))); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/PrametricRimEntryDrawer.cs.meta b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/PrametricRimEntryDrawer.cs.meta new file mode 100644 index 000000000..a4fb01060 --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/PrametricRimEntryDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3eea0197be7b48ed85c7e4f63cb196a8 +timeCreated: 1744181696 \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RenderQueueOffsetEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RenderQueueOffsetEntryDrawer.cs new file mode 100644 index 000000000..57ca7fa54 --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RenderQueueOffsetEntryDrawer.cs @@ -0,0 +1,16 @@ +using UnityEditor; +using UnityEngine; + +namespace VRM10.Samples.MToon10Showcase +{ + [CustomPropertyDrawer(typeof(RenderQueueOffsetShowcase.RenderQueueOffsetEntry))] + public sealed class RenderQueueOffsetEntryDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUILayout.PropertyField( + property.FindPropertyRelative( + nameof(RenderQueueOffsetShowcase.RenderQueueOffsetEntry.renderQueueOffset))); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RenderQueueOffsetEntryDrawer.cs.meta b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RenderQueueOffsetEntryDrawer.cs.meta new file mode 100644 index 000000000..bccfa27bc --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RenderQueueOffsetEntryDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1252c8a4ee97479cab2143c175211921 +timeCreated: 1744181707 \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RimLightingEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RimLightingEntryDrawer.cs new file mode 100644 index 000000000..af5c8f0b8 --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RimLightingEntryDrawer.cs @@ -0,0 +1,19 @@ +using UnityEditor; +using UnityEngine; + +namespace VRM10.Samples.MToon10Showcase +{ + [CustomPropertyDrawer(typeof(RimLightingShowcase.RimLightingMixFactorEntry))] + public sealed class RimLightingEntryDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUILayout.PropertyField( + property.FindPropertyRelative( + nameof(RimLightingShowcase.RimLightingMixFactorEntry.rimLightingMixFactor))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(RimLightingShowcase.RimLightingMixFactorEntry + .rimMultiplyTexture))); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RimLightingEntryDrawer.cs.meta b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RimLightingEntryDrawer.cs.meta new file mode 100644 index 000000000..50f3ec569 --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RimLightingEntryDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 13cddcf1d05c49b59f5a28ffa8598473 +timeCreated: 1744181720 \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingShiftEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingShiftEntryDrawer.cs new file mode 100644 index 000000000..c91390f45 --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingShiftEntryDrawer.cs @@ -0,0 +1,17 @@ +using UnityEditor; +using UnityEngine; + +namespace VRM10.Samples.MToon10Showcase +{ + [CustomPropertyDrawer(typeof(ShadingShiftShowcase.ShadingShiftEntry))] + public sealed class ShadingShiftEntryDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(ShadingShiftShowcase.ShadingShiftEntry.shadingShiftTexture))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(ShadingShiftShowcase.ShadingShiftEntry.shadingShiftTextureScale))); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingShiftEntryDrawer.cs.meta b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingShiftEntryDrawer.cs.meta new file mode 100644 index 000000000..37ede73b7 --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingShiftEntryDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 985ae8c939844b249a4a5562cb28bf3a +timeCreated: 1744181741 \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingToonyEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingToonyEntryDrawer.cs new file mode 100644 index 000000000..8cb4ab5ab --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingToonyEntryDrawer.cs @@ -0,0 +1,17 @@ +using UnityEditor; +using UnityEngine; + +namespace VRM10.Samples.MToon10Showcase +{ + [CustomPropertyDrawer(typeof(ShadingToonyShowcase.ShadingToonyEntry))] + public sealed class ShadingToonyEntryDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(ShadingToonyShowcase.ShadingToonyEntry.shadingToonyFactor))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(ShadingToonyShowcase.ShadingToonyEntry.shadingShiftFactor))); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingToonyEntryDrawer.cs.meta b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingToonyEntryDrawer.cs.meta new file mode 100644 index 000000000..331331034 --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingToonyEntryDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1cb4e1dfc0414b94a77ca53a7df387a1 +timeCreated: 1744181752 \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/UVAnimationEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/UVAnimationEntryDrawer.cs new file mode 100644 index 000000000..fd84da45c --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/UVAnimationEntryDrawer.cs @@ -0,0 +1,24 @@ +using UnityEditor; +using UnityEngine; + +namespace VRM10.Samples.MToon10Showcase +{ + [CustomPropertyDrawer(typeof(UVAnimationShowcase.UVAnimationEntry))] + public class UVAnimationEntryDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUILayout.PropertyField( + property.FindPropertyRelative(nameof(UVAnimationShowcase.UVAnimationEntry.uvAnimationMaskTexture))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative( + nameof(UVAnimationShowcase.UVAnimationEntry.uvAnimationScrollXSpeedFactor))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative( + nameof(UVAnimationShowcase.UVAnimationEntry.uvAnimationScrollYSpeedFactor))); + EditorGUILayout.PropertyField( + property.FindPropertyRelative( + nameof(UVAnimationShowcase.UVAnimationEntry.uvAnimationRotationSpeedFactor))); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/UVAnimationEntryDrawer.cs.meta b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/UVAnimationEntryDrawer.cs.meta new file mode 100644 index 000000000..b914d21f3 --- /dev/null +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/UVAnimationEntryDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3bcab6f07e49404db13cd543829dd7f4 +timeCreated: 1744181759 \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/VRM10.Samples.MToon10Showcase.Editor.asmdef b/Assets/VRM10_Samples/MToon10Showcase/Editor/VRM10.Samples.MToon10Showcase.Editor.asmdef index 8c9266b01..799b5e6d7 100644 --- a/Assets/VRM10_Samples/MToon10Showcase/Editor/VRM10.Samples.MToon10Showcase.Editor.asmdef +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/VRM10.Samples.MToon10Showcase.Editor.asmdef @@ -2,7 +2,8 @@ "name": "VRM10.Samples.MToon10Showcase.Editor", "rootNamespace": "", "references": [ - "GUID:151799a9fa5ec7e44bc6c5293df4b6b3" + "GUID:151799a9fa5ec7e44bc6c5293df4b6b3", + "GUID:0aaf403bd13871a44b7127aef2695ff8" ], "includePlatforms": [ "Editor" diff --git a/Assets/VRM10_Samples/MToon10Showcase/Runtime/ShowcaseTemplates/OutlineShowcase.cs b/Assets/VRM10_Samples/MToon10Showcase/Runtime/ShowcaseTemplates/OutlineShowcase.cs index 961b350a3..3c138c3b4 100644 --- a/Assets/VRM10_Samples/MToon10Showcase/Runtime/ShowcaseTemplates/OutlineShowcase.cs +++ b/Assets/VRM10_Samples/MToon10Showcase/Runtime/ShowcaseTemplates/OutlineShowcase.cs @@ -16,7 +16,7 @@ namespace VRM10.Samples.MToon10Showcase [Serializable] public sealed class OutlineEntry { - [FormerlySerializedAs("outlineMode")] public MToon10OutlineMode outlineWidthMode; + public MToon10OutlineMode outlineWidthMode; public float outlineWidthFactor; public Color outlineColorFactor; public Texture outlineWidthMultiplyTexture; From 3189def11a2349d716e1e40459f5dd35f0481428 Mon Sep 17 00:00:00 2001 From: amamagi Date: Wed, 9 Apr 2025 16:59:06 +0900 Subject: [PATCH 5/5] add slider to property drawers in mtoon10 showcase --- .../Editor/CustomEditor/AlphaModeEntryDrawer.cs | 4 ++-- .../Editor/CustomEditor/GIEqualizationEntryDrawer.cs | 5 +++-- .../Editor/CustomEditor/OutlineEntryDrawer.cs | 10 ++++++---- .../Editor/CustomEditor/PrametricRimEntryDrawer.cs | 8 ++++---- .../Editor/CustomEditor/RimLightingEntryDrawer.cs | 9 +++++---- .../Editor/CustomEditor/ShadingShiftEntryDrawer.cs | 5 +++-- .../Editor/CustomEditor/ShadingToonyEntryDrawer.cs | 10 ++++++---- 7 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/AlphaModeEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/AlphaModeEntryDrawer.cs index 3b67365f9..6788e0898 100644 --- a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/AlphaModeEntryDrawer.cs +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/AlphaModeEntryDrawer.cs @@ -10,8 +10,8 @@ namespace VRM10.Samples.MToon10Showcase { EditorGUILayout.PropertyField( property.FindPropertyRelative(nameof(AlphaModeShowcase.AlphaModeEntry.alphaMode))); - EditorGUILayout.PropertyField( - property.FindPropertyRelative(nameof(AlphaModeShowcase.AlphaModeEntry.alphaCutoff))); + EditorGUILayout.Slider( + property.FindPropertyRelative(nameof(AlphaModeShowcase.AlphaModeEntry.alphaCutoff)), 0, 1); EditorGUILayout.PropertyField( property.FindPropertyRelative(nameof(AlphaModeShowcase.AlphaModeEntry.doubleSidedMode))); EditorGUILayout.PropertyField( diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/GIEqualizationEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/GIEqualizationEntryDrawer.cs index 3e37002f4..910f80661 100644 --- a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/GIEqualizationEntryDrawer.cs +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/GIEqualizationEntryDrawer.cs @@ -8,8 +8,9 @@ namespace VRM10.Samples.MToon10Showcase { public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUILayout.PropertyField( - property.FindPropertyRelative(nameof(GIEqualizationShowcase.GIEqualizationEntry.giEqualizationFactor))); + EditorGUILayout.Slider( + property.FindPropertyRelative(nameof(GIEqualizationShowcase.GIEqualizationEntry.giEqualizationFactor)), + 0, 1); } } } \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/OutlineEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/OutlineEntryDrawer.cs index 4570690b3..455d4a879 100644 --- a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/OutlineEntryDrawer.cs +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/OutlineEntryDrawer.cs @@ -10,14 +10,16 @@ namespace VRM10.Samples.MToon10Showcase { EditorGUILayout.PropertyField( property.FindPropertyRelative(nameof(OutlineShowcase.OutlineEntry.outlineWidthMode))); - EditorGUILayout.PropertyField( - property.FindPropertyRelative(nameof(OutlineShowcase.OutlineEntry.outlineWidthFactor))); + EditorGUILayout.Slider( + property.FindPropertyRelative(nameof(OutlineShowcase.OutlineEntry.outlineWidthFactor)), + 0, 0.05f); EditorGUILayout.PropertyField( property.FindPropertyRelative(nameof(OutlineShowcase.OutlineEntry.outlineColorFactor))); EditorGUILayout.PropertyField( property.FindPropertyRelative(nameof(OutlineShowcase.OutlineEntry.outlineWidthMultiplyTexture))); - EditorGUILayout.PropertyField( - property.FindPropertyRelative(nameof(OutlineShowcase.OutlineEntry.outlineLightingMixFactor))); + EditorGUILayout.Slider( + property.FindPropertyRelative(nameof(OutlineShowcase.OutlineEntry.outlineLightingMixFactor)), + 0, 1); } } } \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/PrametricRimEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/PrametricRimEntryDrawer.cs index 54f06da2e..cc8c4f03f 100644 --- a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/PrametricRimEntryDrawer.cs +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/PrametricRimEntryDrawer.cs @@ -10,11 +10,11 @@ namespace VRM10.Samples.MToon10Showcase { EditorGUILayout.PropertyField( property.FindPropertyRelative(nameof(ParametricRimShowcase.ParametricRimEntry.parametricRimColor))); - EditorGUILayout.PropertyField(property.FindPropertyRelative(nameof(ParametricRimShowcase.ParametricRimEntry - .parametricRimFresnelPowerFactor))); - EditorGUILayout.PropertyField( + EditorGUILayout.Slider(property.FindPropertyRelative(nameof(ParametricRimShowcase.ParametricRimEntry + .parametricRimFresnelPowerFactor)), 0, 100); + EditorGUILayout.Slider( property.FindPropertyRelative(nameof(ParametricRimShowcase.ParametricRimEntry - .parametricRimLiftFactor))); + .parametricRimLiftFactor)), 0, 1); } } } \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RimLightingEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RimLightingEntryDrawer.cs index af5c8f0b8..b0443c428 100644 --- a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RimLightingEntryDrawer.cs +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/RimLightingEntryDrawer.cs @@ -10,10 +10,11 @@ namespace VRM10.Samples.MToon10Showcase { EditorGUILayout.PropertyField( property.FindPropertyRelative( - nameof(RimLightingShowcase.RimLightingMixFactorEntry.rimLightingMixFactor))); - EditorGUILayout.PropertyField( - property.FindPropertyRelative(nameof(RimLightingShowcase.RimLightingMixFactorEntry - .rimMultiplyTexture))); + nameof(RimLightingShowcase.RimLightingMixFactorEntry.rimMultiplyTexture))); + EditorGUILayout.Slider( + property.FindPropertyRelative( + nameof(RimLightingShowcase.RimLightingMixFactorEntry.rimLightingMixFactor)), + 0, 1); } } } \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingShiftEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingShiftEntryDrawer.cs index c91390f45..35146afdc 100644 --- a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingShiftEntryDrawer.cs +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingShiftEntryDrawer.cs @@ -10,8 +10,9 @@ namespace VRM10.Samples.MToon10Showcase { EditorGUILayout.PropertyField( property.FindPropertyRelative(nameof(ShadingShiftShowcase.ShadingShiftEntry.shadingShiftTexture))); - EditorGUILayout.PropertyField( - property.FindPropertyRelative(nameof(ShadingShiftShowcase.ShadingShiftEntry.shadingShiftTextureScale))); + EditorGUILayout.Slider( + property.FindPropertyRelative(nameof(ShadingShiftShowcase.ShadingShiftEntry.shadingShiftTextureScale)), + -3f, 3f); } } } \ No newline at end of file diff --git a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingToonyEntryDrawer.cs b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingToonyEntryDrawer.cs index 8cb4ab5ab..da2f020cc 100644 --- a/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingToonyEntryDrawer.cs +++ b/Assets/VRM10_Samples/MToon10Showcase/Editor/CustomEditor/ShadingToonyEntryDrawer.cs @@ -8,10 +8,12 @@ namespace VRM10.Samples.MToon10Showcase { public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { - EditorGUILayout.PropertyField( - property.FindPropertyRelative(nameof(ShadingToonyShowcase.ShadingToonyEntry.shadingToonyFactor))); - EditorGUILayout.PropertyField( - property.FindPropertyRelative(nameof(ShadingToonyShowcase.ShadingToonyEntry.shadingShiftFactor))); + EditorGUILayout.Slider( + property.FindPropertyRelative(nameof(ShadingToonyShowcase.ShadingToonyEntry.shadingToonyFactor)), + 0f, 1f); + EditorGUILayout.Slider( + property.FindPropertyRelative(nameof(ShadingToonyShowcase.ShadingToonyEntry.shadingShiftFactor)), + -1f, 1f); } } } \ No newline at end of file