-
Notifications
You must be signed in to change notification settings - Fork 0
/
Popup.cs
48 lines (41 loc) · 866 Bytes
/
Popup.cs
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
using UnityEngine;
using System.Collections;
using UniRx;
public class Popup : MonoBehaviour
{
public enum State
{
Open,
Close,
UnUsed
}
public State state { get; private set; }
public TweenScale open, close;
void Start ()
{
open.Setup (gameObject);
open.scaleEndAsObservable.Subscribe (_ => state = State.Open);
close.Setup (gameObject);
close.scaleEndAsObservable.Subscribe (_ => state = State.Close);
}
public void Open ()
{
open.Play ();
}
public void Close ()
{
close.Play ();
}
public void Toggle ()
{
switch (state) {
case State.UnUsed:
case State.Close:
open.Play ();
break;
case State.Open:
close.Play ();
break;
}
}
}