portals and dash. Also a bit of terrain building and level design

This commit is contained in:
2022-03-13 00:26:35 +02:00
parent 813cd0c451
commit e82799c36a
6242 changed files with 2160679 additions and 188245 deletions

View File

@@ -0,0 +1,170 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine.Rendering;
#if UNITY_POST_PROCESSING_STACK_V2
using UnityEngine.Rendering.PostProcessing;
#endif
#if POSEIDON_URP
using UnityEngine.Rendering.Universal;
using Pinwheel.Poseidon.FX.Universal;
#endif
using System.Reflection;
namespace Pinwheel.Poseidon.FX
{
[CustomEditor(typeof(PWaterFX))]
public class PWaterFXInspector : Editor
{
private PWaterFX instance;
private void OnEnable()
{
instance = target as PWaterFX;
SceneView.duringSceneGui += DuringSceneGUI;
if (instance.Profile != null)
{
instance.UpdatePostProcessOrVolumeProfile();
}
}
private void OnDisable()
{
SceneView.duringSceneGui -= DuringSceneGUI;
}
public override void OnInspectorGUI()
{
bool willDrawGUI = false;
string msg = null;
if (PCommon.CurrentRenderPipeline == PRenderPipelineType.Builtin)
{
#if UNITY_POST_PROCESSING_STACK_V2
willDrawGUI = true;
#else
msg = "Please install Post Processing Stack V2 to setup water effect";
#endif
}
else if (PCommon.CurrentRenderPipeline == PRenderPipelineType.Universal)
{
#if POSEIDON_URP
willDrawGUI = true;
#endif
}
else
{
willDrawGUI = false;
msg = "Water effect doesn't support custom render pipeline.";
}
if (!willDrawGUI)
{
EditorGUILayout.LabelField(msg, PEditorCommon.WordWrapItalicLabel);
return;
}
#if POSEIDON_URP
if (PCommon.CurrentRenderPipeline == PRenderPipelineType.Universal)
{
if (!CheckRendererFeatureConfig())
{
EditorGUILayout.LabelField("Please add a Water Effect Renderer Feature to the current URP Asset to setup water effect.", PEditorCommon.WordWrapItalicLabel);
return;
}
}
#endif
instance.Water = EditorGUILayout.ObjectField("Water", instance.Water, typeof(PWater), true) as PWater;
instance.Profile = PEditorCommon.ScriptableObjectField<PWaterFXProfile>("Profile", instance.Profile);
if (instance.Water == null || instance.Profile == null)
return;
DrawVolumesGUI();
EditorGUI.BeginChangeCheck();
PWaterFXProfileInspectorDrawer.Create(instance.Profile, instance.Water).DrawGUI();
if (EditorGUI.EndChangeCheck())
{
instance.UpdatePostProcessOrVolumeProfile();
}
DrawEventsGUI();
}
#if POSEIDON_URP
private bool CheckRendererFeatureConfig()
{
UniversalRenderPipelineAsset uAsset = UniversalRenderPipeline.asset;
ScriptableRenderer renderer = uAsset.scriptableRenderer;
PropertyInfo rendererFeaturesProperty = renderer.GetType().GetProperty("rendererFeatures", BindingFlags.Instance | BindingFlags.NonPublic);
if (rendererFeaturesProperty != null)
{
List<ScriptableRendererFeature> rendererFeatures = rendererFeaturesProperty.GetValue(renderer) as List<ScriptableRendererFeature>;
if (rendererFeatures != null)
{
bool waterFxFeatureAdded = false;
for (int i=0;i<rendererFeatures.Count;++i)
{
if (rendererFeatures[i] is PWaterEffectRendererFeature)
{
waterFxFeatureAdded = true;
}
}
return waterFxFeatureAdded;
}
}
return true;
}
#endif
private void DrawVolumesGUI()
{
string label = "Volumes";
string id = "volumes" + instance.GetInstanceID();
PEditorCommon.Foldout(label, false, id, () =>
{
instance.VolumeExtent = PEditorCommon.InlineVector3Field("Extent", instance.VolumeExtent);
instance.VolumeLayer = EditorGUILayout.LayerField("Layer", instance.VolumeLayer);
});
}
private void DrawEventsGUI()
{
string label = "Events";
string id = "events" + instance.GetInstanceID();
PEditorCommon.Foldout(label, false, id, () =>
{
SerializedObject so = new SerializedObject(instance);
SerializedProperty sp0 = so.FindProperty("onEnterWater");
if (sp0 != null)
{
EditorGUILayout.PropertyField(sp0);
}
SerializedProperty sp1 = so.FindProperty("onExitWater");
if (sp1 != null)
{
EditorGUILayout.PropertyField(sp1);
}
so.ApplyModifiedProperties();
});
}
private void DuringSceneGUI(SceneView sv)
{
if (instance.Water == null || instance.Profile == null)
return;
Bounds waterBounds = instance.Water.Bounds;
Vector3 size = waterBounds.size + instance.VolumeExtent;
Color color = Handles.yAxisColor;
Matrix4x4 matrix = Matrix4x4.TRS(waterBounds.center + instance.transform.position, instance.transform.rotation, instance.transform.localScale);
using (var scope = new Handles.DrawingScope(color, matrix))
{
Handles.DrawWireCube(Vector3.zero, size);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c3726835830f7544e8fb1a79548b2761
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
namespace Pinwheel.Poseidon.FX
{
[CustomEditor(typeof(PWaterFXProfile))]
public class PWaterFXProfileInspector : Editor
{
private PWaterFXProfile instance;
private void OnEnable()
{
instance = target as PWaterFXProfile;
}
public override void OnInspectorGUI()
{
PWaterFXProfileInspectorDrawer.Create(instance, null).DrawGUI();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b29231a8f69bc3e46ba5e8c572478c00
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,114 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
namespace Pinwheel.Poseidon.FX
{
public class PWaterFXProfileInspectorDrawer
{
private PWaterFXProfile instance;
private PWater water;
private PWaterFXProfileInspectorDrawer(PWaterFXProfile instance, PWater water)
{
this.instance = instance;
this.water = water;
}
public static PWaterFXProfileInspectorDrawer Create(PWaterFXProfile instance, PWater water)
{
return new PWaterFXProfileInspectorDrawer(instance, water);
}
public void DrawGUI()
{
EditorGUI.BeginChangeCheck();
DrawUnderwaterGUI();
DrawWetLensGUI();
if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(instance);
}
}
private void DrawUnderwaterGUI()
{
string label = "Underwater";
string id = "underwater" + instance.GetInstanceID();
PEditorCommon.Foldout(label, false, id, () =>
{
instance.EnableUnderwater = EditorGUILayout.Toggle("Enable", instance.EnableUnderwater);
if (instance.EnableUnderwater)
{
PEditorCommon.SpacePixel(0);
EditorGUILayout.LabelField("Water Body", PEditorCommon.BoldHeader);
instance.UnderwaterMaxDepth = EditorGUILayout.FloatField("Max Depth", instance.UnderwaterMaxDepth);
instance.UnderwaterSurfaceColorBoost = EditorGUILayout.Slider("Surface Color Boost", instance.UnderwaterSurfaceColorBoost, 1f, 3f);
PEditorCommon.SpacePixel(0);
EditorGUILayout.LabelField("Fog", PEditorCommon.BoldHeader);
instance.UnderwaterShallowFogColor = EditorGUILayout.ColorField("Shallow Fog Color", instance.UnderwaterShallowFogColor);
instance.UnderwaterDeepFogColor = EditorGUILayout.ColorField("Deep Fog Color", instance.UnderwaterDeepFogColor);
instance.UnderwaterViewDistance = EditorGUILayout.FloatField("View Distance", instance.UnderwaterViewDistance);
PEditorCommon.SpacePixel(0);
EditorGUILayout.LabelField("Caustic", PEditorCommon.BoldHeader);
instance.UnderwaterEnableCaustic = EditorGUILayout.Toggle("Enable", instance.UnderwaterEnableCaustic);
if (instance.UnderwaterEnableCaustic)
{
instance.UnderwaterCausticTexture = PEditorCommon.InlineTextureField("Texture", instance.UnderwaterCausticTexture, -1);
instance.UnderwaterCausticSize = EditorGUILayout.FloatField("Size", instance.UnderwaterCausticSize);
instance.UnderwaterCausticStrength = EditorGUILayout.Slider("Strength", instance.UnderwaterCausticStrength, 0f, 1f);
}
PEditorCommon.SpacePixel(0);
EditorGUILayout.LabelField("Distortion", PEditorCommon.BoldHeader);
instance.UnderwaterEnableDistortion = EditorGUILayout.Toggle("Enable", instance.UnderwaterEnableDistortion);
if (instance.UnderwaterEnableDistortion)
{
instance.UnderwaterDistortionTexture = PEditorCommon.InlineTextureField("Normal Map", instance.UnderwaterDistortionTexture, -1);
instance.UnderwaterDistortionStrength = EditorGUILayout.FloatField("Strength", instance.UnderwaterDistortionStrength);
instance.UnderwaterWaterFlowSpeed = EditorGUILayout.FloatField("Water Flow Speed", instance.UnderwaterWaterFlowSpeed);
}
PEditorCommon.Separator();
}
if (water != null && instance.EnableUnderwater)
{
GUI.enabled = water.Profile != null;
if (GUILayout.Button("Inherit Parameters"))
{
instance.UnderwaterMaxDepth = water.Profile.MaxDepth;
instance.UnderwaterShallowFogColor = water.Profile.Color;
instance.UnderwaterDeepFogColor = water.Profile.DepthColor;
instance.UnderwaterEnableCaustic = water.Profile.EnableCaustic;
instance.UnderwaterCausticTexture = water.Profile.CausticTexture;
instance.UnderwaterCausticSize = water.Profile.CausticSize;
instance.UnderwaterCausticStrength = water.Profile.CausticStrength;
}
GUI.enabled = true;
}
});
}
private void DrawWetLensGUI()
{
string label = "Wet Lens";
string id = "wet-lens" + instance.GetInstanceID();
PEditorCommon.Foldout(label, false, id, () =>
{
instance.EnableWetLens = EditorGUILayout.Toggle("Enable", instance.EnableWetLens);
if (instance.EnableWetLens)
{
instance.WetLensNormalMap = PEditorCommon.InlineTextureField("Normal Map", instance.WetLensNormalMap, -1);
instance.WetLensStrength = EditorGUILayout.Slider("Strength", instance.WetLensStrength, 0f, 1f);
instance.WetLensDuration = EditorGUILayout.FloatField("Duration", instance.WetLensDuration);
instance.WetLensFadeCurve = EditorGUILayout.CurveField("Fade", instance.WetLensFadeCurve, Color.red, new Rect(0, 0, 1, 1));
}
});
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b391a0bf945395e44b4087de4fc66d76
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: