열차 목업의 내부 확인용 프로젝트
smchoi
2024-06-14 3d45944b4b2abc384e2539fa72cd7925bbcf2543
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
//////////////////////////////////////////////////////
// MK Install Wizard Base                              //
//                                                    //
// Created by Michael Kremmel                       //
// www.michaelkremmel.de                            //
// Copyright © 2020 All rights reserved.            //
//////////////////////////////////////////////////////
 
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
 
#if UNITY_EDITOR
using Configuration = MK.Glow.Editor.InstallWizard.Configuration;
namespace MK.Glow.Editor.InstallWizard
{
    public sealed class InstallWizard : EditorWindow
    {
        #pragma warning disable CS0414
        private static readonly string _version = "4.6.4";
        #pragma warning restore CS0414
        
        private static readonly Vector2Int _referenceResolution = new Vector2Int(2560, 1440);
        private static float _sizeScale;
        private static int _scaledWidth;
        private static int _scaledHeight;
        private static Vector2 _windowScrollPos;
 
        private static readonly int _rawWidth = 360;
        private static readonly int _rawHeight = 640;
        private static readonly string _title = "MK Glow Lite Install Wizard";
 
        private GUIStyle _flowTextStyle { get { return new GUIStyle(EditorStyles.label) { wordWrap = true }; } }
        private static readonly int _loadTimeInFrames = 72;
        private static int _waitFramesTillReload = _loadTimeInFrames;
 
        private static InstallWizard _window;
        private static RenderPipeline _targetRenderPipeline = RenderPipeline.Built_in_PostProcessingStack;
        private static bool _showInstallerOnReload = true;
 
        [MenuItem("Window/MK/Glow Lite/Install Wizard")]
        private static void ShowWindow()
        {
            if(Screen.currentResolution.height > Screen.currentResolution.width)
                _sizeScale = (float) Screen.currentResolution.width / (float)_referenceResolution.x;
            else
                _sizeScale = (float) Screen.currentResolution.height / (float)_referenceResolution.y;
 
            _scaledWidth = (int)((float)_rawWidth * _sizeScale);
            _scaledHeight = (int)((float)_rawHeight * _sizeScale);
            _window = (InstallWizard)EditorWindow.GetWindow<InstallWizard>(true, _title, true);
            _window.minSize = new Vector2(_scaledWidth, _scaledHeight);
            _window.maxSize = new Vector2(_scaledWidth * 2, _scaledHeight * 2);
            _window.Show();
        }
 
        [InitializeOnLoadMethod]
        private static void ShowInstallerOnReload()
        {
            QueryReload();
        }
 
        private static void QueryReload()
        {
            _waitFramesTillReload = _loadTimeInFrames;
            EditorApplication.update += Reload;
        }
 
        private static void Reload()
        {
            if (_waitFramesTillReload > 0)
            {
                --_waitFramesTillReload;
            }
            else
            {
                EditorApplication.update -= Reload;
                if(Configuration.isReady && Configuration.TryGetShowInstallerOnReload())
                    ShowWindow();
            }
        }
 
