备份CatanBuilding瘦身独立工程
This commit is contained in:
@@ -0,0 +1,262 @@
|
||||
//Stylized Water 2
|
||||
//Staggart Creations (http://staggart.xyz)
|
||||
//Copyright protected under Unity Asset Store EULA
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
using PrefabStageUtility = UnityEditor.SceneManagement.PrefabStageUtility;
|
||||
#else
|
||||
using PrefabStageUtility = UnityEditor.Experimental.SceneManagement.PrefabStageUtility;
|
||||
#endif
|
||||
|
||||
namespace StylizedWater2
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(AlignToWaves))]
|
||||
public class AlignToWavesInspector : Editor
|
||||
{
|
||||
AlignToWaves script;
|
||||
|
||||
SerializedProperty waterObject;
|
||||
SerializedProperty autoFind;
|
||||
SerializedProperty dynamicMaterial;
|
||||
SerializedProperty waterLevelSource;
|
||||
SerializedProperty waterLevel;
|
||||
SerializedProperty childTransform;
|
||||
|
||||
SerializedProperty heightOffset;
|
||||
SerializedProperty rollAmount;
|
||||
|
||||
SerializedProperty samples;
|
||||
|
||||
private bool editSamples;
|
||||
private bool isRiver;
|
||||
private bool wavesEnabled;
|
||||
|
||||
private string proSkinPrefix => EditorGUIUtility.isProSkin ? "d_" : "";
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
script = (AlignToWaves)target;
|
||||
|
||||
waterObject = serializedObject.FindProperty("waterObject");
|
||||
autoFind = serializedObject.FindProperty("autoFind");
|
||||
dynamicMaterial = serializedObject.FindProperty("dynamicMaterial");
|
||||
waterLevelSource = serializedObject.FindProperty("waterLevelSource");
|
||||
waterLevel = serializedObject.FindProperty("waterLevel");
|
||||
childTransform = serializedObject.FindProperty("childTransform");
|
||||
heightOffset = serializedObject.FindProperty("heightOffset");
|
||||
rollAmount = serializedObject.FindProperty("rollAmount");
|
||||
samples = serializedObject.FindProperty("samples");
|
||||
|
||||
//Auto fetch if there is only one water body in the scene
|
||||
if (waterObject.objectReferenceValue == null && WaterObject.Instances.Count == 1)
|
||||
{
|
||||
serializedObject.Update();
|
||||
waterObject.objectReferenceValue = WaterObject.Instances[0];
|
||||
EditorUtility.SetDirty(target);
|
||||
serializedObject.ApplyModifiedPropertiesWithoutUndo();
|
||||
}
|
||||
|
||||
ValidateMaterial();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
AlignToWaves.Disable = false;
|
||||
Tools.hidden = false;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
UI.DrawHeader();
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Space(EditorGUIUtility.labelWidth);
|
||||
AlignToWaves.EnableInEditor =
|
||||
GUILayout.Toggle(AlignToWaves.EnableInEditor, new GUIContent(" Run in edit-mode (global)", EditorGUIUtility.IconContent(
|
||||
(AlignToWaves.EnableInEditor ? "animationvisibilitytoggleon" : "animationvisibilitytoggleoff")).image), "Button");
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(waterObject);
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(autoFind);
|
||||
EditorGUILayout.PropertyField(dynamicMaterial);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
UI.DrawNotification(isRiver, "Material has river mode enabled, buoyancy only works for flat water bodies", MessageType.Error);
|
||||
UI.DrawNotification(!wavesEnabled && !isRiver, "Material used on the water object does not have waves enabled.", MessageType.Error);
|
||||
|
||||
if (script.waterObject && script.waterObject.material)
|
||||
{
|
||||
UI.DrawNotification((script.waterObject.material.GetFloat("_WorldSpaceUV") == 0f), "Material must use world-projected UV", "Change", ()=> script.waterObject.material.SetFloat("_WorldSpaceUV", 1f), MessageType.Error);
|
||||
}
|
||||
|
||||
if(!autoFind.boolValue && waterObject.objectReferenceValue == null)
|
||||
{
|
||||
UI.DrawNotification("A water object must be assigned!", MessageType.Error);
|
||||
}
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.PrefixLabel("Water level source");
|
||||
waterLevelSource.intValue = GUILayout.Toolbar(waterLevelSource.intValue, new GUIContent[] { new GUIContent("Fixed Value"), new GUIContent("Water Object") });
|
||||
}
|
||||
if (waterLevelSource.intValue == (int)AlignToWaves.WaterLevelSource.FixedValue) EditorGUILayout.PropertyField(waterLevel);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.PropertyField(heightOffset);
|
||||
EditorGUILayout.PropertyField(rollAmount);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField("Sample positions", EditorStyles.boldLabel);
|
||||
|
||||
if (targets.Length > 1)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Cannot be modified for a multi-selection", MessageType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (samples.arraySize > 0)
|
||||
{
|
||||
editSamples =
|
||||
GUILayout.Toggle(editSamples,
|
||||
new GUIContent(" Edit samples", EditorGUIUtility.IconContent("sv_icon_dot0_pix16_gizmo").image),
|
||||
"Button", GUILayout.MaxWidth(125f), GUILayout.MaxHeight(30f));
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("No sample positions added. The transform's pivot position is used", MessageType.None);
|
||||
}
|
||||
|
||||
for (int i = 0; i < samples.arraySize; i++)
|
||||
{
|
||||
SerializedProperty param = samples.GetArrayElementAtIndex(i);
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.PropertyField(param, true);
|
||||
|
||||
if (GUILayout.Button(new GUIContent("",
|
||||
EditorGUIUtility.IconContent(proSkinPrefix + "TreeEditor.Trash").image, "Delete item"), GUILayout.MaxWidth(30f)))
|
||||
{
|
||||
samples.DeleteArrayElementAtIndex(i);
|
||||
selectedSampleIndex = -1;
|
||||
|
||||
EditorUtility.SetDirty(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button(new GUIContent("Add", EditorGUIUtility.IconContent(proSkinPrefix + "Toolbar Plus").image, "Add new sample point")))
|
||||
{
|
||||
samples.InsertArrayElementAtIndex(samples.arraySize);
|
||||
selectedSampleIndex = samples.arraySize - 1;
|
||||
|
||||
EditorUtility.SetDirty(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(childTransform);
|
||||
if (childTransform.objectReferenceValue == null && samples.arraySize > 0)
|
||||
UI.DrawNotification("Assign a transform to rotate/scale the sample positions with");
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
ValidateMaterial();
|
||||
}
|
||||
|
||||
UI.DrawFooter();
|
||||
}
|
||||
|
||||
private void ValidateMaterial()
|
||||
{
|
||||
if (script.waterObject && script.waterObject.material)
|
||||
{
|
||||
if (script.waterObject.material != script.waterObject.meshRenderer.sharedMaterial) script.waterObject.material = script.waterObject.meshRenderer.sharedMaterial;
|
||||
|
||||
wavesEnabled = WaveParameters.WavesEnabled(script.waterObject.material);
|
||||
isRiver = script.waterObject.material.IsKeywordEnabled("_RIVER");
|
||||
}
|
||||
}
|
||||
|
||||
private int selectedSampleIndex;
|
||||
Vector3 sampleWorldPos;
|
||||
Vector3 prevSampleWorldPos;
|
||||
|
||||
private void OnSceneGUI()
|
||||
{
|
||||
if (!script) return;
|
||||
|
||||
AlignToWaves.Disable = PrefabStageUtility.GetCurrentPrefabStage() != null || editSamples;
|
||||
|
||||
if (editSamples)
|
||||
{
|
||||
//Mute default controls
|
||||
Tools.hidden = true;
|
||||
|
||||
Handles.color = new Color(0.66f, 0.66f, 0.66f, 1);
|
||||
|
||||
for (int i = 0; i < script.samples.Count; i++)
|
||||
{
|
||||
sampleWorldPos = script.ConvertToWorldSpace(script.samples[i]);
|
||||
|
||||
float size = HandleUtility.GetHandleSize(sampleWorldPos) * 0.25f;
|
||||
if (Handles.Button(sampleWorldPos, Quaternion.identity, size, size, Handles.SphereHandleCap))
|
||||
{
|
||||
selectedSampleIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedSampleIndex > -1)
|
||||
{
|
||||
sampleWorldPos = script.ConvertToWorldSpace(script.samples[selectedSampleIndex]);
|
||||
prevSampleWorldPos = sampleWorldPos;
|
||||
|
||||
sampleWorldPos = Handles.PositionHandle(sampleWorldPos, script.childTransform ? script.childTransform.rotation : script.transform.rotation );
|
||||
script.samples[selectedSampleIndex] = script.ConvertToLocalSpace(sampleWorldPos);
|
||||
|
||||
//If moved
|
||||
if (sampleWorldPos != prevSampleWorldPos)
|
||||
{
|
||||
prevSampleWorldPos = sampleWorldPos;
|
||||
EditorUtility.SetDirty(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedSampleIndex = -1;
|
||||
Tools.hidden = false;
|
||||
|
||||
if (script.samples == null) return;
|
||||
|
||||
Handles.color = new Color(1,1,1, 0.25f);
|
||||
for (int i = 0; i < script.samples.Count; i++)
|
||||
{
|
||||
sampleWorldPos = script.ConvertToWorldSpace(script.samples[i]);
|
||||
Handles.SphereHandleCap(0, sampleWorldPos, SceneView.lastActiveSceneView.camera.transform.rotation, HandleUtility.GetHandleSize(sampleWorldPos) * 0.25f, EventType.Repaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6551d287f84686b47a644eabc2efd2c8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 148978298399363526, guid: 0000000000000000d000000000000000, type: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,350 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.XR;
|
||||
|
||||
namespace StylizedWater2
|
||||
{
|
||||
[CustomEditor(typeof(PlanarReflectionRenderer))]
|
||||
public class PlanarReflectionRendererInspector : Editor
|
||||
{
|
||||
private PlanarReflectionRenderer renderer;
|
||||
|
||||
//Rendering
|
||||
private SerializedProperty rotatable;
|
||||
private SerializedProperty cullingMask;
|
||||
private SerializedProperty rendererIndex;
|
||||
private SerializedProperty offset;
|
||||
private SerializedProperty includeSkybox;
|
||||
private SerializedProperty enableFog;
|
||||
|
||||
//Quality
|
||||
private SerializedProperty renderShadows;
|
||||
private SerializedProperty renderRange;
|
||||
private SerializedProperty renderScale;
|
||||
private SerializedProperty maximumLODLevel;
|
||||
|
||||
private SerializedProperty waterObjects;
|
||||
private SerializedProperty moveWithTransform;
|
||||
|
||||
private Bounds curBounds;
|
||||
private bool waterLayerError;
|
||||
|
||||
private bool previewReflection
|
||||
{
|
||||
get => EditorPrefs.GetBool("SWS2_PREVIEW_REFLECTION_ENABLED", true);
|
||||
set => EditorPrefs.SetBool("SWS2_PREVIEW_REFLECTION_ENABLED", value);
|
||||
}
|
||||
private RenderTexture previewTexture;
|
||||
|
||||
#if URP
|
||||
private void OnEnable()
|
||||
{
|
||||
PipelineUtilities.RefreshRendererList();
|
||||
|
||||
renderer = (PlanarReflectionRenderer)target;
|
||||
|
||||
rotatable = serializedObject.FindProperty("rotatable");
|
||||
cullingMask = serializedObject.FindProperty("cullingMask");
|
||||
rendererIndex = serializedObject.FindProperty("rendererIndex");
|
||||
offset = serializedObject.FindProperty("offset");
|
||||
includeSkybox = serializedObject.FindProperty("includeSkybox");
|
||||
enableFog = serializedObject.FindProperty("enableFog");
|
||||
renderShadows = serializedObject.FindProperty("renderShadows");
|
||||
renderRange = serializedObject.FindProperty("renderRange");
|
||||
renderScale = serializedObject.FindProperty("renderScale");
|
||||
maximumLODLevel = serializedObject.FindProperty("maximumLODLevel");
|
||||
waterObjects = serializedObject.FindProperty("waterObjects");
|
||||
moveWithTransform = serializedObject.FindProperty("moveWithTransform");
|
||||
|
||||
if (renderer.waterObjects.Count == 0 && WaterObject.Instances.Count == 1)
|
||||
{
|
||||
renderer.waterObjects.Add(WaterObject.Instances[0]);
|
||||
renderer.RecalculateBounds();
|
||||
renderer.EnableMaterialReflectionSampling();
|
||||
|
||||
EditorUtility.SetDirty(target);
|
||||
serializedObject.ApplyModifiedPropertiesWithoutUndo();
|
||||
}
|
||||
|
||||
ValidateWaterObjectLayer();
|
||||
|
||||
curBounds = renderer.CalculateBounds();
|
||||
|
||||
RenderPipelineManager.endCameraRendering += OnEndCameraRendering;
|
||||
}
|
||||
|
||||
private Camera currentCamera;
|
||||
private string currentCameraName;
|
||||
private bool waterObjectsVisible;
|
||||
|
||||
private void OnEndCameraRendering(ScriptableRenderContext context, Camera camera)
|
||||
{
|
||||
if (!previewReflection) return;
|
||||
|
||||
if (PlanarReflectionRenderer.InvalidContext(camera)) return;
|
||||
|
||||
currentCamera = camera;
|
||||
|
||||
waterObjectsVisible = renderer.WaterObjectsVisible(currentCamera);
|
||||
|
||||
previewTexture = renderer.TryGetReflectionTexture(currentCamera);
|
||||
currentCameraName = currentCamera.name;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
RenderPipelineManager.endCameraRendering -= OnEndCameraRendering;
|
||||
}
|
||||
#endif
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
#if !URP
|
||||
UI.DrawNotification("The Universal Render Pipeline package v" + AssetInfo.MIN_URP_VERSION + " or newer is not installed", MessageType.Error);
|
||||
#else
|
||||
UI.DrawHeader();
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Space(EditorGUIUtility.labelWidth);
|
||||
previewReflection =
|
||||
GUILayout.Toggle(previewReflection, new GUIContent(" Preview reflection", EditorGUIUtility.IconContent(
|
||||
(previewReflection ? "animationvisibilitytoggleon" : "animationvisibilitytoggleoff")).image), "Button");
|
||||
}
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Space(EditorGUIUtility.labelWidth);
|
||||
EditorGUILayout.LabelField("Status: " + (waterObjectsVisible && currentCamera ? $"Rendering (camera: {currentCamera.name})" : "Not rendering (water not in view for any camera)"), EditorStyles.miniLabel);
|
||||
}
|
||||
|
||||
UI.DrawNotification(PipelineUtilities.VREnabled(), "Not supported with VR rendering", MessageType.Error);
|
||||
|
||||
UI.DrawNotification(PlanarReflectionRenderer.AllowReflections == false, "Reflections have been globally disabled by an external script", MessageType.Warning);
|
||||
|
||||
serializedObject.Update();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.LabelField("Rendering", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
UI.DrawRendererProperty(rendererIndex);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
renderer.SetRendererIndex(rendererIndex.intValue);
|
||||
}
|
||||
|
||||
//Default renderer
|
||||
if (rendererIndex.intValue == 0)
|
||||
{
|
||||
UI.DrawNotification("\n" +
|
||||
"Using the default renderer for reflections is strongly discouraged." +
|
||||
"\n\nMost (if not all) render features, such as third-party post processing effects, will also render for the reflection." +
|
||||
"\n\nThis can lead to rendering artefacts and negatively impacts overall performance." +
|
||||
"\n", MessageType.Warning);
|
||||
|
||||
//If there are no other renderers to assign, suggest to auto-create one
|
||||
UI.DrawNotification(PipelineUtilities.rendererIndexList.Length <= 2, "It is highly recommend to create a separate empty renderer", "Create and assign", CreateRenderer, MessageType.None);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(cullingMask);
|
||||
|
||||
EditorGUILayout.PropertyField(includeSkybox);
|
||||
EditorGUILayout.PropertyField(enableFog);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.PropertyField(rotatable);
|
||||
EditorGUILayout.PropertyField(offset);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField("Quality", EditorStyles.boldLabel);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(renderShadows);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
renderer.ToggleShadows(renderShadows.boolValue);
|
||||
}
|
||||
EditorGUILayout.PropertyField(renderRange);
|
||||
EditorGUILayout.PropertyField(renderScale);
|
||||
EditorGUILayout.PropertyField(maximumLODLevel);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField("Target water objects", EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(moveWithTransform, new GUIContent("Move bounds with transform", moveWithTransform.tooltip));
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(waterObjects);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
curBounds = renderer.CalculateBounds();
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
if(GUILayout.Button(new GUIContent("Auto-find", "Assigns all active water objects currently in the scene"), EditorStyles.miniButton))
|
||||
{
|
||||
renderer.waterObjects = new List<WaterObject>(WaterObject.Instances);
|
||||
|
||||
renderer.RecalculateBounds();
|
||||
curBounds = renderer.bounds;
|
||||
renderer.EnableMaterialReflectionSampling();
|
||||
|
||||
ValidateWaterObjectLayer();
|
||||
|
||||
EditorUtility.SetDirty(target);
|
||||
}
|
||||
if(GUILayout.Button("Clear", EditorStyles.miniButton))
|
||||
{
|
||||
renderer.ToggleMaterialReflectionSampling(false);
|
||||
renderer.waterObjects.Clear();
|
||||
renderer.RecalculateBounds();
|
||||
|
||||
EditorUtility.SetDirty(target);
|
||||
}
|
||||
}
|
||||
|
||||
if (renderer.waterObjects != null)
|
||||
{
|
||||
UI.DrawNotification(renderer.waterObjects.Count == 0, "Assign at least one Water Object", MessageType.Info);
|
||||
|
||||
if (renderer.waterObjects.Count > 0)
|
||||
{
|
||||
UI.DrawNotification(curBounds.size != renderer.bounds.size || (moveWithTransform.boolValue == false && curBounds.center != renderer.bounds.center), "Water objects have changed or moved, bounds needs to be recalculated", "Recalculate",() => RecalculateBounds(), MessageType.Error);
|
||||
}
|
||||
|
||||
UI.DrawNotification(waterLayerError, "One or more Water Objects aren't on the \"Water\" layer.\n\nThis causes recursive reflections", "Fix", () => SetObjectsOnWaterLayer(), MessageType.Error);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
UI.DrawFooter();
|
||||
}
|
||||
|
||||
#if URP
|
||||
|
||||
private void CreateRenderer()
|
||||
{
|
||||
int index = -1;
|
||||
string path = "";
|
||||
|
||||
PipelineUtilities.CreateAndAssignNewRenderer(out index, out path);
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
rendererIndex.intValue = index;
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
serializedObject.Update();
|
||||
|
||||
renderer.SetRendererIndex(rendererIndex.intValue);
|
||||
|
||||
if (path != string.Empty)
|
||||
{
|
||||
Debug.Log("New renderer created at path <i>" + path + "</i>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasPreviewGUI()
|
||||
{
|
||||
return previewReflection && previewTexture;
|
||||
}
|
||||
|
||||
public override bool RequiresConstantRepaint()
|
||||
{
|
||||
return HasPreviewGUI();
|
||||
}
|
||||
|
||||
public override GUIContent GetPreviewTitle()
|
||||
{
|
||||
return currentCamera ? new GUIContent(currentCameraName + " reflection") : new GUIContent("Reflection");
|
||||
}
|
||||
|
||||
public override void OnPreviewSettings()
|
||||
{
|
||||
if (HasPreviewGUI() == false) return;
|
||||
|
||||
GUILayout.Label($"Resolution ({previewTexture.width}x{previewTexture.height})");
|
||||
}
|
||||
|
||||
private bool drawAlpha;
|
||||
|
||||
public override void OnPreviewGUI(Rect r, GUIStyle background)
|
||||
{
|
||||
if (drawAlpha)
|
||||
{
|
||||
EditorGUI.DrawTextureAlpha(r, previewTexture, ScaleMode.ScaleToFit);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.DrawTexture(r, previewTexture, ScaleMode.ScaleToFit, false);
|
||||
}
|
||||
|
||||
Rect btnRect = r;
|
||||
btnRect.x += 10f;
|
||||
btnRect.y += 10f;
|
||||
btnRect.width = 150f;
|
||||
btnRect.height = 20f;
|
||||
|
||||
drawAlpha = GUI.Toggle(btnRect, drawAlpha, new GUIContent(" Alpha channel"));
|
||||
}
|
||||
|
||||
private void ValidateWaterObjectLayer()
|
||||
{
|
||||
if (renderer.waterObjects == null) return;
|
||||
|
||||
waterLayerError = false;
|
||||
int layerID = LayerMask.NameToLayer("Water");
|
||||
|
||||
foreach (WaterObject obj in renderer.waterObjects)
|
||||
{
|
||||
//Is not on "Water" layer?
|
||||
if (obj.gameObject.layer != layerID)
|
||||
{
|
||||
waterLayerError = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetObjectsOnWaterLayer()
|
||||
{
|
||||
int layerID = LayerMask.NameToLayer("Water");
|
||||
|
||||
foreach (WaterObject obj in renderer.waterObjects)
|
||||
{
|
||||
//Is not on "Water" layer?
|
||||
if (obj.gameObject.layer != layerID)
|
||||
{
|
||||
obj.gameObject.layer = layerID;
|
||||
EditorUtility.SetDirty(obj);
|
||||
}
|
||||
}
|
||||
|
||||
waterLayerError = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
private void RecalculateBounds()
|
||||
{
|
||||
#if URP
|
||||
renderer.RecalculateBounds();
|
||||
curBounds = renderer.bounds;
|
||||
EditorUtility.SetDirty(target);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e169bca08efce694eab8006b53ed91c1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
#if URP
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace StylizedWater2
|
||||
{
|
||||
[CustomEditor(typeof(StylizedWaterRenderFeature))]
|
||||
public class RenderFeatureEditor : Editor
|
||||
{
|
||||
private SerializedProperty screenSpaceReflectionSettings;
|
||||
|
||||
private SerializedProperty directionalCaustics;
|
||||
|
||||
private SerializedProperty displacementPrePassSettings;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
screenSpaceReflectionSettings = serializedObject.FindProperty("screenSpaceReflectionSettings");
|
||||
|
||||
directionalCaustics = serializedObject.FindProperty("directionalCaustics");
|
||||
|
||||
displacementPrePassSettings = serializedObject.FindProperty("displacementPrePassSettings");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.LabelField($"Version {AssetInfo.INSTALLED_VERSION}", EditorStyles.miniLabel);
|
||||
|
||||
if (GUILayout.Button(new GUIContent(" Documentation", EditorGUIUtility.FindTexture("_Help"))))
|
||||
{
|
||||
Application.OpenURL(AssetInfo.DOC_URL);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
|
||||
serializedObject.Update();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(directionalCaustics);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.PropertyField(screenSpaceReflectionSettings);
|
||||
if(screenSpaceReflectionSettings.isExpanded) EditorGUILayout.HelpBox("This feature is available for preview, no configurable settings are available yet", MessageType.Info);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.PropertyField(displacementPrePassSettings);
|
||||
if (displacementPrePassSettings.isExpanded)
|
||||
{
|
||||
EditorGUILayout.HelpBox("This will pre-render all the water geometry's height (including any displacement effects) into a buffer. Allowing other shaders to access this information." +
|
||||
"\n\nSee the Displacement.hlsl shader library for the API, or use the \"Sample Water Height\" Sub-graph in Shader Graph." +
|
||||
"\n\nThis is for advanced users, there is currently no functionality in Stylized Water 2 that makes use of this.", MessageType.Info);
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
UI.DrawFooter();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1e12468f8ea4290a886e4706e800a98
|
||||
timeCreated: 1701084026
|
||||
@@ -0,0 +1,116 @@
|
||||
//Stylized Water 2
|
||||
//Staggart Creations (http://staggart.xyz)
|
||||
//Copyright protected under Unity Asset Store EULA
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace StylizedWater2
|
||||
{
|
||||
[CustomEditor(typeof(WaterGrid))]
|
||||
public class CreateWaterGridInspector : Editor
|
||||
{
|
||||
private WaterGrid script;
|
||||
|
||||
private SerializedProperty material;
|
||||
private SerializedProperty followSceneCamera;
|
||||
private SerializedProperty autoAssignCamera;
|
||||
private SerializedProperty followTarget;
|
||||
|
||||
private SerializedProperty scale;
|
||||
private SerializedProperty vertexDistance;
|
||||
private SerializedProperty rowsColumns;
|
||||
|
||||
private int vertexCount;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
script = (WaterGrid) target;
|
||||
script.m_rowsColumns = script.rowsColumns;
|
||||
|
||||
material = serializedObject.FindProperty("material");
|
||||
followSceneCamera = serializedObject.FindProperty("followSceneCamera");
|
||||
autoAssignCamera = serializedObject.FindProperty("autoAssignCamera");
|
||||
followTarget = serializedObject.FindProperty("followTarget");
|
||||
|
||||
scale = serializedObject.FindProperty("scale");
|
||||
vertexDistance = serializedObject.FindProperty("vertexDistance");
|
||||
rowsColumns = serializedObject.FindProperty("rowsColumns");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
UI.DrawHeader();
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Space(EditorGUIUtility.labelWidth);
|
||||
WaterGrid.DisplayGrid = GUILayout.Toggle(WaterGrid.DisplayGrid , new GUIContent(" Display Grid", EditorGUIUtility.IconContent((WaterGrid.DisplayGrid ? "animationvisibilitytoggleon" : "animationvisibilitytoggleoff")).image), "Button");
|
||||
WaterGrid.DisplayWireframe = GUILayout.Toggle(WaterGrid.DisplayWireframe, new GUIContent(" Show Wireframe", EditorGUIUtility.IconContent((WaterGrid.DisplayWireframe ? "animationvisibilitytoggleon" : "animationvisibilitytoggleoff")).image), "Button");
|
||||
}
|
||||
|
||||
serializedObject.Update();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.LabelField("Appearance", EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(material);
|
||||
if(material.objectReferenceValue == null) EditorGUILayout.HelpBox("A material must be assigned", MessageType.Error);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField("Movement", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.PropertyField(followSceneCamera);
|
||||
using (new EditorGUI.DisabledScope(autoAssignCamera.boolValue))
|
||||
{
|
||||
EditorGUILayout.PropertyField(followTarget);
|
||||
}
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(autoAssignCamera);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField("Grid geometry", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.PropertyField(scale, GUILayout.MaxWidth(EditorGUIUtility.labelWidth + 95f));
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.PrefixLabel(rowsColumns.displayName);
|
||||
using (new EditorGUI.DisabledScope(rowsColumns.intValue <= 1))
|
||||
{
|
||||
if (GUILayout.Button("-", EditorStyles.miniButtonLeft, GUILayout.Width(25f)))
|
||||
{
|
||||
rowsColumns.intValue--;
|
||||
}
|
||||
}
|
||||
EditorGUILayout.PropertyField(rowsColumns, GUIContent.none, GUILayout.MaxWidth(40f));
|
||||
if (GUILayout.Button("+", EditorStyles.miniButtonRight, GUILayout.Width(25f)))
|
||||
{
|
||||
rowsColumns.intValue++;
|
||||
}
|
||||
EditorGUILayout.LabelField($"= {rowsColumns.intValue * rowsColumns.intValue} tiles", EditorStyles.miniLabel);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.PropertyField(vertexDistance, new GUIContent("Min. vertex distance", vertexDistance.tooltip));
|
||||
vertexCount = Mathf.FloorToInt(((scale.floatValue / rowsColumns.intValue) / vertexDistance.floatValue) * ((scale.floatValue / rowsColumns.intValue) / vertexDistance.floatValue));
|
||||
if(vertexCount > 65535)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Vertex count of individual tiles is too high. Increase the vertex distance, decrease the grid scale, or add more rows/columns", MessageType.Error);
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
//Executed here since objects can't be destroyed from OnValidate
|
||||
script.Recreate();
|
||||
}
|
||||
|
||||
UI.DrawFooter();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55b547e4881242f4af120838d3e9e6d6
|
||||
timeCreated: 1680100927
|
||||
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
#if URP
|
||||
using UnityEngine.Rendering.Universal;
|
||||
#endif
|
||||
|
||||
namespace StylizedWater2
|
||||
{
|
||||
[CustomEditor(typeof(WaterObject))]
|
||||
[CanEditMultipleObjects]
|
||||
public class WaterObjectInspector : Editor
|
||||
{
|
||||
private WaterObject component;
|
||||
|
||||
private SerializedProperty material;
|
||||
private SerializedProperty meshFilter;
|
||||
private SerializedProperty meshRenderer;
|
||||
|
||||
private bool depthTextureRequired;
|
||||
private bool opaqueTextureRequired;
|
||||
|
||||
private bool showInstances
|
||||
{
|
||||
get => SessionState.GetBool("WATEROBJECT_SHOW_INSTANCES", false);
|
||||
set => SessionState.SetBool("WATEROBJECT_SHOW_INSTANCES", value);
|
||||
}
|
||||
|
||||
private Texture icon;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
component = (WaterObject)target;
|
||||
|
||||
icon = Resources.Load<Texture>("water-object-icon");
|
||||
|
||||
material = serializedObject.FindProperty("material");
|
||||
meshFilter = serializedObject.FindProperty("meshFilter");
|
||||
meshRenderer = serializedObject.FindProperty("meshRenderer");
|
||||
|
||||
CheckMaterial();
|
||||
}
|
||||
|
||||
private void CheckMaterial()
|
||||
{
|
||||
#if URP
|
||||
if (UniversalRenderPipeline.asset == null || component.material == null) return;
|
||||
|
||||
depthTextureRequired = UniversalRenderPipeline.asset.supportsCameraDepthTexture == false && component.material.GetFloat("_DisableDepthTexture") == 0f;
|
||||
opaqueTextureRequired = UniversalRenderPipeline.asset.supportsCameraOpaqueTexture == false && component.material.GetFloat("_RefractionOn") == 1f;
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
#if URP
|
||||
if (UniversalRenderPipeline.asset)
|
||||
{
|
||||
UI.DrawNotification(
|
||||
depthTextureRequired,
|
||||
"Depth texture is disabled, but is required for the water material",
|
||||
"Enable",
|
||||
() =>
|
||||
{
|
||||
StylizedWaterEditor.EnableDepthTexture();
|
||||
CheckMaterial();
|
||||
},
|
||||
MessageType.Error);
|
||||
|
||||
UI.DrawNotification(
|
||||
opaqueTextureRequired,
|
||||
"Opaque texture is disabled, but is required for the water material",
|
||||
"Enable",
|
||||
() =>
|
||||
{
|
||||
StylizedWaterEditor.EnableOpaqueTexture();
|
||||
CheckMaterial();
|
||||
},
|
||||
MessageType.Error);
|
||||
}
|
||||
#endif
|
||||
|
||||
EditorGUILayout.HelpBox("This component provides a means for other scripts to identify and find water bodies", MessageType.None);
|
||||
|
||||
EditorGUILayout.LabelField("References (Read only)", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
{
|
||||
EditorGUILayout.PropertyField(material);
|
||||
EditorGUILayout.PropertyField(meshFilter);
|
||||
EditorGUILayout.PropertyField(meshRenderer);
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
//In case the material was changed on the attached Mesh Renderer, reflect the change
|
||||
foreach (Object currentTarget in targets)
|
||||
{
|
||||
WaterObject water = (WaterObject)currentTarget;
|
||||
water.FetchWaterMaterial();
|
||||
}
|
||||
|
||||
if (WaterObject.Instances.Count > 1)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
|
||||
showInstances = EditorGUILayout.BeginFoldoutHeaderGroup(showInstances, $"Instances ({WaterObject.Instances.Count})");
|
||||
|
||||
if (showInstances)
|
||||
{
|
||||
this.Repaint();
|
||||
|
||||
using (new EditorGUILayout.VerticalScope(EditorStyles.textArea))
|
||||
{
|
||||
foreach (WaterObject obj in WaterObject.Instances)
|
||||
{
|
||||
var rect = EditorGUILayout.BeginHorizontal(EditorStyles.miniLabel);
|
||||
|
||||
if (rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
EditorGUIUtility.AddCursorRect(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 27, 27), MouseCursor.Link);
|
||||
EditorGUI.DrawRect(rect, Color.gray * (EditorGUIUtility.isProSkin ? 0.66f : 0.20f));
|
||||
}
|
||||
|
||||
if (GUILayout.Button(new GUIContent(" " + obj.name, icon), EditorStyles.miniLabel, GUILayout.Height(20f)))
|
||||
{
|
||||
EditorGUIUtility.PingObject(obj);
|
||||
Selection.activeGameObject = obj.gameObject;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24c4c7f693f04a3893891169c1f864d8
|
||||
timeCreated: 1685014300
|
||||
@@ -0,0 +1,341 @@
|
||||
//Stylized Water 2
|
||||
//Staggart Creations (http://staggart.xyz)
|
||||
//Copyright protected under Unity Asset Store EULA
|
||||
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
using UnityEditor.AssetImporters;
|
||||
#else
|
||||
using UnityEditor.Experimental.AssetImporters;
|
||||
#endif
|
||||
|
||||
namespace StylizedWater2
|
||||
{
|
||||
[CustomEditor(typeof(WaterShaderImporter))]
|
||||
[CanEditMultipleObjects]
|
||||
public class WaterShaderImporterEditor : ScriptedImporterEditor
|
||||
{
|
||||
private WaterShaderImporter importer;
|
||||
|
||||
private SerializedProperty template;
|
||||
|
||||
private SerializedProperty settings;
|
||||
|
||||
private SerializedProperty shaderName;
|
||||
private SerializedProperty hidden;
|
||||
private SerializedProperty type;
|
||||
|
||||
private SerializedProperty autoIntegration;
|
||||
private SerializedProperty fogIntegration;
|
||||
|
||||
private SerializedProperty lightCookies;
|
||||
|
||||
private SerializedProperty customIncludeDirectives;
|
||||
|
||||
private bool underwaterRenderingInstalled;
|
||||
private bool dynamicEffectsInstalled;
|
||||
private ShaderConfigurator.Fog.Integration firstIntegration;
|
||||
private bool curvedWorldInstalled;
|
||||
|
||||
private bool showDependencies;
|
||||
|
||||
public override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
underwaterRenderingInstalled = StylizedWaterEditor.UnderwaterRenderingInstalled();
|
||||
dynamicEffectsInstalled = StylizedWaterEditor.DynamicEffectsInstalled();
|
||||
firstIntegration = ShaderConfigurator.Fog.GetFirstInstalled();
|
||||
curvedWorldInstalled = StylizedWaterEditor.CurvedWorldInstalled(out var _);
|
||||
|
||||
importer = (WaterShaderImporter)target;
|
||||
|
||||
template = serializedObject.FindProperty("template");
|
||||
|
||||
settings = serializedObject.FindProperty("settings");
|
||||
//settings.isExpanded = true;
|
||||
|
||||
shaderName = settings.FindPropertyRelative("shaderName");
|
||||
hidden = settings.FindPropertyRelative("hidden");
|
||||
type = settings.FindPropertyRelative("type");
|
||||
|
||||
lightCookies = settings.FindPropertyRelative("lightCookies");
|
||||
|
||||
autoIntegration = settings.FindPropertyRelative("autoIntegration");
|
||||
fogIntegration = settings.FindPropertyRelative("fogIntegration");
|
||||
|
||||
customIncludeDirectives = settings.FindPropertyRelative("customIncludeDirectives");
|
||||
}
|
||||
|
||||
public override bool HasPreviewGUI()
|
||||
{
|
||||
//Hide the useless sphere preview :)
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
//base.OnInspectorGUI();
|
||||
Color defaultColor = GUI.contentColor;
|
||||
|
||||
UI.DrawHeader();
|
||||
|
||||
Shader shader = AssetDatabase.LoadAssetAtPath<Shader>(importer.assetPath);
|
||||
if (shader == null)
|
||||
{
|
||||
UI.DrawNotification("Shader failed to compile, try to manually recompile it now.", MessageType.Error);
|
||||
}
|
||||
|
||||
if (GUILayout.Button(new GUIContent(" Recompile", EditorGUIUtility.IconContent("RotateTool").image), GUILayout.MinHeight(30f)))
|
||||
{
|
||||
importer.SaveAndReimport();
|
||||
}
|
||||
|
||||
GUILayout.Space(-2f);
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
using (new EditorGUI.DisabledGroupScope(shader == null))
|
||||
{
|
||||
if (GUILayout.Button(new GUIContent(" Show Generated Code", EditorGUIUtility.IconContent("align_horizontally_left_active").image), EditorStyles.miniButtonLeft, GUILayout.Height(28f)))
|
||||
{
|
||||
GenericMenu menu = new GenericMenu();
|
||||
|
||||
menu.AddItem(new GUIContent("With tessellation"), false, () => OpenGeneratedCode(true));
|
||||
menu.AddItem(new GUIContent("Without tessellation"), false, () => OpenGeneratedCode(false));
|
||||
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
if (GUILayout.Button(new GUIContent("Clear cache", "Unity's shader compiler will cache the compiled shader, and internally use that." +
|
||||
"\n\nThis may result in seemingly false-positive shader errors. Such as in the case of importing the shader, before the URP shader libraries are." +
|
||||
"\n\nClearing the cache gives the compiler a kick, and makes the shader properly represent the current state of the project/dependencies."), EditorStyles.miniButtonRight, GUILayout.Height(28f)))
|
||||
{
|
||||
importer.ClearCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
serializedObject.Update();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(template);
|
||||
|
||||
if (template.objectReferenceValue == null) EditorGUILayout.HelpBox("• Template is assumed to be in the contents of the file itself", MessageType.None);
|
||||
//EditorGUILayout.LabelField(importer.GetTemplatePath(), EditorStyles.miniLabel);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField("Settings", EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(shaderName);
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(hidden);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
EditorGUILayout.PropertyField(type);
|
||||
|
||||
if (type.intValue == (int)WaterShaderImporter.WaterShaderSettings.ShaderType.WaterSurface)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField("Integrations", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.PropertyField(autoIntegration, new GUIContent("Automatic detection", autoIntegration.tooltip));
|
||||
if (autoIntegration.boolValue)
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.LabelField("Fog post-processing", GUILayout.MaxWidth(EditorGUIUtility.labelWidth));
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope(EditorStyles.textField))
|
||||
{
|
||||
GUI.contentColor = Color.green;
|
||||
EditorGUILayout.LabelField(firstIntegration.name);
|
||||
|
||||
GUI.contentColor = defaultColor;
|
||||
}
|
||||
}
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.LabelField("Curved World 2020", GUILayout.MaxWidth(EditorGUIUtility.labelWidth));
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope(EditorStyles.textField))
|
||||
{
|
||||
if (curvedWorldInstalled)
|
||||
{
|
||||
GUI.contentColor = Color.green;
|
||||
EditorGUILayout.LabelField("Installed");
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.contentColor = new Color(1f, 0.65f, 0f);
|
||||
EditorGUILayout.LabelField("(Not installed)");
|
||||
}
|
||||
|
||||
GUI.contentColor = defaultColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(fogIntegration);
|
||||
}
|
||||
if (curvedWorldInstalled) EditorGUILayout.HelpBox("Curved World integration must be activated through Window->Amazing Assets->Curved Word (Activator tab)", MessageType.Info);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField("Functionality support", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.PropertyField(lightCookies);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField("Extensions", EditorStyles.boldLabel);
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.LabelField("Underwater Rendering", GUILayout.MaxWidth(EditorGUIUtility.labelWidth));
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope(EditorStyles.textField))
|
||||
{
|
||||
if (underwaterRenderingInstalled)
|
||||
{
|
||||
GUI.contentColor = Color.green;
|
||||
EditorGUILayout.LabelField("Installed");
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.contentColor = new Color(1f, 0.65f, 0f);
|
||||
EditorGUILayout.LabelField("(Not installed)");
|
||||
}
|
||||
|
||||
GUI.contentColor = defaultColor;
|
||||
}
|
||||
}
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.LabelField("Dynamic Effects", GUILayout.MaxWidth(EditorGUIUtility.labelWidth));
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope(EditorStyles.textField))
|
||||
{
|
||||
if (dynamicEffectsInstalled)
|
||||
{
|
||||
GUI.contentColor = Color.green;
|
||||
EditorGUILayout.LabelField("Installed");
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.contentColor = new Color(1f, 0.65f, 0f);
|
||||
EditorGUILayout.LabelField("(Not installed)");
|
||||
}
|
||||
|
||||
GUI.contentColor = defaultColor;
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.PropertyField(customIncludeDirectives);
|
||||
if (customIncludeDirectives.isExpanded)
|
||||
{
|
||||
EditorGUILayout.HelpBox("These are defined in a HLSLINCLUDE block and apply to all passes" +
|
||||
"\nMay be used to insert custom code.", MessageType.Info);
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
//Force the parameter to a matching value.
|
||||
//This way, if the "auto-integration" option is used, the .meta file will be changed when using the shader in a package, spanning different projects.
|
||||
//When switching a different project, the file will be seen as changed and will be re-imported, in turn applying the project-specific integration.
|
||||
if (autoIntegration.boolValue)
|
||||
{
|
||||
fogIntegration.intValue = (int)firstIntegration.asset;
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
this.ApplyRevertGUI();
|
||||
|
||||
showDependencies = EditorGUILayout.BeginFoldoutHeaderGroup(showDependencies, $"Dependencies ({importer.dependencies.Count})");
|
||||
|
||||
if (showDependencies)
|
||||
{
|
||||
this.Repaint();
|
||||
|
||||
using (new EditorGUILayout.VerticalScope(EditorStyles.textArea))
|
||||
{
|
||||
foreach (string dependency in importer.dependencies)
|
||||
{
|
||||
var rect = EditorGUILayout.BeginHorizontal(EditorStyles.miniLabel);
|
||||
|
||||
if (rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
EditorGUIUtility.AddCursorRect(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 27, 27), MouseCursor.Link);
|
||||
EditorGUI.DrawRect(rect, Color.gray * (EditorGUIUtility.isProSkin ? 0.66f : 0.20f));
|
||||
}
|
||||
|
||||
if (GUILayout.Button(dependency == string.Empty ? new GUIContent(" (Missing)", EditorGUIUtility.IconContent("console.warnicon.sml").image) : new GUIContent(" " + dependency, EditorGUIUtility.IconContent("TextAsset Icon").image),
|
||||
EditorStyles.miniLabel, GUILayout.Height(20f)))
|
||||
{
|
||||
if (dependency != string.Empty)
|
||||
{
|
||||
TextAsset file = AssetDatabase.LoadAssetAtPath<TextAsset>(dependency);
|
||||
|
||||
EditorGUIUtility.PingObject(file);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.HelpBox("Should any of these files be modified/moved/deleted, this shader will also re-import", MessageType.Info);
|
||||
}
|
||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||
|
||||
UI.DrawFooter();
|
||||
|
||||
if (shader)
|
||||
{
|
||||
UI.DrawNotification(ShaderUtil.ShaderHasError(shader), "Errors may be false-positives due to caching", "Clear cache", () => importer.ClearCache(true), MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGeneratedCode(bool tessellation)
|
||||
{
|
||||
importer = (WaterShaderImporter)target;
|
||||
|
||||
string filePath = $"{Application.dataPath.Replace("Assets", string.Empty)}Temp/{importer.settings.shaderName}(Generated Code).shader";
|
||||
|
||||
string code = ShaderConfigurator.TemplateParser.CreateShaderCode(importer.GetTemplatePath(), importer, tessellation);
|
||||
File.WriteAllText(filePath, code);
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
Debug.LogError(string.Format("Path {0} doesn't exists", filePath));
|
||||
return;
|
||||
}
|
||||
|
||||
string externalScriptEditor = ScriptEditorUtility.GetExternalScriptEditor();
|
||||
if (externalScriptEditor != "internal")
|
||||
{
|
||||
InternalEditorUtility.OpenFileAtLineExternal(filePath, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Application.OpenURL("file://" + filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81c37dbe6c244dcca9bde0e9c0f64171
|
||||
timeCreated: 1691138447
|
||||
Reference in New Issue
Block a user