Add pinch controls to statue dressup game
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a935f5e791c46df8920c2c33f1c24c0
|
||||
timeCreated: 1765361215
|
||||
@@ -1,99 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Minigames.TrashMaze.Objects;
|
||||
|
||||
namespace Minigames.TrashMaze.Editor
|
||||
{
|
||||
[CustomEditor(typeof(RevealableObject))]
|
||||
public class RevealableObjectEditor : UnityEditor.Editor
|
||||
{
|
||||
private RenderTexture _cachedStampTexture;
|
||||
private Texture2D _previewTexture;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
|
||||
// Only show debug info in play mode
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("Progressive Reveal Debug (Play Mode Only)", EditorStyles.boldLabel);
|
||||
EditorGUILayout.HelpBox("Shows the current stamp texture for Progressive reveal mode.", MessageType.Info);
|
||||
|
||||
RevealableObject revealableObject = (RevealableObject)target;
|
||||
|
||||
// Use reflection to get private _revealStampTexture field
|
||||
var field = typeof(RevealableObject).GetField("_revealStampTexture",
|
||||
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
|
||||
if (field != null)
|
||||
{
|
||||
RenderTexture stampTexture = field.GetValue(revealableObject) as RenderTexture;
|
||||
|
||||
if (stampTexture != null)
|
||||
{
|
||||
// Display stamp texture info
|
||||
EditorGUILayout.LabelField("Stamp Texture:", $"{stampTexture.width}x{stampTexture.height}");
|
||||
|
||||
// Show preview of stamp texture
|
||||
GUILayout.Label("Reveal Mask Preview (White = Revealed):");
|
||||
|
||||
// Create preview texture if needed
|
||||
if (_cachedStampTexture != stampTexture || _previewTexture == null)
|
||||
{
|
||||
_cachedStampTexture = stampTexture;
|
||||
|
||||
if (_previewTexture != null)
|
||||
{
|
||||
DestroyImmediate(_previewTexture);
|
||||
}
|
||||
|
||||
_previewTexture = new Texture2D(stampTexture.width, stampTexture.height, TextureFormat.R8, false);
|
||||
_previewTexture.filterMode = FilterMode.Point;
|
||||
}
|
||||
|
||||
// Copy RenderTexture to Texture2D for preview
|
||||
RenderTexture.active = stampTexture;
|
||||
_previewTexture.ReadPixels(new Rect(0, 0, stampTexture.width, stampTexture.height), 0, 0);
|
||||
_previewTexture.Apply();
|
||||
RenderTexture.active = null;
|
||||
|
||||
// Display preview with fixed size
|
||||
float previewSize = 256f;
|
||||
float aspectRatio = (float)stampTexture.height / stampTexture.width;
|
||||
Rect previewRect = GUILayoutUtility.GetRect(previewSize, previewSize * aspectRatio);
|
||||
EditorGUI.DrawPreviewTexture(previewRect, _previewTexture, null, ScaleMode.ScaleToFit);
|
||||
|
||||
// Auto-refresh in play mode
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
Repaint();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("No stamp texture found. Make sure object is in Progressive reveal mode.", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("Could not access stamp texture via reflection.", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
// Clean up preview texture
|
||||
if (_previewTexture != null)
|
||||
{
|
||||
DestroyImmediate(_previewTexture);
|
||||
_previewTexture = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d081993ee424269bf8eae99db36a54c
|
||||
timeCreated: 1765361215
|
||||
Reference in New Issue
Block a user