artbook added to drawing
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Darkmatter.Core;
|
||||
using Darkmatter.Core.Data.Signals.Features.ShapeBuilder;
|
||||
using Darkmatter.Libs.Observer;
|
||||
using VContainer.Unity;
|
||||
@@ -22,11 +23,18 @@ namespace Darkmatter.Features.Coloring.UI
|
||||
{
|
||||
_view.HideInstant();
|
||||
_assembledSub = _bus.Subscribe<ShapeAssembledSignal>(_ => _view.Show());
|
||||
_view.OnArtbookClicked += HandleArtbookClicked;
|
||||
}
|
||||
|
||||
private void HandleArtbookClicked()
|
||||
{
|
||||
_bus.Publish(new OpenArtBookSignal());
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_assembledSub?.Dispose();
|
||||
_view.OnArtbookClicked -= HandleArtbookClicked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using PrimeTween;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Darkmatter.Features.Coloring.UI
|
||||
{
|
||||
@@ -8,6 +10,7 @@ namespace Darkmatter.Features.Coloring.UI
|
||||
{
|
||||
[SerializeField] private RectTransform spawnRoot;
|
||||
[SerializeField] private RectTransform animatedRoot;
|
||||
[SerializeField] private Button artbookButton;
|
||||
[SerializeField] private float showDuration = 0.35f;
|
||||
[SerializeField] private float hideDuration = 0.25f;
|
||||
[SerializeField] private Vector2 hiddenOffset = new(1500f, 0f);
|
||||
@@ -17,9 +20,16 @@ namespace Darkmatter.Features.Coloring.UI
|
||||
private Sequence _activeSequence;
|
||||
private bool _refsReady;
|
||||
|
||||
public event Action OnArtbookClicked;
|
||||
public RectTransform SpawnRoot => spawnRoot;
|
||||
|
||||
private void Awake() => EnsureRefs();
|
||||
private void Awake()
|
||||
{
|
||||
EnsureRefs();
|
||||
if (artbookButton != null) artbookButton.onClick.AddListener(HandleArtbookClicked);
|
||||
}
|
||||
|
||||
private void HandleArtbookClicked() => OnArtbookClicked?.Invoke();
|
||||
|
||||
private void EnsureRefs()
|
||||
{
|
||||
@@ -80,5 +90,10 @@ namespace Darkmatter.Features.Coloring.UI
|
||||
{
|
||||
KillActive();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (artbookButton != null) artbookButton.onClick.RemoveListener(HandleArtbookClicked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Darkmatter.Core;
|
||||
using Darkmatter.Core.Data.Signals.Features.ShapeBuilder;
|
||||
using Darkmatter.Libs.Observer;
|
||||
using VContainer.Unity;
|
||||
@@ -24,12 +25,19 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
_view.HideInstant();
|
||||
_startedSub = _bus.Subscribe<ShapeBuilderStartedSignal>(_ => _view.Show());
|
||||
_assembledSub = _bus.Subscribe<ShapeAssembledSignal>(_ => _view.Hide());
|
||||
_view.OnArtbookClicked += HandleArtbookClicked;
|
||||
}
|
||||
|
||||
private void HandleArtbookClicked()
|
||||
{
|
||||
_bus.Publish(new OpenArtBookSignal());
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_startedSub?.Dispose();
|
||||
_assembledSub?.Dispose();
|
||||
_view.OnArtbookClicked -= HandleArtbookClicked;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using Darkmatter.Features.ShapeBuilder.Systems;
|
||||
using PrimeTween;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
{
|
||||
@@ -8,6 +11,7 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
{
|
||||
[SerializeField] private RectTransform spawnRoot;
|
||||
[SerializeField] private RectTransform animatedRoot;
|
||||
[SerializeField] private Button artbookButton;
|
||||
[SerializeField] private float showDuration = 0.35f;
|
||||
[SerializeField] private float hideDuration = 0.25f;
|
||||
[SerializeField] private Vector2 hiddenOffset = new(1500f, 0f);
|
||||
@@ -15,6 +19,7 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
private CanvasGroup _canvasGroup;
|
||||
private Vector2 _shownAnchoredPos;
|
||||
private Sequence _activeSequence;
|
||||
public event Action OnArtbookClicked;
|
||||
|
||||
public RectTransform SpawnRoot => spawnRoot;
|
||||
public float SpawnWidth => spawnRoot.rect.width;
|
||||
@@ -24,6 +29,12 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
_canvasGroup = GetComponent<CanvasGroup>();
|
||||
if (animatedRoot == null) animatedRoot = (RectTransform)transform;
|
||||
_shownAnchoredPos = animatedRoot.anchoredPosition;
|
||||
artbookButton.onClick.AddListener(HandleArtbookClicked);
|
||||
}
|
||||
|
||||
private void HandleArtbookClicked()
|
||||
{
|
||||
OnArtbookClicked?.Invoke();
|
||||
}
|
||||
|
||||
public Sequence Show()
|
||||
@@ -73,5 +84,10 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
{
|
||||
KillActive();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
artbookButton.onClick.RemoveListener(HandleArtbookClicked);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ namespace Darkmatter.Services.Capture
|
||||
{
|
||||
var paperCanvas = GetRootCanvas(captureObject);
|
||||
var disabledCanvases = DisableOtherRootCanvases(paperCanvas);
|
||||
var disabledGraphics = HideNonPaperGraphics(captureObject != null ? captureObject.transform : null);
|
||||
var cam = Camera.main;
|
||||
CameraClearFlags prevFlags = default;
|
||||
Color prevBg = default;
|
||||
@@ -26,7 +27,21 @@ namespace Darkmatter.Services.Capture
|
||||
|
||||
await UniTask.WaitForEndOfFrame(cancellationToken);
|
||||
|
||||
var fullScreen = ScreenCapture.CaptureScreenshotAsTexture();
|
||||
int sw = Screen.width;
|
||||
int sh = Screen.height;
|
||||
var captureRT = RenderTexture.GetTemporary(sw, sh, 0, RenderTextureFormat.ARGB32);
|
||||
ScreenCapture.CaptureScreenshotIntoRenderTexture(captureRT);
|
||||
|
||||
var prevActive = RenderTexture.active;
|
||||
RenderTexture.active = captureRT;
|
||||
var fullScreen = new Texture2D(sw, sh, TextureFormat.RGBA32, mipChain: false);
|
||||
fullScreen.ReadPixels(new Rect(0, 0, sw, sh), 0, 0);
|
||||
fullScreen.Apply();
|
||||
RenderTexture.active = prevActive;
|
||||
RenderTexture.ReleaseTemporary(captureRT);
|
||||
|
||||
FlipVertical(fullScreen);
|
||||
|
||||
try
|
||||
{
|
||||
Rect crop = ComputeCropRect(captureObject, fullScreen.width, fullScreen.height);
|
||||
@@ -62,6 +77,7 @@ namespace Darkmatter.Services.Capture
|
||||
finally
|
||||
{
|
||||
Object.Destroy(fullScreen);
|
||||
foreach (var g in disabledGraphics) if (g != null) g.enabled = true;
|
||||
foreach (var c in disabledCanvases) if (c != null) c.enabled = true;
|
||||
if (cam != null)
|
||||
{
|
||||
@@ -91,6 +107,21 @@ namespace Darkmatter.Services.Capture
|
||||
return disabled;
|
||||
}
|
||||
|
||||
private static List<UnityEngine.UI.Graphic> HideNonPaperGraphics(Transform paper)
|
||||
{
|
||||
var disabled = new List<UnityEngine.UI.Graphic>();
|
||||
if (paper == null) return disabled;
|
||||
var all = Object.FindObjectsByType<UnityEngine.UI.Graphic>(FindObjectsSortMode.None);
|
||||
foreach (var g in all)
|
||||
{
|
||||
if (g == null || !g.enabled) continue;
|
||||
if (g.transform.IsChildOf(paper)) continue;
|
||||
g.enabled = false;
|
||||
disabled.Add(g);
|
||||
}
|
||||
return disabled;
|
||||
}
|
||||
|
||||
private static Rect ComputeCropRect(GameObject target, int screenW, int screenH)
|
||||
{
|
||||
if (target == null || target.transform is not RectTransform rt)
|
||||
@@ -106,6 +137,18 @@ namespace Darkmatter.Services.Capture
|
||||
return Rect.MinMaxRect(minX, minY, maxX, maxY);
|
||||
}
|
||||
|
||||
private static void FlipVertical(Texture2D tex)
|
||||
{
|
||||
int w = tex.width, h = tex.height;
|
||||
var pixels = tex.GetPixels();
|
||||
var flipped = new Color[pixels.Length];
|
||||
for (int y = 0; y < h; y++)
|
||||
for (int x = 0; x < w; x++)
|
||||
flipped[(h - 1 - y) * w + x] = pixels[y * w + x];
|
||||
tex.SetPixels(flipped);
|
||||
tex.Apply();
|
||||
}
|
||||
|
||||
private static Texture2D Resize(Texture2D src, int width, int height)
|
||||
{
|
||||
var rt = RenderTexture.GetTemporary(width, height);
|
||||
|
||||
8
Assets/Darkmatter/Code/Services/Music.meta
Normal file
8
Assets/Darkmatter/Code/Services/Music.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27c2e817c276c40b19f6284b7c87860c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/Services/Music/Installers.meta
Normal file
8
Assets/Darkmatter/Code/Services/Music/Installers.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1d52cf6530064afd982535de65293bb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/Services/Music/Systems.meta
Normal file
8
Assets/Darkmatter/Code/Services/Music/Systems.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bec4745668fea4987809c8370d372048
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
20
Assets/Darkmatter/Code/Services/Music/Systems/MusicConfig.cs
Normal file
20
Assets/Darkmatter/Code/Services/Music/Systems/MusicConfig.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Services.Music.Systems
|
||||
{
|
||||
[Serializable]
|
||||
public readonly struct MusicConfig
|
||||
{
|
||||
public AudioClip DefaultTrack { get; }
|
||||
public float DefaultVolume { get; }
|
||||
public float CrossFadeSeconds { get; }
|
||||
|
||||
public MusicConfig(AudioClip defaultTrack, float defaultVolume, float crossFadeSeconds)
|
||||
{
|
||||
DefaultTrack = defaultTrack;
|
||||
DefaultVolume = defaultVolume;
|
||||
CrossFadeSeconds = crossFadeSeconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user