        private void OnGUI()
        {
            if(Configuration.isReady)
            {
                _windowScrollPos = EditorGUILayout.BeginScrollView(_windowScrollPos);
                Texture2D titleImage = Configuration.TryGetTitleImage();
                if(titleImage)
                {
                    float titleScaledWidth = EditorGUIUtility.currentViewWidth - EditorGUIUtility.standardVerticalSpacing * 4;
                    float titleScaledHeight = titleScaledWidth * ((float)titleImage.height / (float)titleImage.width);
                    Rect titleRect = EditorGUILayout.GetControlRect();
                    titleRect.width = titleScaledWidth;
                    titleRect.height = titleScaledHeight;
                    GUI.DrawTexture(titleRect, titleImage, ScaleMode.ScaleToFit);
                    GUILayout.Label("", GUILayout.Height(titleScaledHeight - 20));
                    Divider();
                }
                EditorGUILayout.LabelField("1. Select your Render Pipeline", UnityEditor.EditorStyles.boldLabel);
                _targetRenderPipeline = Configuration.TryGetRenderPipeline();
                EditorGUI.BeginChangeCheck();
                _targetRenderPipeline = (RenderPipeline) EditorGUILayout.EnumPopup("Render Pipeline", _targetRenderPipeline);
                if(EditorGUI.EndChangeCheck())
                    Configuration.TrySetRenderPipeline(_targetRenderPipeline);
                VerticalSpace();
                Divider();
                VerticalSpace();
                EditorGUILayout.LabelField("2. Import / Update Package", UnityEditor.EditorStyles.boldLabel);
                if(GUILayout.Button("Import Package"))
                {
                    EditorUtility.DisplayProgressBar("MK Toon Install Wizard", "Importing Package", 0.5f);
                    Configuration.ImportShaders(_targetRenderPipeline);
                    EditorUtility.ClearProgressBar();
                }
                switch(_targetRenderPipeline)
                {
                    case RenderPipeline.Built_in_Legacy:
                    EditorGUILayout.LabelField("Attach the MK Glow component to your rendering camera.", _flowTextStyle);
                    break;
                    case RenderPipeline.Built_in_PostProcessingStack:
                    EditorGUILayout.LabelField("1. Make sure the Post Processing Stack is installed. It can be installed via the Package Manager (Window -> Package Manager)", _flowTextStyle);
                    EditorGUILayout.LabelField("2. On your Post Processing Stack Profile add the “MK/MKGlowLite” component.", _flowTextStyle);
                    break;
                    //case RenderPipeline.Lightweight:
                    //EditorGUILayout.LabelField("On your Post Processing Stack V2 Profile add the “MK/MKGlow” component.", _flowTextStyle);
                    //break;
                    case RenderPipeline.Universal3D:
                    #if UNITY_2021_2_OR_NEWER
                    case RenderPipeline.Universal2D:
                    #endif
                    EditorGUILayout.LabelField("1. On your Universal Render Pipeline Renderer Asset add the custom Renderer Feature: MK Glow Lite Renderer Feature.", _flowTextStyle);
                    EditorGUILayout.LabelField(@"2. On your Volume Profile add MK Glow Lite via “Post-processing/MK/MKGlowLite” (optional).", _flowTextStyle);
                    break;
                }
                VerticalSpace();
                Divider();
                VerticalSpace();
                int readMeNumber = 4;
                /*
                if(_targetRenderPipeline == RenderPipeline.Lightweight)
                {
                    readMeNumber = 3;
                    EditorGUILayout.LabelField("3. Examples are not available for the Lightweight Render Pipeline.", _flowTextStyle);
                    VerticalSpace();
                    Divider();
                }
                else
                */
                {
                    EditorGUILayout.LabelField("3. Import Examples (optional)", UnityEditor.EditorStyles.boldLabel);
                    EditorGUILayout.LabelField("Example Scenes are based on Linear Color Space and HDR. Make sure to change from Gamma to Linear Color Space and enable HDR.", _flowTextStyle);
                    switch(_targetRenderPipeline)
                    {
                        case RenderPipeline.Built_in_Legacy:
                        case RenderPipeline.Built_in_PostProcessingStack:
                        break;
                        //case RenderPipeline.Lightweight:
                        //break;
                        case RenderPipeline.Universal3D:
                        #if UNITY_2021_2_OR_NEWER
                        case RenderPipeline.Universal2D:
                        #endif
                        EditorGUILayout.LabelField("Example Scenes using the Post Process Volumes Workmode on the MK Glow Renderer Feature.", _flowTextStyle);
                        break;
                    }
                    EditorGUILayout.LabelField("Old Input Manager is used for the examples.", _flowTextStyle);
                    if(GUILayout.Button("Import Examples"))
                    {
                        EditorUtility.DisplayProgressBar("MK Toon Install Wizard", "Importing Examples", 0.5f);
                        Configuration.ImportExamples(_targetRenderPipeline);
                        EditorUtility.ClearProgressBar();
                    }
                    VerticalSpace();
                    Divider();
                    ExampleContainer[] examples = Configuration.TryGetExamples();
                    bool anyExamplesAvailable = false;
                    for(int i = 0; i < examples.Length; i++)
                    {
                        if(examples[i].scene != null)
                        {
                            anyExamplesAvailable = true;
                            break;
                        }
                    }
                    if(examples.Length > 0 && anyExamplesAvailable)
                    {
                        VerticalSpace();
                        EditorGUILayout.LabelField("Example Scenes:");
                        EditorGUILayout.BeginHorizontal();
                        for(int i = 0; i < examples.Length; i++)
                        {
                            if(examples[i].scene != null)
                                examples[i].DrawEditorButton();
                        }
                        EditorGUILayout.EndHorizontal();
                        VerticalSpace();
                        Divider();
                    }
                }
                VerticalSpace();
                EditorGUILayout.LabelField(readMeNumber.ToString() + ". Read Me (Recommended)", UnityEditor.EditorStyles.boldLabel);
                if(GUILayout.Button("Open Read Me"))
                {
                    Configuration.OpenReadMe();
                }
 
                VerticalSpace();
                Divider();
                VerticalSpace();
 
                _showInstallerOnReload = Configuration.TryGetShowInstallerOnReload();
                EditorGUI.BeginChangeCheck();
                _showInstallerOnReload = EditorGUILayout.Toggle("Show Installer On Reload", _showInstallerOnReload);
                if(EditorGUI.EndChangeCheck())
                    Configuration.TrySetShowInstallerOnReload(_showInstallerOnReload);
 
                EditorGUILayout.EndScrollView();
                GUI.FocusControl(null);
            }
            else
            {
                Repaint();
            }
        }
 
        private static void VerticalSpace()
        {
            GUILayoutUtility.GetRect(1f, EditorGUIUtility.standardVerticalSpacing);
        }
 
        private static void Divider()
        {
            GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(2) });
        }
    }
}
#endif