summaryrefslogtreecommitdiff
path: root/Assets/BOXOPHOBIC/Atmospheric Height Fog/Core/Editor/HeightFogCreate.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-11-26 20:52:34 +0800
committerchai <chaifix@163.com>2020-11-26 20:52:34 +0800
commit5b158af90739dcbb89c1538a6cb8c65a875dce80 (patch)
treef0437fff6efaab91ac850152a08aef288d572aab /Assets/BOXOPHOBIC/Atmospheric Height Fog/Core/Editor/HeightFogCreate.cs
parentbc4d5201fc537f70cdcb576b57aaeb5d96527112 (diff)
*misc
Diffstat (limited to 'Assets/BOXOPHOBIC/Atmospheric Height Fog/Core/Editor/HeightFogCreate.cs')
-rw-r--r--Assets/BOXOPHOBIC/Atmospheric Height Fog/Core/Editor/HeightFogCreate.cs111
1 files changed, 111 insertions, 0 deletions
diff --git a/Assets/BOXOPHOBIC/Atmospheric Height Fog/Core/Editor/HeightFogCreate.cs b/Assets/BOXOPHOBIC/Atmospheric Height Fog/Core/Editor/HeightFogCreate.cs
new file mode 100644
index 00000000..bc273fca
--- /dev/null
+++ b/Assets/BOXOPHOBIC/Atmospheric Height Fog/Core/Editor/HeightFogCreate.cs
@@ -0,0 +1,111 @@
+// Cristian Pop - https://boxophobic.com/
+
+using UnityEditor;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+
+namespace AtmosphericHeightFog
+{
+ public class HeightFogCreate
+ {
+ [MenuItem("GameObject/BOXOPHOBIC/Atmospheric Height Fog/Global", false, 9)]
+ static void CreateGlobalVolume()
+ {
+ if (GameObject.Find("Height Fog Global") != null)
+ {
+ Debug.Log("[Atmospheric Height Fog] " + "Height Fog Global is already added to your scene!");
+ return;
+ }
+
+ GameObject go = new GameObject();
+ go.name = "Height Fog Global";
+ go.AddComponent<HeightFogGlobal>();
+
+ if (Selection.activeGameObject != null)
+ {
+ go.transform.parent = Selection.activeGameObject.transform;
+ }
+
+ Selection.activeGameObject = go;
+
+ EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
+ }
+
+ [MenuItem("GameObject/BOXOPHOBIC/Atmospheric Height Fog/Override Volume (Box)", false, 10)]
+ static void CreateOverrideBoxVolume()
+ {
+ if (GameObject.Find("Height Fog Global") == null)
+ {
+ Debug.Log("[Atmospheric Height Fog] " + "Height Fog Global must be added to the scene first!");
+ return;
+ }
+
+ GameObject go = new GameObject();
+ go.name = "Height Fog Override (Box)";
+ go.AddComponent<BoxCollider>();
+ go.GetComponent<BoxCollider>().isTrigger = true;
+ go.AddComponent<HeightFogOverride>();
+
+ var sceneCamera = SceneView.lastActiveSceneView.camera;
+
+ if (sceneCamera != null)
+ {
+ go.transform.position = sceneCamera.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 10f));
+ }
+ else
+ {
+ go.transform.localPosition = Vector3.zero;
+ go.transform.localEulerAngles = Vector3.zero;
+ go.transform.localScale = Vector3.one;
+ }
+
+ if (Selection.activeGameObject != null)
+ {
+ go.transform.parent = Selection.activeGameObject.transform;
+ }
+
+ Selection.activeGameObject = go;
+
+ EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
+ }
+
+ [MenuItem("GameObject/BOXOPHOBIC/Atmospheric Height Fog/Override Volume (Sphere)", false, 11)]
+ static void CreateOverrideSphereVolume()
+ {
+ if (GameObject.Find("Height Fog Global") == null)
+ {
+ Debug.Log("[Atmospheric Height Fog] " + "Height Fog Global must be added to the scene first!");
+ return;
+ }
+
+ GameObject go = new GameObject();
+ go.name = "Height Fog Override (Sphere)";
+ go.AddComponent<SphereCollider>();
+ go.GetComponent<SphereCollider>().isTrigger = true;
+ go.AddComponent<HeightFogOverride>();
+
+ var sceneCamera = SceneView.lastActiveSceneView.camera;
+
+ if (sceneCamera != null)
+ {
+ go.transform.position = sceneCamera.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 10f));
+ }
+ else
+ {
+ go.transform.localPosition = Vector3.zero;
+ go.transform.localEulerAngles = Vector3.zero;
+ go.transform.localScale = Vector3.one;
+ }
+
+ if (Selection.activeGameObject != null)
+ {
+ go.transform.parent = Selection.activeGameObject.transform;
+ }
+
+ Selection.activeGameObject = go;
+
+ EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
+ }
+ }
+}
+