forked from homuler/MediaPipeUnityPlugin
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathModal.cs
More file actions
61 lines (52 loc) · 1.13 KB
/
Copy pathModal.cs
File metadata and controls
61 lines (52 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) 2021 homuler
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
using UnityEngine;
namespace Mediapipe.Unity.UI
{
public class Modal : MonoBehaviour
{
[SerializeField] private Solution _solution;
private GameObject _contents;
public void Open(GameObject contents)
{
_contents = Instantiate(contents, gameObject.transform);
_contents.transform.localScale = new Vector3(0.8f, 0.8f, 1);
gameObject.SetActive(true);
}
public void OpenAndPause(GameObject contents)
{
Open(contents);
if (_solution != null)
{
_solution.Pause();
}
}
public void Close()
{
gameObject.SetActive(false);
if (_contents != null)
{
Destroy(_contents);
}
}
public void CloseAndResume(bool forceRestart = false)
{
Close();
if (_solution == null)
{
return;
}
if (forceRestart)
{
_solution.Play();
}
else
{
_solution.Resume();
}
}
}
}