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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class InGameManager : MonoBehaviour
{
    private static InGameManager _instance;
 
    public static InGameManager Instance
    {
        get
        {
            if(_instance == null)
            {
                _instance = GameObject.FindObjectOfType(typeof(InGameManager)) as InGameManager;
                if (_instance == null)
                {
                    GameObject ingameManager = new GameObject();
                    ingameManager.name = "InGameManager";
                    _instance = ingameManager.AddComponent<InGameManager>();
                }
            }
            return _instance;
        }
    }
 
    private void Awake()
    {
        DontDestroyOnLoad(this);
    }
 
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 
 

 

Posted by Dongkey
,
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine;
using System;
 
public class CameraFade : MonoBehaviour
{
    public event Action OnFadeComplete;  //Camera Fade In,Out 완료시 호출
 
    [SerializeField] private bool fadeInOnStart = true;
    [SerializeField] private bool fadeInOnSceneLoad = false;
 
    [SerializeField] private float fadeDuration = 2f;
 
    [SerializeField] private Image fadeImage;
    [SerializeField] private Color fadeColor = Color.black;
 
    private bool isFading;
    private float fadeStartTime;
    private Color fadeOutColor;
 
    public bool IsFading
    {
        get
        {
            return isFading;
        }
    }
 
    private void Awake()
    {
        SceneManager.sceneLoaded += HandleSceneLoaded;
 
        fadeOutColor = new Color(fadeColor.r, fadeColor.g, fadeColor.b, 0f);
        fadeImage.enabled = true;
    }
 
 
    // Start is called before the first frame update
    void Start()
    {
        if(fadeInOnStart)
        {
            fadeImage.color = fadeColor;
            FadeIn();    
        }
    }
 
    private void HandleSceneLoaded(Scene arg0, LoadSceneMode arg1)
    {
        if(fadeInOnSceneLoad)
        {
            fadeImage.color = fadeColor;
            FadeIn();
        }
    }
 
 
    public void FadeIn()
    {
        if (isFading)
            return;
 
        StartCoroutine(BeginFade(fadeColor, fadeOutColor, fadeDuration));
    }
 
    public void FadeOut()
    {
        if (isFading)
            return;
 
        StartCoroutine(BeginFade(fadeOutColor,fadeColor, fadeDuration));
    }
 
    public IEnumerator BeginFadeOut()
    {
        yield return StartCoroutine(BeginFade(fadeOutColor, fadeColor, fadeDuration));
    }
 
    public IEnumerator BeginFadeIn()
    {
        yield return StartCoroutine(BeginFade(fadeColor, fadeOutColor, fadeDuration));
    }
 
    private IEnumerator BeginFade(Color startCol, Color endCol , float duration)
    {
        //Start Fade
        isFading = true;
 
        float timer = 0f;
        while(timer <= duration)
        {
            fadeImage.color = Color.Lerp(startCol, endCol, timer / duration);
 
            timer += Time.deltaTime;
 
            yield return null;
        }
 
        isFading = false;
 
        if (OnFadeComplete != null)
            OnFadeComplete();
    }
 
    private void OnDestroy()
    {
        SceneManager.sceneLoaded -= HandleSceneLoaded;
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 
Posted by Dongkey
,

C++ standard output에 대해서 알아보겠습니다.


조정자(Manipulator)

#include <iostream> 안에 있는 조정자

  • showbase/noshowbase
출력의 진법을 표기
  • showpos/noshowpos (pos -> positive)
양수 일때 + 표기/표기X
  • dec(decimal) 
10진수로 표기
  • hex(hexa decimal) 
16진수로 표기
  • oct(octal decimal) 
8진수로 표기
  • uppercase/noupeercase
대문자로 표기
  • left/internal/right
왼쪽 정렬 / 내부 정렬(부호는 왼쪽,숫자는 오른쪽)/ 오른쪽 정렬
  • showpoint/noshowpoint
소수점 값 표기 / 소수점 값 없으면 표기X 
ex)  showpoint 경우 10.1 -> 10.100
noshowpoint 경우 10.1 -> 10.1

  • fixed/scientific
고정적으로 표기 / 과학적으로 표기 ( 123.456789 -> 1.234568E+02 )

  • boolalpha / noboolalpha
true,false 로 표기 / 값으로 표기 (1,0)

#include <iomanip>
함수처럼 매개변수를 받음
  • setw(n)
n만큼의 공간차지


  • setfill(char형)

빈공간의 char형 문자를 채우기


  • setprecision(n)
n만큼의 유효한 소수점 표기



//실행 예제 코드

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
#include <iostream>
#include <iomanip>
 
using namespace std;
 
int main()
{
    int num = 1234;
 
    cout << showbase << dec << num << endl;        //1234
    cout << showbase << oct << num << endl;        //02322
    cout << showbase << hex << num << endl;        //0x4d2
 
    cout << noshowbase << dec << endl;            //초기화&줄맞춤
 
    cout << showpos << num << endl;                //+1234
    cout << noshowpos << num << endl;            //1234
    
    cout << endl;                                //줄맞춤
 
    cout << uppercase << hex << num << endl;    //4D2
    cout << nouppercase << hex << num << endl;    //4d2
    
    cout << noshowbase << dec << endl;            //초기화&줄맞춤
 
    cout << setw(6<< left << -num << endl;    //-1234
    cout << setw(6<< internal << -num << endl;//- 1234
    cout << setw(6<< right << -num << endl;    // -1234
    
    cout << endl;                                //줄맞춤
 
 
    float decimal1 = 10.0f;
    float decimal2 = 10.12f;
 
    cout << noshowpoint << decimal1 << " " << decimal2 << endl//10      10.12
    cout << showpoint << decimal1 << " " << decimal2 << endl;    //10.0000 10.1200
 
    cout << fixed << decimal2 << endl;                //10.120000
    cout << scientific << decimal2 << endl;            //1.012000e+01
 
    bool boolean = true;
 
    cout << fixed << endl;                                    //줄맞춤
 
    cout << boolalpha << boolean << endl;            //true
    cout << noboolalpha << boolean << endl;            //1
 
    cout << endl;                                    //줄맞춤
 
    cout << setfill('*'<< setw(6<< num << endl;    //**1234
 
    cout << endl;                                    //줄맞춤
 
    cout << setprecision(7<< decimal2 << endl;    //10.1199999
 
    system("pause");
 
    return 0;
}
cs


'프로그래밍 > C++' 카테고리의 다른 글

C++ namespace/using  (0) 2019.01.02
Posted by Dongkey
,