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
|
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
using Boxophobic.StyledGUI;
using Boxophobic.Utils;
using System.IO;
namespace AtmosphericHeightFog
{
public class HeightFogHub : EditorWindow
{
#if UNITY_2019_3_OR_NEWER
const int GUI_HEIGHT = 18;
#else
const int GUI_HEIGHT = 14;
#endif
string folderAsset = "Assets/BOXOPHOBIC/Atmospheric Height Fog";
string[] pipelinePaths;
string[] pipelineOptions;
string pipelinesPath;
int pipelineIndex;
int assetVersion;
string bannerVersion;
GUIStyle stylePopup;
Color bannerColor;
string bannerText;
string helpURL;
static HeightFogHub window;
//Vector2 scrollPosition = Vector2.zero;
[MenuItem("Window/BOXOPHOBIC/Atmospheric Height Fog/Hub", false, 1000)]
public static void ShowWindow()
{
window = GetWindow<HeightFogHub>(false, "Atmospheric Height Fog", true);
window.minSize = new Vector2(389, 220);
}
void OnEnable()
{
bannerColor = new Color(0.55f, 0.7f, 1f);
bannerText = "Atmospheric Height Fog";
helpURL = "https://docs.google.com/document/d/1pIzIHIZ-cSh2ykODSZCbAPtScJ4Jpuu7lS3rNEHCLbc/edit#heading=h.hbq3w8ae720x";
//Safer search, there might be many user folders
string[] searchFolders;
searchFolders = AssetDatabase.FindAssets("Atmospheric Height Fog");
for (int i = 0; i < searchFolders.Length; i++)
{
if (AssetDatabase.GUIDToAssetPath(searchFolders[i]).EndsWith("Atmospheric Height Fog.pdf"))
{
folderAsset = AssetDatabase.GUIDToAssetPath(searchFolders[i]);
folderAsset = folderAsset.Replace("/Atmospheric Height Fog.pdf", "");
}
}
pipelinesPath = folderAsset + "/Core/Pipelines";
GetPackages();
assetVersion = SettingsUtils.LoadSettingsData(folderAsset + "/Core/Editor/Version.asset", -99);
bannerVersion = assetVersion.ToString();
bannerVersion = bannerVersion.Insert(1, ".");
bannerVersion = bannerVersion.Insert(3, ".");
bannerColor = new Color(0.55f, 0.7f, 1f);
bannerText = "Atmospheric Height Fog " + bannerVersion;
}
void OnGUI()
{
SetGUIStyles();
StyledGUI.DrawWindowBanner(bannerColor, bannerText, helpURL);
GUILayout.BeginHorizontal();
GUILayout.Space(20);
GUILayout.BeginVertical();
//scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false, GUILayout.Width(this.position.width - 28), GUILayout.Height(this.position.height - 80));
EditorGUILayout.HelpBox("Click the Import Render Pipeline to switch to another render pipeline. For Universal Render Pipeline, follow the instructions below to enable the fog rendering!", MessageType.Info, true);
if (pipelineOptions[pipelineIndex].Contains("Universal 7.1.8"))
{
EditorGUILayout.HelpBox("For Universal 7.1.8+ Pipeline, Depth Texture and one of the following features need to be enabled for the depth to work properly: Opaque Texure, HDR or Post Processing!", MessageType.Info, true);
}
if (pipelineOptions[pipelineIndex].Contains("Universal 7.4.1"))
{
EditorGUILayout.HelpBox("For Universal 7.4.1+ Pipeline, Depth Texture need to be enabled on the render pipeline asset!", MessageType.Info, true);
}
DrawInterface();
//GUILayout.EndScrollView();
GUILayout.EndVertical();
GUILayout.Space(13);
GUILayout.EndHorizontal();
}
void SetGUIStyles()
{
stylePopup = new GUIStyle(EditorStyles.popup)
{
alignment = TextAnchor.MiddleCenter
};
}
void DrawInterface()
{
GUILayout.Space(10);
GUILayout.BeginHorizontal();
EditorGUILayout.LabelField(new GUIContent("Render Pipeline", ""), GUILayout.Width(220));
pipelineIndex = EditorGUILayout.Popup(pipelineIndex, pipelineOptions, stylePopup);
if (GUILayout.Button("Import", GUILayout.Width(80), GUILayout.Height(GUI_HEIGHT)))
{
ImportPackage();
GUIUtility.ExitGUI();
}
GUILayout.EndHorizontal();
}
void GetPackages()
{
pipelinePaths = Directory.GetFiles(pipelinesPath, "*.unitypackage", SearchOption.TopDirectoryOnly);
pipelineOptions = new string[pipelinePaths.Length];
for (int i = 0; i < pipelineOptions.Length; i++)
{
pipelineOptions[i] = Path.GetFileNameWithoutExtension(pipelinePaths[i].Replace("Built-in Pipeline", "Standard"));
}
}
void ImportPackage()
{
AssetDatabase.ImportPackage(pipelinePaths[pipelineIndex], true);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
Debug.Log("[Atmospheric Height Fog] " + pipelineOptions[pipelineIndex] + " package imported in your project!");
}
}
}
|