2026-06-09 룸 프로토타입 디자인 (진행중)
This commit is contained in:
236
Assets/Stylized Water 3/_Demo/Scripts/DemoController.cs
Normal file
236
Assets/Stylized Water 3/_Demo/Scripts/DemoController.cs
Normal file
@@ -0,0 +1,236 @@
|
||||
// Stylized Water 3 by Staggart Creations (http://staggart.xyz)
|
||||
// COPYRIGHT PROTECTED UNDER THE UNITY ASSET STORE EULA (https://unity.com/legal/as-terms)
|
||||
// • Copying or referencing source code for the production of new asset store, or public, content is strictly prohibited!
|
||||
// • Uploading this file to a public repository will subject it to an automated DMCA takedown request.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
#if URP
|
||||
using UnityEngine.Rendering.Universal;
|
||||
#endif
|
||||
using UnityEngine.SceneManagement;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
#endif
|
||||
|
||||
namespace StylizedWater3.Demo
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class DemoController : MonoBehaviour
|
||||
{
|
||||
public bool isMainScene;
|
||||
|
||||
[Flags]
|
||||
public enum Requirements
|
||||
{
|
||||
None = 0,
|
||||
DepthTexture = 1,
|
||||
OpaqueTexture = 2,
|
||||
LightCookies = 4,
|
||||
Decals = 8,
|
||||
RenderFeature = 16,
|
||||
HeightPrePass = 32,
|
||||
Splines = 64
|
||||
}
|
||||
|
||||
public Requirements requirements;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[Space]
|
||||
public SceneAsset[] sceneAssets = Array.Empty<SceneAsset>();
|
||||
#endif
|
||||
|
||||
[SerializeField]
|
||||
private string[] sceneGUIDS = Array.Empty<string>();
|
||||
[SerializeField]
|
||||
private string[] scenePaths = Array.Empty<string>();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnValidate()
|
||||
{
|
||||
sceneGUIDS = new string[sceneAssets.Length];
|
||||
scenePaths = new string[sceneAssets.Length];
|
||||
for (int i = 0; i < sceneAssets.Length; i++)
|
||||
{
|
||||
scenePaths[i] = AssetDatabase.GetAssetPath(sceneAssets[i]);
|
||||
sceneGUIDS[i] = AssetDatabase.AssetPathToGUID(scenePaths[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Scene scene = this.gameObject.scene;
|
||||
string sceneName = scene.name;
|
||||
|
||||
string setupMessage = $"Not all functionality in the scene \"{sceneName}\" will work as intended, due to incorrect or missing project settings:\n\n";
|
||||
bool requiresSetup = false;
|
||||
|
||||
#if URP
|
||||
if (UniversalRenderPipeline.asset)
|
||||
{
|
||||
if (requirements.HasFlag(Requirements.DepthTexture))
|
||||
{
|
||||
if (UniversalRenderPipeline.asset.supportsCameraDepthTexture == false)
|
||||
{
|
||||
requiresSetup = true;
|
||||
setupMessage += "• Depth texture isn't enabled. Water depth will not look correct.\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (requirements.HasFlag(Requirements.OpaqueTexture))
|
||||
{
|
||||
if (UniversalRenderPipeline.asset.supportsCameraOpaqueTexture == false)
|
||||
{
|
||||
requiresSetup = true;
|
||||
setupMessage += "• Opaque texture isn't enabled. Refraction effect cannot work\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (requirements.HasFlag(Requirements.LightCookies))
|
||||
{
|
||||
if (UniversalRenderPipeline.asset.supportsLightCookies == false)
|
||||
{
|
||||
requiresSetup = true;
|
||||
setupMessage += "• Light cookies aren't enabled\n";
|
||||
}
|
||||
|
||||
LightCookieFormat lightCookieFormat = PipelineUtilities.GetDefaultLightCookieFormat();
|
||||
if (lightCookieFormat < LightCookieFormat.ColorHigh)
|
||||
{
|
||||
requiresSetup = true;
|
||||
setupMessage += "• Light cookie format isn't set to \"Color High\" or \"Color HDR\"\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (requirements.HasFlag(Requirements.Decals))
|
||||
{
|
||||
if (PipelineUtilities.IsDecalRenderFeatureSetup() == false)
|
||||
{
|
||||
requiresSetup = true;
|
||||
setupMessage += "• Decal render feature isn't set up\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (requirements.HasFlag(Requirements.RenderFeature))
|
||||
{
|
||||
if (PipelineUtilities.RenderFeatureAdded<StylizedWaterRenderFeature>() == false)
|
||||
{
|
||||
requiresSetup = true;
|
||||
setupMessage += "• Stylized Water render feature isn't set up\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (requirements.HasFlag(Requirements.HeightPrePass))
|
||||
{
|
||||
StylizedWaterRenderFeature renderFeature = (StylizedWaterRenderFeature)PipelineUtilities.GetRenderFeature<StylizedWaterRenderFeature>();
|
||||
|
||||
if (renderFeature == null || renderFeature.heightPrePassSettings.enable == false)
|
||||
{
|
||||
requiresSetup = true;
|
||||
setupMessage += "• Height pre-pass is disabled on the Stylized Water render feature\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
if (requirements.HasFlag(Requirements.Splines))
|
||||
{
|
||||
#if !SPLINES
|
||||
requiresSetup = true;
|
||||
setupMessage += "• Splines package isn't installed\n";
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
setupMessage += "\nIf you're unsure what this means, please consult the \"Getting Started\" documentation section for instructions.";
|
||||
|
||||
if (Application.isPlaying == false && UnityEditor.BuildPipeline.isBuildingPlayer == false && Application.isBatchMode == false)
|
||||
{
|
||||
if (requiresSetup)
|
||||
{
|
||||
UnityEditor.EditorUtility.DisplayDialog("Stylized Water 3", setupMessage, "OK");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||
|
||||
if (Application.isPlaying == false)
|
||||
{
|
||||
OpenScenes();
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCoroutine(OpenScenesRoutine());
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
|
||||
{
|
||||
if (isMainScene)
|
||||
{
|
||||
SceneManager.SetActiveScene(this.gameObject.scene);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator OpenScenesRoutine()
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
OpenScenes();
|
||||
}
|
||||
|
||||
void OpenScenes()
|
||||
{
|
||||
for (int i = 0; i < scenePaths.Length; i++)
|
||||
{
|
||||
string path = scenePaths[i];
|
||||
|
||||
//Scene not found, possibly an extension not currently installed or a dev-only scene
|
||||
if (path == string.Empty) continue;
|
||||
|
||||
Scene scene = SceneManager.GetSceneByPath(path);
|
||||
|
||||
if (scene.isLoaded == false)
|
||||
{
|
||||
//Debug.Log($"scene {path} being loaded");
|
||||
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
SceneManager.LoadScene(path, LoadSceneMode.Additive);
|
||||
//StartCoroutine(LoadScene(path));
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EditorSceneManager.OpenScene(path, OpenSceneMode.Additive);
|
||||
#endif
|
||||
}
|
||||
|
||||
//Debug.Log($"{path} loaded");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator LoadScene(string path)
|
||||
{
|
||||
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(path, LoadSceneMode.Additive);
|
||||
|
||||
while (!asyncLoad.isDone)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
SceneManager.sceneLoaded -= OnSceneLoaded;
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Assets/Stylized Water 3/_Demo/Scripts/DemoController.cs.meta
Normal file
10
Assets/Stylized Water 3/_Demo/Scripts/DemoController.cs.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ce943a824c74c80851ddb105b5964c9
|
||||
timeCreated: 1717490223
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 287769
|
||||
packageName: Stylized Water 3
|
||||
packageVersion: 3.2.7
|
||||
assetPath: Assets/Stylized Water 3/_Demo/Scripts/DemoController.cs
|
||||
uploadId: 927372
|
||||
321
Assets/Stylized Water 3/_Demo/Scripts/DemoLightingController.cs
Normal file
321
Assets/Stylized Water 3/_Demo/Scripts/DemoLightingController.cs
Normal file
@@ -0,0 +1,321 @@
|
||||
// Stylized Water 3 by Staggart Creations (http://staggart.xyz)
|
||||
// COPYRIGHT PROTECTED UNDER THE UNITY ASSET STORE EULA (https://unity.com/legal/as-terms)
|
||||
// • Copying or referencing source code for the production of new asset store, or public, content is strictly prohibited!
|
||||
// • Uploading this file to a public repository will subject it to an automated DMCA takedown request.
|
||||
#if (ENABLE_INPUT_SYSTEM && INPUT_SYSTEM_INSTALLED)
|
||||
#define USE_INPUT_SYSTEM
|
||||
#endif
|
||||
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
#if USE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
namespace StylizedWater3.Demo
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class DemoLightingController : MonoBehaviour
|
||||
{
|
||||
[Serializable]
|
||||
public class Preset
|
||||
{
|
||||
public string name;
|
||||
public Material skybox;
|
||||
|
||||
[Header("Direct light")]
|
||||
|
||||
[Range(0f, 90f)]
|
||||
public float sunAngle = 45;
|
||||
[Range(0f, 360f)]
|
||||
public float sunRotation = 0f;
|
||||
|
||||
public float intensity = 1f;
|
||||
public Color tint = Color.white;
|
||||
|
||||
[Header("Indirect light")]
|
||||
public Color ambientColor = Color.gray;
|
||||
|
||||
[Header("Fog")]
|
||||
public Color fogColor = Color.white;
|
||||
[Range(0.0001f, 0.01f)]
|
||||
public float fogDensity = 0.002f;
|
||||
}
|
||||
|
||||
public static bool ShowGUI = true;
|
||||
|
||||
[Min(0)]
|
||||
public int activeIndex = 0;
|
||||
public Preset[] presets = Array.Empty<Preset>();
|
||||
|
||||
public ReflectionProbe reflectionProbe;
|
||||
|
||||
[NonSerialized]
|
||||
private Material m_skybox;
|
||||
private Light sun;
|
||||
|
||||
[SerializeField]
|
||||
private bool realtimeReflectionProbesDisabled;
|
||||
|
||||
#if USE_INPUT_SYSTEM
|
||||
private InputAction[] numberKeyActions;
|
||||
#endif
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
realtimeReflectionProbesDisabled = QualitySettings.realtimeReflectionProbes;
|
||||
|
||||
if (!realtimeReflectionProbesDisabled)
|
||||
{
|
||||
//Debug.LogWarning("Realtime Reflection Probes are disabled in your Quality Settings, this is by default in new Unity projects. To ensure the water looks correct, it has been enabled temporarily.");
|
||||
//QualitySettings.realtimeReflectionProbes = true;
|
||||
}
|
||||
|
||||
ApplyPreset(activeIndex);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.SceneView.duringSceneGui += OnSceneGUI;
|
||||
#endif
|
||||
|
||||
SetupInput();
|
||||
}
|
||||
|
||||
private void SetupInput()
|
||||
{
|
||||
#if USE_INPUT_SYSTEM
|
||||
numberKeyActions = new InputAction[9];
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
int presetIndex = i;
|
||||
numberKeyActions[i] = new InputAction($"Preset{presetIndex + 1}", binding: $"<Keyboard>/{presetIndex + 1}");
|
||||
numberKeyActions[i].performed += ctx => OnNumberKeyPressed(presetIndex);
|
||||
numberKeyActions[i].Enable();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
RenderSettings.defaultReflectionMode = DefaultReflectionMode.Skybox;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.SceneView.duringSceneGui -= OnSceneGUI;
|
||||
#endif
|
||||
|
||||
//Do not meddle with project settings, restore changes
|
||||
if (realtimeReflectionProbesDisabled == false && QualitySettings.realtimeReflectionProbes == true) QualitySettings.realtimeReflectionProbes = false;
|
||||
|
||||
#if USE_INPUT_SYSTEM
|
||||
if (numberKeyActions != null)
|
||||
{
|
||||
foreach (var action in numberKeyActions)
|
||||
{
|
||||
action.Disable();
|
||||
action.Dispose();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private readonly int SkyboxTexID = Shader.PropertyToID("_Tex");
|
||||
|
||||
public void ApplyPreset(int index = -1)
|
||||
{
|
||||
if (index < 0) index = activeIndex;
|
||||
|
||||
if (this.gameObject.activeInHierarchy == false) return;
|
||||
if (index > presets.Length) return;
|
||||
|
||||
activeIndex = index;
|
||||
|
||||
Preset preset = presets[index];
|
||||
|
||||
#if UNITY_6000_4_OR_NEWER
|
||||
Light[] lights = FindObjectsByType<Light>(FindObjectsInactive.Exclude);
|
||||
#else
|
||||
Light[] lights = FindObjectsByType<Light>(FindObjectsInactive.Exclude, FindObjectsSortMode.None);
|
||||
#endif
|
||||
for (int i = 0; i < lights.Length; i++)
|
||||
{
|
||||
if (lights[i].type == LightType.Directional) sun = lights[i];
|
||||
}
|
||||
|
||||
if (m_skybox == null || preset.skybox.GetTexture(SkyboxTexID) != RenderSettings.skybox.GetTexture(SkyboxTexID))
|
||||
{
|
||||
CreateSkyboxMat(preset.skybox);
|
||||
}
|
||||
|
||||
sun.intensity = preset.intensity;
|
||||
sun.color = preset.tint;
|
||||
|
||||
m_skybox.CopyPropertiesFromMaterial(preset.skybox);
|
||||
m_skybox.SetTexture(SkyboxTexID, preset.skybox.GetTexture(SkyboxTexID));
|
||||
|
||||
sun.transform.eulerAngles = new Vector3(preset.sunAngle, preset.sunRotation, 0f);
|
||||
m_skybox.SetFloat("_Rotation", -sun.transform.eulerAngles.y);
|
||||
|
||||
RenderSettings.skybox = m_skybox;
|
||||
RenderSettings.fogColor = preset.fogColor;
|
||||
RenderSettings.fogDensity = preset.fogDensity;
|
||||
|
||||
RenderSettings.ambientLight = preset.ambientColor;
|
||||
|
||||
if (reflectionProbe)
|
||||
{
|
||||
reflectionProbe.RenderProbe();
|
||||
//RenderSettings.defaultReflectionMode = DefaultReflectionMode.Custom;
|
||||
//RenderSettings.customReflectionTexture = reflectionProbe.texture;
|
||||
}
|
||||
else
|
||||
{
|
||||
//RenderSettings.defaultReflectionMode = DefaultReflectionMode.Skybox;
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateSkyboxMat(Material source)
|
||||
{
|
||||
m_skybox = new Material(source);
|
||||
m_skybox.name = "Temp skybox";
|
||||
}
|
||||
|
||||
private void OnNumberKeyPressed(int index)
|
||||
{
|
||||
if (index < presets.Length)
|
||||
{
|
||||
ApplyPreset(index);
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnSceneGUI(SceneView sceneView)
|
||||
{
|
||||
Handles.BeginGUI();
|
||||
OnGUI();
|
||||
Handles.EndGUI();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (!ShowGUI) return;
|
||||
|
||||
using (new GUILayout.HorizontalScope(GUILayout.Width(300f)))
|
||||
{
|
||||
GUILayout.Label(" Lighting Presets:", GUI.skin.label);
|
||||
|
||||
for (int i = 0; i < presets.Length; i++)
|
||||
{
|
||||
GUI.enabled = (activeIndex != i);
|
||||
if (GUILayout.Button(presets[i].name))
|
||||
{
|
||||
ApplyPreset(i);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(this);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[CustomEditor(typeof(DemoLightingController))]
|
||||
public class DemoLightingControllerEditor : Editor
|
||||
{
|
||||
private DemoLightingController component;
|
||||
private SerializedProperty presets;
|
||||
|
||||
private SerializedProperty reflectionProbe;
|
||||
|
||||
private string proSkinPrefix => EditorGUIUtility.isProSkin ? "d_" : "";
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
component = (DemoLightingController)target;
|
||||
presets = serializedObject.FindProperty("presets");
|
||||
reflectionProbe = serializedObject.FindProperty("reflectionProbe");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(reflectionProbe);
|
||||
DemoLightingController.ShowGUI = EditorGUILayout.Toggle("Show GUI", DemoLightingController.ShowGUI);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField("Presets", EditorStyles.boldLabel);
|
||||
|
||||
for (int i = 0; i < presets.arraySize; i++)
|
||||
{
|
||||
if (GUILayout.Button("Set Active"))
|
||||
{
|
||||
component.activeIndex = i;
|
||||
component.ApplyPreset(i);
|
||||
|
||||
EditorUtility.SetDirty(component);
|
||||
}
|
||||
|
||||
using (new EditorGUI.DisabledGroupScope(component.activeIndex != i))
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
|
||||
{
|
||||
using (new EditorGUILayout.VerticalScope())
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
|
||||
SerializedProperty param = presets.GetArrayElementAtIndex(i);
|
||||
|
||||
EditorGUILayout.PropertyField(param);
|
||||
|
||||
GUILayout.Space(5f);
|
||||
}
|
||||
|
||||
if (GUILayout.Button(new GUIContent("", EditorGUIUtility.IconContent(proSkinPrefix + "TreeEditor.Trash").image, "Remove parameter"), EditorStyles.miniButton, GUILayout.Width(30f))) presets.DeleteArrayElementAtIndex(i);
|
||||
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
if (component.activeIndex == i)
|
||||
{
|
||||
component.ApplyPreset(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(3f);
|
||||
}
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button(new GUIContent(" Add", EditorGUIUtility.IconContent(proSkinPrefix + "Toolbar Plus").image, "Insert new parameter"), EditorStyles.miniButton, GUILayout.Width(60f)))
|
||||
{
|
||||
presets.InsertArrayElementAtIndex(presets.arraySize);
|
||||
}
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cba965c6fe284869ba24e6006356c9a9
|
||||
timeCreated: 1727092186
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 287769
|
||||
packageName: Stylized Water 3
|
||||
packageVersion: 3.2.7
|
||||
assetPath: Assets/Stylized Water 3/_Demo/Scripts/DemoLightingController.cs
|
||||
uploadId: 927372
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"reference": "GUID:4fd586483f5d4a24491f09604d74752b"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca51cc01654c7e348bcc3eae6ff63108
|
||||
AssemblyDefinitionReferenceImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 287769
|
||||
packageName: Stylized Water 3
|
||||
packageVersion: 3.2.7
|
||||
assetPath: Assets/Stylized Water 3/_Demo/Scripts/sc.stylizedwater3.demo.runtime.asmref
|
||||
uploadId: 927372
|
||||
Reference in New Issue
Block a user