Skip to content

Commit 6ee72dd

Browse files
committed
Move
1 parent 791d34b commit 6ee72dd

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Juce.Core.Repositories;
2+
using Juce.Core.Sequencing;
3+
using Juce.CoreUnity.Ui.Frame;
4+
using Juce.CoreUnity.ViewStack.Entries;
5+
using System;
6+
7+
namespace Playground.Services.ViewStack.Instructions
8+
{
9+
public class MoveToForegroundInstruction : InstantInstruction
10+
{
11+
private readonly IUiFrame frame;
12+
private readonly IKeyValueRepository<Type, IViewStackEntry> entriesRepository;
13+
private readonly Type entryId;
14+
15+
public MoveToForegroundInstruction(
16+
IUiFrame frame,
17+
IKeyValueRepository<Type, IViewStackEntry> entriesRepository,
18+
Type entryId
19+
)
20+
{
21+
this.frame = frame;
22+
this.entriesRepository = entriesRepository;
23+
this.entryId = entryId;
24+
}
25+
26+
protected override void OnInstantExecute()
27+
{
28+
bool found = entriesRepository.TryGet(entryId, out IViewStackEntry entry);
29+
30+
if (!found)
31+
{
32+
UnityEngine.Debug.LogError($"Tried to Show {nameof(IViewStackEntry)} of type {entryId}, " +
33+
$"but it was not registered, at {nameof(MoveToBackgroundInstruction)}");
34+
35+
return;
36+
}
37+
38+
frame.MoveToForeground(entry.Transform);
39+
}
40+
}
41+
}

Runtime/Ui/ViewStack/Instructions/MoveToForegroundInstruction.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Ui/ViewStack/Sequences/ViewStackSequenceBuilder.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,19 @@ public IViewStackSequenceBuilder MoveToBackground<T>()
126126
return this;
127127
}
128128

129+
public IViewStackSequenceBuilder MoveToForeground<T>()
130+
{
131+
Type entryId = typeof(T);
132+
133+
instructionsToPlay.Add(new MoveToForegroundInstruction(
134+
frame,
135+
entriesRepository,
136+
entryId
137+
));
138+
139+
return this;
140+
}
141+
129142
public IViewStackSequenceBuilder SetInteractable<T>(bool set)
130143
{
131144
Type entryId = typeof(T);

0 commit comments

Comments
 (0)