From b6a14f025c7e71926a8abcc7b5030b493d4a91bd Mon Sep 17 00:00:00 2001 From: TheFatBastid Date: Tue, 9 May 2023 15:01:54 -0400 Subject: [PATCH 1/5] Updated Readme (#291) * Update README.md Changed the URL from personal to YARC * Update README.md Changed the URL from personal to YARC --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 70a043846..c44a4236a 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Windows: 3. Clone the repository. If you don't know how to do this: 1. Download [Git](https://git-scm.com/downloads). Be sure it is added to system path. 2. Open the command prompt in the directory you want to store the repository. - 3. Type in `git clone https://github.com/EliteAsian123/YARG.git`. + 3. Type in `git clone https://github.com/YARC-Official/YARG.git`. 4. Install Unity Hub and Unity `2021.3.21f1` (LTS). 1. Download and install [Unity Hub](https://unity.com/download). 2. Sign-in/create an account with a personal license (free). From bd044724243ea44e26cb2bfed55cc7697bbe06c3 Mon Sep 17 00:00:00 2001 From: NyxTheShield Date: Wed, 10 May 2023 21:31:44 -0400 Subject: [PATCH 2/5] Custom Post Processing Shader to Enable Transparency on Render Textures --- Assets/Art/Shaders/UberPP.shader | 260 ++++++++++++ Assets/Art/Shaders/UberPP.shader.meta | 10 + .../Editor/ExtendedScriptableObjectDrawer.cs | 288 +++++++++++++ .../ExtendedScriptableObjectDrawer.cs.meta | 11 + .../Scenes/ExportedBackgroundSceneTest.unity | 388 ++++++++++++++++++ .../ExportedBackgroundSceneTest.unity.meta | 7 + Assets/Settings/CustomPostProcessData.asset | 82 ++++ .../Settings/CustomPostProcessData.asset.meta | 8 + Assets/Settings/High_Renderer.asset | 2 +- Assets/Settings/Low_Renderer.asset | 2 +- 10 files changed, 1056 insertions(+), 2 deletions(-) create mode 100644 Assets/Art/Shaders/UberPP.shader create mode 100644 Assets/Art/Shaders/UberPP.shader.meta create mode 100644 Assets/Editor/ExtendedScriptableObjectDrawer.cs create mode 100644 Assets/Editor/ExtendedScriptableObjectDrawer.cs.meta create mode 100644 Assets/Scenes/ExportedBackgroundSceneTest.unity create mode 100644 Assets/Scenes/ExportedBackgroundSceneTest.unity.meta create mode 100644 Assets/Settings/CustomPostProcessData.asset create mode 100644 Assets/Settings/CustomPostProcessData.asset.meta diff --git a/Assets/Art/Shaders/UberPP.shader b/Assets/Art/Shaders/UberPP.shader new file mode 100644 index 000000000..caf78827a --- /dev/null +++ b/Assets/Art/Shaders/UberPP.shader @@ -0,0 +1,260 @@ +Shader "Artificial Artists/Universal Render Pipeline/AA_UberPost" +{ + HLSLINCLUDE + #pragma exclude_renderers gles + #pragma multi_compile_local_fragment _ _DISTORTION + #pragma multi_compile_local_fragment _ _CHROMATIC_ABERRATION + #pragma multi_compile_local_fragment _ _BLOOM_LQ _BLOOM_HQ _BLOOM_LQ_DIRT _BLOOM_HQ_DIRT + #pragma multi_compile_local_fragment _ _HDR_GRADING _TONEMAP_ACES _TONEMAP_NEUTRAL + #pragma multi_compile_local_fragment _ _FILM_GRAIN + #pragma multi_compile_local_fragment _ _DITHERING + #pragma multi_compile_local_fragment _ _GAMMA_20 _LINEAR_TO_SRGB_CONVERSION + #pragma multi_compile_local_fragment _ _USE_FAST_SRGB_LINEAR_CONVERSION + #pragma multi_compile _ _USE_DRAW_PROCEDURAL + #pragma multi_compile_fragment _ DEBUG_DISPLAY + + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Filtering.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/PostProcessing/Common.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/DebuggingFullscreen.hlsl" + + // Hardcoded dependencies to reduce the number of variants + #if _BLOOM_LQ || _BLOOM_HQ || _BLOOM_LQ_DIRT || _BLOOM_HQ_DIRT + #define BLOOM + #if _BLOOM_LQ_DIRT || _BLOOM_HQ_DIRT + #define BLOOM_DIRT + #endif + #endif + + TEXTURE2D_X(_SourceTex); + TEXTURE2D_X(_Bloom_Texture); + TEXTURE2D(_LensDirt_Texture); + TEXTURE2D(_Grain_Texture); + TEXTURE2D(_InternalLut); + TEXTURE2D(_UserLut); + TEXTURE2D(_BlueNoise_Texture); + + float4 _Lut_Params; + float4 _UserLut_Params; + float4 _Bloom_Params; + float _Bloom_RGBM; + float4 _LensDirt_Params; + float _LensDirt_Intensity; + float4 _Distortion_Params1; + float4 _Distortion_Params2; + float _Chroma_Params; + half4 _Vignette_Params1; + float4 _Vignette_Params2; + float2 _Grain_Params; + float4 _Grain_TilingParams; + float4 _Bloom_Texture_TexelSize; + float4 _Dithering_Params; + + #define DistCenter _Distortion_Params1.xy + #define DistAxis _Distortion_Params1.zw + #define DistTheta _Distortion_Params2.x + #define DistSigma _Distortion_Params2.y + #define DistScale _Distortion_Params2.z + #define DistIntensity _Distortion_Params2.w + + #define ChromaAmount _Chroma_Params.x + + #define BloomIntensity _Bloom_Params.x + #define BloomTint _Bloom_Params.yzw + #define BloomRGBM _Bloom_RGBM.x + #define LensDirtScale _LensDirt_Params.xy + #define LensDirtOffset _LensDirt_Params.zw + #define LensDirtIntensity _LensDirt_Intensity.x + + #define VignetteColor _Vignette_Params1.xyz + #define VignetteCenter _Vignette_Params2.xy + #define VignetteIntensity _Vignette_Params2.z + #define VignetteSmoothness _Vignette_Params2.w + #define VignetteRoundness _Vignette_Params1.w + + #define LutParams _Lut_Params.xyz + #define PostExposure _Lut_Params.w + #define UserLutParams _UserLut_Params.xyz + #define UserLutContribution _UserLut_Params.w + + #define GrainIntensity _Grain_Params.x + #define GrainResponse _Grain_Params.y + #define GrainScale _Grain_TilingParams.xy + #define GrainOffset _Grain_TilingParams.zw + + #define DitheringScale _Dithering_Params.xy + #define DitheringOffset _Dithering_Params.zw + + float2 DistortUV(float2 uv) + { + // Note: this variant should never be set with XR + #if _DISTORTION + { + uv = (uv - 0.5) * DistScale + 0.5; + float2 ruv = DistAxis * (uv - 0.5 - DistCenter); + float ru = length(float2(ruv)); + + UNITY_BRANCH + if (DistIntensity > 0.0) + { + float wu = ru * DistTheta; + ru = tan(wu) * (rcp(ru * DistSigma)); + uv = uv + ruv * (ru - 1.0); + } + else + { + ru = rcp(ru) * DistTheta * atan(ru * DistSigma); + uv = uv + ruv * (ru - 1.0); + } + } + #endif + + return uv; + } + + half4 Frag(Varyings input) : SV_Target + { + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + + float2 uv = UnityStereoTransformScreenSpaceTex(input.uv); + float2 uvDistorted = DistortUV(uv); + + half3 color = (0.0).xxx; + + #if _CHROMATIC_ABERRATION + { + // Very fast version of chromatic aberration from HDRP using 3 samples and hardcoded + // spectral lut. Performs significantly better on lower end GPUs. + float2 coords = 2.0 * uv - 1.0; + float2 end = uv - coords * dot(coords, coords) * ChromaAmount; + float2 delta = (end - uv) / 3.0; + + half r = SAMPLE_TEXTURE2D_X(_SourceTex, sampler_LinearClamp, uvDistorted ).x; + half g = SAMPLE_TEXTURE2D_X(_SourceTex, sampler_LinearClamp, DistortUV(delta + uv) ).y; + half b = SAMPLE_TEXTURE2D_X(_SourceTex, sampler_LinearClamp, DistortUV(delta * 2.0 + uv)).z; + + color = half3(r, g, b); + } + #else + { + color = SAMPLE_TEXTURE2D_X(_SourceTex, sampler_LinearClamp, uvDistorted).xyz; + } + #endif + + // Gamma space... Just do the rest of Uber in linear and convert back to sRGB at the end + #if UNITY_COLORSPACE_GAMMA + { + color = GetSRGBToLinear(color); + } + #endif + + #if defined(BLOOM) + { + #if _BLOOM_HQ && !defined(SHADER_API_GLES) + half4 bloom = SampleTexture2DBicubic(TEXTURE2D_X_ARGS(_Bloom_Texture, sampler_LinearClamp), uvDistorted, _Bloom_Texture_TexelSize.zwxy, (1.0).xx, unity_StereoEyeIndex); + #else + half4 bloom = SAMPLE_TEXTURE2D_X(_Bloom_Texture, sampler_LinearClamp, uvDistorted); + #endif + + #if UNITY_COLORSPACE_GAMMA + bloom.xyz *= bloom.xyz; // γ to linear + #endif + + UNITY_BRANCH + if (BloomRGBM > 0) + { + bloom.xyz = DecodeRGBM(bloom); + } + + bloom.xyz *= BloomIntensity; + color += bloom.xyz * BloomTint; + + #if defined(BLOOM_DIRT) + { + // UVs for the dirt texture should be DistortUV(uv * DirtScale + DirtOffset) but + // considering we use a cover-style scale on the dirt texture the difference + // isn't massive so we chose to save a few ALUs here instead in case lens + // distortion is active. + half3 dirt = SAMPLE_TEXTURE2D(_LensDirt_Texture, sampler_LinearClamp, uvDistorted * LensDirtScale + LensDirtOffset).xyz; + dirt *= LensDirtIntensity; + color += dirt * bloom.xyz; + } + #endif + } + #endif + + // To save on variants we'll use an uniform branch for vignette. Lower end platforms + // don't like these but if we're running Uber it means we're running more expensive + // effects anyway. Lower-end devices would limit themselves to on-tile compatible effect + // and thus this shouldn't too much of a problem (famous last words). + UNITY_BRANCH + if (VignetteIntensity > 0) + { + color = ApplyVignette(color, uvDistorted, VignetteCenter, VignetteIntensity, VignetteRoundness, VignetteSmoothness, VignetteColor); + } + + // Color grading is always enabled when post-processing/uber is active + { + color = ApplyColorGrading(color, PostExposure, TEXTURE2D_ARGS(_InternalLut, sampler_LinearClamp), LutParams, TEXTURE2D_ARGS(_UserLut, sampler_LinearClamp), UserLutParams, UserLutContribution); + } + + #if _FILM_GRAIN + { + color = ApplyGrain(color, uv, TEXTURE2D_ARGS(_Grain_Texture, sampler_LinearRepeat), GrainIntensity, GrainResponse, GrainScale, GrainOffset); + } + #endif + + // When Unity is configured to use gamma color encoding, we ignore the request to convert to gamma 2.0 and instead fall back to sRGB encoding + #if _GAMMA_20 && !UNITY_COLORSPACE_GAMMA + { + color = LinearToGamma20(color); + } + // Back to sRGB + #elif UNITY_COLORSPACE_GAMMA || _LINEAR_TO_SRGB_CONVERSION + { + color = GetLinearToSRGB(color); + } + #endif + + #if _DITHERING + { + color = ApplyDithering(color, uv, TEXTURE2D_ARGS(_BlueNoise_Texture, sampler_PointRepeat), DitheringScale, DitheringOffset); + // Assume color > 0 and prevent 0 - ditherNoise. + // Negative colors can cause problems if fed back to the postprocess via render to FP16 texture. + color = max(color, 0); + } + #endif + + #if defined(DEBUG_DISPLAY) + half4 debugColor = 0; + + if(CanDebugOverrideOutputColor(half4(color, 1), uv, debugColor)) + { + return debugColor; + } + #endif + + half alpha = SAMPLE_TEXTURE2D_X(_SourceTex, sampler_LinearClamp, uvDistorted).w; + return half4(color, alpha); + } + + ENDHLSL + + SubShader + { + Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline"} + LOD 100 + ZTest Always ZWrite Off Cull Off + + Pass + { + Name "UberPost" + + HLSLPROGRAM + #pragma vertex FullscreenVert + #pragma fragment Frag + ENDHLSL + } + } +} \ No newline at end of file diff --git a/Assets/Art/Shaders/UberPP.shader.meta b/Assets/Art/Shaders/UberPP.shader.meta new file mode 100644 index 000000000..eabafab30 --- /dev/null +++ b/Assets/Art/Shaders/UberPP.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: a276db0b89af5f8468acef2e570bf1f7 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/ExtendedScriptableObjectDrawer.cs b/Assets/Editor/ExtendedScriptableObjectDrawer.cs new file mode 100644 index 000000000..ae75d6065 --- /dev/null +++ b/Assets/Editor/ExtendedScriptableObjectDrawer.cs @@ -0,0 +1,288 @@ +// Developed by Tom Kail at Inkle +// Released under the MIT Licence as held at https://opensource.org/licenses/MIT + +// Must be placed within a folder named "Editor" +using System; +using System.Reflection; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using Object = UnityEngine.Object; + +/// +/// Extends how ScriptableObject object references are displayed in the inspector +/// Shows you all values under the object reference +/// Also provides a button to create a new ScriptableObject if property is null. +/// +[CustomPropertyDrawer(typeof(ScriptableObject), true)] +public class ExtendedScriptableObjectDrawer : PropertyDrawer { + + public override float GetPropertyHeight (SerializedProperty property, GUIContent label) { + float totalHeight = EditorGUIUtility.singleLineHeight; + if(property.objectReferenceValue == null || !AreAnySubPropertiesVisible(property)){ + return totalHeight; + } + if(property.isExpanded) { + var data = property.objectReferenceValue as ScriptableObject; + if( data == null ) return EditorGUIUtility.singleLineHeight; + SerializedObject serializedObject = new SerializedObject(data); + SerializedProperty prop = serializedObject.GetIterator(); + if (prop.NextVisible(true)) { + do { + if(prop.name == "m_Script") continue; + var subProp = serializedObject.FindProperty(prop.name); + float height = EditorGUI.GetPropertyHeight(subProp, null, true) + EditorGUIUtility.standardVerticalSpacing; + totalHeight += height; + } + while (prop.NextVisible(false)); + } + // Add a tiny bit of height if open for the background + totalHeight += EditorGUIUtility.standardVerticalSpacing; + serializedObject.Dispose(); + } + return totalHeight; + } + + const int buttonWidth = 66; + + static readonly List ignoreClassFullNames = new List{ "TMPro.TMP_FontAsset" }; + + public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) { + EditorGUI.BeginProperty (position, label, property); + var type = GetFieldType(); + + if(type == null || ignoreClassFullNames.Contains(type.FullName)) { + EditorGUI.PropertyField(position, property, label); + EditorGUI.EndProperty (); + return; + } + + ScriptableObject propertySO = null; + if(!property.hasMultipleDifferentValues && property.serializedObject.targetObject != null && property.serializedObject.targetObject is ScriptableObject) { + propertySO = (ScriptableObject)property.serializedObject.targetObject; + } + + var propertyRect = Rect.zero; + var guiContent = new GUIContent(property.displayName); + var foldoutRect = new Rect(position.x, position.y, EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight); + if(property.objectReferenceValue != null && AreAnySubPropertiesVisible(property)) { + property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, guiContent, true); + } else { + // So yeah having a foldout look like a label is a weird hack + // but both code paths seem to need to be a foldout or + // the object field control goes weird when the codepath changes. + // I guess because foldout is an interactable control of its own and throws off the controlID? + foldoutRect.x += 12; + EditorGUI.Foldout(foldoutRect, property.isExpanded, guiContent, true, EditorStyles.label); + } + var indentedPosition = EditorGUI.IndentedRect(position); + var indentOffset = indentedPosition.x - position.x; + propertyRect = new Rect(position.x + (EditorGUIUtility.labelWidth - indentOffset), position.y, position.width - (EditorGUIUtility.labelWidth - indentOffset), EditorGUIUtility.singleLineHeight); + + if(propertySO != null || property.objectReferenceValue == null) { + propertyRect.width -= buttonWidth; + } + + EditorGUI.ObjectField(propertyRect, property, type, GUIContent.none); + if (GUI.changed) property.serializedObject.ApplyModifiedProperties(); + + var buttonRect = new Rect(position.x + position.width - buttonWidth, position.y, buttonWidth, EditorGUIUtility.singleLineHeight); + + if(property.propertyType == SerializedPropertyType.ObjectReference && property.objectReferenceValue != null) { + var data = (ScriptableObject)property.objectReferenceValue; + + if(property.isExpanded) { + // Draw a background that shows us clearly which fields are part of the ScriptableObject + GUI.Box(new Rect(0, position.y + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing - 1, Screen.width, position.height - EditorGUIUtility.singleLineHeight - EditorGUIUtility.standardVerticalSpacing), ""); + + EditorGUI.indentLevel++; + SerializedObject serializedObject = new SerializedObject(data); + + // Iterate over all the values and draw them + SerializedProperty prop = serializedObject.GetIterator(); + float y = position.y + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + if (prop.NextVisible(true)) { + do { + // Don't bother drawing the class file + if(prop.name == "m_Script") continue; + float height = EditorGUI.GetPropertyHeight(prop, new GUIContent(prop.displayName), true); + EditorGUI.PropertyField(new Rect(position.x, y, position.width-buttonWidth, height), prop, true); + y += height + EditorGUIUtility.standardVerticalSpacing; + } + while (prop.NextVisible(false)); + } + if (GUI.changed) + serializedObject.ApplyModifiedProperties(); + serializedObject.Dispose(); + EditorGUI.indentLevel--; + } + } else { + if(GUI.Button(buttonRect, "Create")) { + string selectedAssetPath = "Assets"; + if(property.serializedObject.targetObject is MonoBehaviour) { + MonoScript ms = MonoScript.FromMonoBehaviour((MonoBehaviour)property.serializedObject.targetObject); + selectedAssetPath = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath( ms )); + } + + property.objectReferenceValue = CreateAssetWithSavePrompt(type, selectedAssetPath); + } + } + property.serializedObject.ApplyModifiedProperties(); + EditorGUI.EndProperty (); + } + + public static T _GUILayout (string label, T objectReferenceValue, ref bool isExpanded) where T : ScriptableObject { + return _GUILayout(new GUIContent(label), objectReferenceValue, ref isExpanded); + } + + public static T _GUILayout (GUIContent label, T objectReferenceValue, ref bool isExpanded) where T : ScriptableObject { + Rect position = EditorGUILayout.BeginVertical(); + + var propertyRect = Rect.zero; + var guiContent = label; + var foldoutRect = new Rect(position.x, position.y, EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight); + if(objectReferenceValue != null) { + isExpanded = EditorGUI.Foldout(foldoutRect, isExpanded, guiContent, true); + + var indentedPosition = EditorGUI.IndentedRect(position); + var indentOffset = indentedPosition.x - position.x; + propertyRect = new Rect(position.x + EditorGUIUtility.labelWidth - indentOffset, position.y, position.width - EditorGUIUtility.labelWidth - indentOffset, EditorGUIUtility.singleLineHeight); + } else { + // So yeah having a foldout look like a label is a weird hack + // but both code paths seem to need to be a foldout or + // the object field control goes weird when the codepath changes. + // I guess because foldout is an interactable control of its own and throws off the controlID? + foldoutRect.x += 12; + EditorGUI.Foldout(foldoutRect, isExpanded, guiContent, true, EditorStyles.label); + + var indentedPosition = EditorGUI.IndentedRect(position); + var indentOffset = indentedPosition.x - position.x; + propertyRect = new Rect(position.x + EditorGUIUtility.labelWidth - indentOffset, position.y, position.width - EditorGUIUtility.labelWidth - indentOffset-60, EditorGUIUtility.singleLineHeight); + } + + EditorGUILayout.BeginHorizontal(); + objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent(" "), objectReferenceValue, typeof(T), false) as T; + + if(objectReferenceValue != null) { + + EditorGUILayout.EndHorizontal(); + if(isExpanded) { + DrawScriptableObjectChildFields(objectReferenceValue); + } + } else { + if(GUILayout.Button("Create", GUILayout.Width(buttonWidth))) { + string selectedAssetPath = "Assets"; + var newAsset = CreateAssetWithSavePrompt(typeof(T), selectedAssetPath); + if(newAsset != null) { + objectReferenceValue = (T)newAsset; + } + } + EditorGUILayout.EndHorizontal(); + } + EditorGUILayout.EndVertical(); + return objectReferenceValue; + } + + static void DrawScriptableObjectChildFields (T objectReferenceValue) where T : ScriptableObject { + // Draw a background that shows us clearly which fields are part of the ScriptableObject + EditorGUI.indentLevel++; + EditorGUILayout.BeginVertical(GUI.skin.box); + + var serializedObject = new SerializedObject(objectReferenceValue); + // Iterate over all the values and draw them + SerializedProperty prop = serializedObject.GetIterator(); + if (prop.NextVisible(true)) { + do { + // Don't bother drawing the class file + if(prop.name == "m_Script") continue; + EditorGUILayout.PropertyField(prop, true); + } + while (prop.NextVisible(false)); + } + if (GUI.changed) + serializedObject.ApplyModifiedProperties(); + serializedObject.Dispose(); + EditorGUILayout.EndVertical(); + EditorGUI.indentLevel--; + } + + public static T DrawScriptableObjectField (GUIContent label, T objectReferenceValue, ref bool isExpanded) where T : ScriptableObject { + Rect position = EditorGUILayout.BeginVertical(); + + var propertyRect = Rect.zero; + var guiContent = label; + var foldoutRect = new Rect(position.x, position.y, EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight); + if(objectReferenceValue != null) { + isExpanded = EditorGUI.Foldout(foldoutRect, isExpanded, guiContent, true); + + var indentedPosition = EditorGUI.IndentedRect(position); + var indentOffset = indentedPosition.x - position.x; + propertyRect = new Rect(position.x + EditorGUIUtility.labelWidth - indentOffset, position.y, position.width - EditorGUIUtility.labelWidth - indentOffset, EditorGUIUtility.singleLineHeight); + } else { + // So yeah having a foldout look like a label is a weird hack + // but both code paths seem to need to be a foldout or + // the object field control goes weird when the codepath changes. + // I guess because foldout is an interactable control of its own and throws off the controlID? + foldoutRect.x += 12; + EditorGUI.Foldout(foldoutRect, isExpanded, guiContent, true, EditorStyles.label); + + var indentedPosition = EditorGUI.IndentedRect(position); + var indentOffset = indentedPosition.x - position.x; + propertyRect = new Rect(position.x + EditorGUIUtility.labelWidth - indentOffset, position.y, position.width - EditorGUIUtility.labelWidth - indentOffset-60, EditorGUIUtility.singleLineHeight); + } + + EditorGUILayout.BeginHorizontal(); + objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent(" "), objectReferenceValue, typeof(T), false) as T; + + if(objectReferenceValue != null) { + EditorGUILayout.EndHorizontal(); + if(isExpanded) { + + } + } else { + if(GUILayout.Button("Create", GUILayout.Width(buttonWidth))) { + string selectedAssetPath = "Assets"; + var newAsset = CreateAssetWithSavePrompt(typeof(T), selectedAssetPath); + if(newAsset != null) { + objectReferenceValue = (T)newAsset; + } + } + EditorGUILayout.EndHorizontal(); + } + EditorGUILayout.EndVertical(); + return objectReferenceValue; + } + + // Creates a new ScriptableObject via the default Save File panel + static ScriptableObject CreateAssetWithSavePrompt (Type type, string path) { + path = EditorUtility.SaveFilePanelInProject("Save ScriptableObject", type.Name+".asset", "asset", "Enter a file name for the ScriptableObject.", path); + if (path == "") return null; + ScriptableObject asset = ScriptableObject.CreateInstance(type); + AssetDatabase.CreateAsset (asset, path); + AssetDatabase.SaveAssets (); + AssetDatabase.Refresh(); + AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate); + EditorGUIUtility.PingObject(asset); + return asset; + } + + Type GetFieldType () { + Type type = fieldInfo.FieldType; + if(type.IsArray) type = type.GetElementType(); + else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>)) type = type.GetGenericArguments()[0]; + return type; + } + + static bool AreAnySubPropertiesVisible(SerializedProperty property) { + var data = (ScriptableObject)property.objectReferenceValue; + SerializedObject serializedObject = new SerializedObject(data); + SerializedProperty prop = serializedObject.GetIterator(); + while (prop.NextVisible(true)) { + if (prop.name == "m_Script") continue; + return true; //if theres any visible property other than m_script + } + serializedObject.Dispose(); + return false; + } +} \ No newline at end of file diff --git a/Assets/Editor/ExtendedScriptableObjectDrawer.cs.meta b/Assets/Editor/ExtendedScriptableObjectDrawer.cs.meta new file mode 100644 index 000000000..097dd1260 --- /dev/null +++ b/Assets/Editor/ExtendedScriptableObjectDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a51d917f465881049bd0af38dc929380 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/ExportedBackgroundSceneTest.unity b/Assets/Scenes/ExportedBackgroundSceneTest.unity new file mode 100644 index 000000000..735c4c845 --- /dev/null +++ b/Assets/Scenes/ExportedBackgroundSceneTest.unity @@ -0,0 +1,388 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.12731749, g: 0.13414757, b: 0.1210787, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &649026867 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 649026869} + - component: {fileID: 649026868} + m_Layer: 0 + m_Name: BackgroundManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &649026868 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 649026867} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 36fcdb2a65df1a74bb4c49947268a3bf, type: 3} + m_Name: + m_EditorClassIdentifier: + mainCamera: {fileID: 863916995} + bgTexture: {fileID: 0} +--- !u!4 &649026869 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 649026867} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 863916998} + - {fileID: 1822444567} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &863916994 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 863916998} + - component: {fileID: 863916995} + - component: {fileID: 863916997} + - component: {fileID: 863916996} + m_Layer: 0 + m_Name: Background Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!20 &863916995 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 863916994} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!114 &863916996 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 863916994} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RenderShadows: 1 + m_RequiresDepthTextureOption: 2 + m_RequiresOpaqueTextureOption: 2 + m_CameraType: 0 + m_Cameras: [] + m_RendererIndex: -1 + m_VolumeLayerMask: + serializedVersion: 2 + m_Bits: 1 + m_VolumeTrigger: {fileID: 0} + m_VolumeFrameworkUpdateModeOption: 2 + m_RenderPostProcessing: 0 + m_Antialiasing: 0 + m_AntialiasingQuality: 2 + m_StopNaN: 0 + m_Dithering: 0 + m_ClearDepth: 1 + m_AllowXRRendering: 1 + m_RequiresDepthTexture: 0 + m_RequiresColorTexture: 0 + m_Version: 2 +--- !u!81 &863916997 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 863916994} + m_Enabled: 1 +--- !u!4 &863916998 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 863916994} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 649026869} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1822444566 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1822444567} + - component: {fileID: 1822444570} + - component: {fileID: 1822444569} + - component: {fileID: 1822444568} + m_Layer: 0 + m_Name: Magic Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1822444567 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1822444566} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 3.85} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 649026869} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!65 &1822444568 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1822444566} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &1822444569 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1822444566} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1822444570 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1822444566} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} diff --git a/Assets/Scenes/ExportedBackgroundSceneTest.unity.meta b/Assets/Scenes/ExportedBackgroundSceneTest.unity.meta new file mode 100644 index 000000000..aca026c2a --- /dev/null +++ b/Assets/Scenes/ExportedBackgroundSceneTest.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 07849bbfed1eddc4a8a78c2f28752b43 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Settings/CustomPostProcessData.asset b/Assets/Settings/CustomPostProcessData.asset new file mode 100644 index 000000000..95ab4fc7c --- /dev/null +++ b/Assets/Settings/CustomPostProcessData.asset @@ -0,0 +1,82 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 572910c10080c0945a0ef731ccedc739, type: 3} + m_Name: CustomPostProcessData + m_EditorClassIdentifier: + shaders: + stopNanPS: {fileID: 4800000, guid: 1121bb4e615ca3c48b214e79e841e823, type: 3} + subpixelMorphologicalAntialiasingPS: {fileID: 4800000, guid: 63eaba0ebfb82cc43bde059b4a8c65f6, + type: 3} + gaussianDepthOfFieldPS: {fileID: 4800000, guid: 5e7134d6e63e0bc47a1dd2669cedb379, + type: 3} + bokehDepthOfFieldPS: {fileID: 4800000, guid: 2aed67ad60045d54ba3a00c91e2d2631, + type: 3} + cameraMotionBlurPS: {fileID: 4800000, guid: 1edcd131364091c46a17cbff0b1de97a, + type: 3} + paniniProjectionPS: {fileID: 4800000, guid: a15b78cf8ca26ca4fb2090293153c62c, + type: 3} + lutBuilderLdrPS: {fileID: 4800000, guid: 65df88701913c224d95fc554db28381a, type: 3} + lutBuilderHdrPS: {fileID: 4800000, guid: ec9fec698a3456d4fb18cf8bacb7a2bc, type: 3} + bloomPS: {fileID: 4800000, guid: 5f1864addb451f54bae8c86d230f736e, type: 3} + LensFlareDataDrivenPS: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92, + type: 3} + scalingSetupPS: {fileID: 4800000, guid: e8ee25143a34b8c4388709ea947055d1, type: 3} + easuPS: {fileID: 4800000, guid: 562b7ae4f629f144aa97780546fce7c6, type: 3} + uberPostPS: {fileID: 4800000, guid: a276db0b89af5f8468acef2e570bf1f7, type: 3} + finalPostPassPS: {fileID: 4800000, guid: c49e63ed1bbcb334780a3bd19dfed403, type: 3} + textures: + blueNoise16LTex: + - {fileID: 2800000, guid: 81200413a40918d4d8702e94db29911c, type: 3} + - {fileID: 2800000, guid: d50c5e07c9911a74982bddf7f3075e7b, type: 3} + - {fileID: 2800000, guid: 1134690bf9216164dbc75050e35b7900, type: 3} + - {fileID: 2800000, guid: 7ce2118f74614a94aa8a0cdf2e6062c3, type: 3} + - {fileID: 2800000, guid: 2ca97df9d1801e84a8a8f2c53cb744f0, type: 3} + - {fileID: 2800000, guid: e63eef8f54aa9dc4da9a5ac094b503b5, type: 3} + - {fileID: 2800000, guid: 39451254daebd6d40b52899c1f1c0c1b, type: 3} + - {fileID: 2800000, guid: c94ad916058dff743b0f1c969ddbe660, type: 3} + - {fileID: 2800000, guid: ed5ea7ce59ca8ec4f9f14bf470a30f35, type: 3} + - {fileID: 2800000, guid: 071e954febf155243a6c81e48f452644, type: 3} + - {fileID: 2800000, guid: 96aaab9cc247d0b4c98132159688c1af, type: 3} + - {fileID: 2800000, guid: fc3fa8f108657e14486697c9a84ccfc5, type: 3} + - {fileID: 2800000, guid: bfed3e498947fcb4890b7f40f54d85b9, type: 3} + - {fileID: 2800000, guid: d512512f4af60a442ab3458489412954, type: 3} + - {fileID: 2800000, guid: 47a45908f6db0cb44a0d5e961143afec, type: 3} + - {fileID: 2800000, guid: 4dcc0502f8586f941b5c4a66717205e8, type: 3} + - {fileID: 2800000, guid: 9d92991794bb5864c8085468b97aa067, type: 3} + - {fileID: 2800000, guid: 14381521ff11cb74abe3fe65401c23be, type: 3} + - {fileID: 2800000, guid: d36f0fe53425e08499a2333cf423634c, type: 3} + - {fileID: 2800000, guid: d4044ea2490d63b43aa1765f8efbf8a9, type: 3} + - {fileID: 2800000, guid: c9bd74624d8070f429e3f46d161f9204, type: 3} + - {fileID: 2800000, guid: d5c9b274310e5524ebe32a4e4da3df1f, type: 3} + - {fileID: 2800000, guid: f69770e54f2823f43badf77916acad83, type: 3} + - {fileID: 2800000, guid: 10b6c6d22e73dea46a8ab36b6eebd629, type: 3} + - {fileID: 2800000, guid: a2ec5cbf5a9b64345ad3fab0912ddf7b, type: 3} + - {fileID: 2800000, guid: 1c3c6d69a645b804fa232004b96b7ad3, type: 3} + - {fileID: 2800000, guid: d18a24d7b4ed50f4387993566d9d3ae2, type: 3} + - {fileID: 2800000, guid: c989e1ed85cf7154caa922fec53e6af6, type: 3} + - {fileID: 2800000, guid: ff47e5a0f105eb34883b973e51f4db62, type: 3} + - {fileID: 2800000, guid: fa042edbfc40fbd4bad0ab9d505b1223, type: 3} + - {fileID: 2800000, guid: 896d9004736809c4fb5973b7c12eb8b9, type: 3} + - {fileID: 2800000, guid: 179f794063d2a66478e6e726f84a65bc, type: 3} + filmGrainTex: + - {fileID: 2800000, guid: 654c582f7f8a5a14dbd7d119cbde215d, type: 3} + - {fileID: 2800000, guid: dd77ffd079630404e879388999033049, type: 3} + - {fileID: 2800000, guid: 1097e90e1306e26439701489f391a6c0, type: 3} + - {fileID: 2800000, guid: f0b67500f7fad3b4c9f2b13e8f41ba6e, type: 3} + - {fileID: 2800000, guid: 9930fb4528622b34687b00bbe6883de7, type: 3} + - {fileID: 2800000, guid: bd9e8c758250ef449a4b4bfaad7a2133, type: 3} + - {fileID: 2800000, guid: 510a2f57334933e4a8dbabe4c30204e4, type: 3} + - {fileID: 2800000, guid: b4db8180660810945bf8d55ab44352ad, type: 3} + - {fileID: 2800000, guid: fd2fd78b392986e42a12df2177d3b89c, type: 3} + - {fileID: 2800000, guid: 5cdee82a77d13994f83b8fdabed7c301, type: 3} + smaaAreaTex: {fileID: 2800000, guid: d1f1048909d55cd4fa1126ab998f617e, type: 3} + smaaSearchTex: {fileID: 2800000, guid: 51eee22c2a633ef4aada830eed57c3fd, type: 3} diff --git a/Assets/Settings/CustomPostProcessData.asset.meta b/Assets/Settings/CustomPostProcessData.asset.meta new file mode 100644 index 000000000..6a15eaa91 --- /dev/null +++ b/Assets/Settings/CustomPostProcessData.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 66f375f5df7dfc84ca908273b0038a93 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Settings/High_Renderer.asset b/Assets/Settings/High_Renderer.asset index 8a8788717..b83cb7912 100644 --- a/Assets/Settings/High_Renderer.asset +++ b/Assets/Settings/High_Renderer.asset @@ -42,7 +42,7 @@ MonoBehaviour: - {fileID: -7153464507104564842} m_RendererFeatureMap: 96e9aa74eec9b99c m_UseNativeRenderPass: 0 - postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2} + postProcessData: {fileID: 11400000, guid: 66f375f5df7dfc84ca908273b0038a93, type: 2} xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2} shaders: blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3} diff --git a/Assets/Settings/Low_Renderer.asset b/Assets/Settings/Low_Renderer.asset index a39a1f8ee..acee9eebd 100644 --- a/Assets/Settings/Low_Renderer.asset +++ b/Assets/Settings/Low_Renderer.asset @@ -18,7 +18,7 @@ MonoBehaviour: m_RendererFeatures: [] m_RendererFeatureMap: m_UseNativeRenderPass: 0 - postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2} + postProcessData: {fileID: 11400000, guid: 66f375f5df7dfc84ca908273b0038a93, type: 2} xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2} shaders: blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3} From 4ea9b28cf764a14c47ea6c692f552a92a0e852c9 Mon Sep 17 00:00:00 2001 From: NyxTheShield Date: Wed, 10 May 2023 21:36:50 -0400 Subject: [PATCH 3/5] Custom Background Testing --- Assets/BackgroundManager.cs | 88 ++++++++++++++++++++++++++++++++ Assets/BackgroundManager.cs.meta | 11 ++++ Assets/Script/PlayMode/Play.cs | 18 ++++++- 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 Assets/BackgroundManager.cs create mode 100644 Assets/BackgroundManager.cs.meta diff --git a/Assets/BackgroundManager.cs b/Assets/BackgroundManager.cs new file mode 100644 index 000000000..b3528ba70 --- /dev/null +++ b/Assets/BackgroundManager.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; + +using UnityEngine; +using UnityEngine.Video; + +#if UNITY_EDITOR +using UnityEditor; +#endif +public class BackgroundManager : MonoBehaviour { + + public Camera mainCamera; + public RenderTexture bgTexture; + + // Start is called before the first frame update + void Start() { + bgTexture = new RenderTexture(Screen.currentResolution.width, Screen.currentResolution.height, 16, RenderTextureFormat.ARGB32); + bgTexture.Create(); + mainCamera.targetTexture = bgTexture; + } + + private void OnDestroy() { + bgTexture.Release(); + + } + + GameObject tromboneBackground; + + #if UNITY_EDITOR + [ContextMenu("Export Background")] + public void ExportBackground() { + tromboneBackground = gameObject; + string path = EditorUtility.SaveFilePanel("Save Trombone Background", string.Empty, "bg", + "yarground"); + + BuildTargetGroup selectedBuildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup; + BuildTarget activeBuildTarget = EditorUserBuildSettings.activeBuildTarget; + + GameObject clonedTromboneBackground = null; + + try { + if (!string.IsNullOrEmpty(path)) { + clonedTromboneBackground = Instantiate(tromboneBackground.gameObject); + + string fileName = Path.GetFileName(path); + string folderPath = Path.GetDirectoryName(path); + + // serialize tromboners (this one is not unity's fault, it's base game weirdness) + List trombonePaths = new List() { "Assets/_Background.prefab" }; + + + PrefabUtility.SaveAsPrefabAsset(clonedTromboneBackground.gameObject, "Assets/_Background.prefab"); + AssetBundleBuild assetBundleBuild = default; + assetBundleBuild.assetBundleName = fileName; + assetBundleBuild.assetNames = trombonePaths.ToArray(); + + BuildPipeline.BuildAssetBundles(Application.temporaryCachePath, + new AssetBundleBuild[] { assetBundleBuild }, BuildAssetBundleOptions.ForceRebuildAssetBundle, + EditorUserBuildSettings.activeBuildTarget); + EditorPrefs.SetString("currentBuildingAssetBundlePath", folderPath); + EditorUserBuildSettings.SwitchActiveBuildTarget(selectedBuildTargetGroup, activeBuildTarget); + + foreach (var asset in trombonePaths) { + AssetDatabase.DeleteAsset(asset); + } + + if (File.Exists(path)) File.Delete(path); + + // Unity seems to save the file in lower case, which is a problem on Linux, as file systems are case sensitive there + File.Move(Path.Combine(Application.temporaryCachePath, fileName.ToLowerInvariant()), path); + + AssetDatabase.Refresh(); + + EditorUtility.DisplayDialog("Export Successful!", "Export Successful!", "OK"); + + if (clonedTromboneBackground != null) DestroyImmediate(clonedTromboneBackground); + } + } + catch { + if (clonedTromboneBackground != null) DestroyImmediate(clonedTromboneBackground); + } + + } + + #endif +} diff --git a/Assets/BackgroundManager.cs.meta b/Assets/BackgroundManager.cs.meta new file mode 100644 index 000000000..0f4955caa --- /dev/null +++ b/Assets/BackgroundManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 36fcdb2a65df1a74bb4c49947268a3bf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Script/PlayMode/Play.cs b/Assets/Script/PlayMode/Play.cs index 7a6c645e3..f04835f9e 100644 --- a/Assets/Script/PlayMode/Play.cs +++ b/Assets/Script/PlayMode/Play.cs @@ -159,8 +159,24 @@ private void StartSong() { i++; } - SongStarted = true; + //Load Background + string backgroundPath = Path.Combine(song.Location, "bg.yarground"); + if (File.Exists(backgroundPath)) { + + var bundle = AssetBundle.LoadFromFile(backgroundPath); + var bg = bundle.LoadAsset("assets/_background.prefab"); + Instantiate(bg); + Debug.Log("Loaded Custom Background!"); + OnSongEnd += (SongEntry song) => { bundle.Unload(true);}; + } + else { + Debug.LogWarning($"There is no background file in {backgroundPath}!"); + } + SongStarted = true; + + + // Hide loading screen GameUI.Instance.loadingContainer.SetActive(false); From 7603328219c9277568603e2bbd1ffee9925c54b9 Mon Sep 17 00:00:00 2001 From: NyxTheShield Date: Wed, 10 May 2023 23:16:23 -0400 Subject: [PATCH 4/5] Support for VIdeo, PNG and Custom YARGrounds (Trombone Champ Style AssetBundles for customizable 3D BGs) --- .../Art/DummyBackgroundTexture.renderTexture | 39 ++++ .../DummyBackgroundTexture.renderTexture.meta | 8 + Assets/Art/Textures/PlayMode/Black.png | 3 + Assets/Art/Textures/PlayMode/Black.png.meta | 123 ++++++++++++ Assets/BackgroundManager.cs | 15 +- Assets/Nyx.meta | 8 + .../Scenes/ExportedBackgroundSceneTest.unity | 182 +++++++++++++++--- Assets/Scenes/PlayScene.unity | 135 ++++++++++++- Assets/Script/ImageHelper.cs | 104 ++++++++++ Assets/Script/ImageHelper.cs.meta | 11 ++ Assets/Script/PlayMode/Play.cs | 24 ++- Assets/Script/UI/GameUI.cs | 4 +- 12 files changed, 617 insertions(+), 39 deletions(-) create mode 100644 Assets/Art/DummyBackgroundTexture.renderTexture create mode 100644 Assets/Art/DummyBackgroundTexture.renderTexture.meta create mode 100644 Assets/Art/Textures/PlayMode/Black.png create mode 100644 Assets/Art/Textures/PlayMode/Black.png.meta create mode 100644 Assets/Nyx.meta create mode 100644 Assets/Script/ImageHelper.cs create mode 100644 Assets/Script/ImageHelper.cs.meta diff --git a/Assets/Art/DummyBackgroundTexture.renderTexture b/Assets/Art/DummyBackgroundTexture.renderTexture new file mode 100644 index 000000000..4556f7d63 --- /dev/null +++ b/Assets/Art/DummyBackgroundTexture.renderTexture @@ -0,0 +1,39 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!84 &8400000 +RenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: DummyBackgroundTexture + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + m_IsAlphaChannelOptional: 0 + serializedVersion: 5 + m_Width: 1920 + m_Height: 1080 + m_AntiAliasing: 1 + m_MipCount: -1 + m_DepthStencilFormat: 94 + m_ColorFormat: 40 + m_MipMap: 0 + m_GenerateMips: 1 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_EnableCompatibleFormat: 1 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 1 + m_Aniso: 0 + m_MipBias: 0 + m_WrapU: 1 + m_WrapV: 1 + m_WrapW: 1 + m_Dimension: 2 + m_VolumeDepth: 1 + m_ShadowSamplingMode: 2 diff --git a/Assets/Art/DummyBackgroundTexture.renderTexture.meta b/Assets/Art/DummyBackgroundTexture.renderTexture.meta new file mode 100644 index 000000000..53ddae3e4 --- /dev/null +++ b/Assets/Art/DummyBackgroundTexture.renderTexture.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6f01deee09a9c5846a83d96667de20f1 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 8400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Art/Textures/PlayMode/Black.png b/Assets/Art/Textures/PlayMode/Black.png new file mode 100644 index 000000000..a29ece6b0 --- /dev/null +++ b/Assets/Art/Textures/PlayMode/Black.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20c39023500e487e46fc5ff01da1d9c089b64dbf550a997de2b92b37d8f79326 +size 511 diff --git a/Assets/Art/Textures/PlayMode/Black.png.meta b/Assets/Art/Textures/PlayMode/Black.png.meta new file mode 100644 index 000000000..d660db121 --- /dev/null +++ b/Assets/Art/Textures/PlayMode/Black.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 72f9a6ffd095a1444af9067cad0cfefa +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BackgroundManager.cs b/Assets/BackgroundManager.cs index b3528ba70..941cc23ef 100644 --- a/Assets/BackgroundManager.cs +++ b/Assets/BackgroundManager.cs @@ -2,9 +2,10 @@ using System.Collections; using System.Collections.Generic; using System.IO; - +using UnityEditor.UI; using UnityEngine; using UnityEngine.Video; +using YARG.UI; #if UNITY_EDITOR using UnityEditor; @@ -13,26 +14,32 @@ public class BackgroundManager : MonoBehaviour { public Camera mainCamera; public RenderTexture bgTexture; - + + public AssetBundle bundle; // Start is called before the first frame update void Start() { + //Move object out of the way just in case + transform.position += Vector3.up * 1000; bgTexture = new RenderTexture(Screen.currentResolution.width, Screen.currentResolution.height, 16, RenderTextureFormat.ARGB32); bgTexture.Create(); mainCamera.targetTexture = bgTexture; + GameUI.Instance.background.texture = bgTexture; } private void OnDestroy() { bgTexture.Release(); - + bundle.Unload(true); } GameObject tromboneBackground; + //Code to export a background from the editor + //This honestly should be on a different class (and ideally on a completely different project as a template) but as a quick dirty PoC it will do for now #if UNITY_EDITOR [ContextMenu("Export Background")] public void ExportBackground() { tromboneBackground = gameObject; - string path = EditorUtility.SaveFilePanel("Save Trombone Background", string.Empty, "bg", + string path = EditorUtility.SaveFilePanel("Save Background", string.Empty, "bg", "yarground"); BuildTargetGroup selectedBuildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup; diff --git a/Assets/Nyx.meta b/Assets/Nyx.meta new file mode 100644 index 000000000..4457c5256 --- /dev/null +++ b/Assets/Nyx.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 47f6fa8a74fdf59458dfed1d340b5dc3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/ExportedBackgroundSceneTest.unity b/Assets/Scenes/ExportedBackgroundSceneTest.unity index 735c4c845..dd7285c09 100644 --- a/Assets/Scenes/ExportedBackgroundSceneTest.unity +++ b/Assets/Scenes/ExportedBackgroundSceneTest.unity @@ -133,6 +133,7 @@ GameObject: m_Component: - component: {fileID: 649026869} - component: {fileID: 649026868} + - component: {fileID: 649026870} m_Layer: 0 m_Name: BackgroundManager m_TagString: Untagged @@ -167,10 +168,32 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 863916998} - - {fileID: 1822444567} + - {fileID: 956942800} + - {fileID: 1171147136} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!95 &649026870 +Animator: + serializedVersion: 5 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 649026867} + m_Enabled: 0 + m_Avatar: {fileID: 0} + m_Controller: {fileID: 9100000, guid: dd83ff470ca1aaa4a888076102a0b23a, type: 2} + m_CullingMode: 0 + m_UpdateMode: 0 + m_ApplyRootMotion: 0 + m_LinearVelocityBlending: 0 + m_StabilizeFeet: 0 + m_WarningMessage: + m_HasTransformHierarchy: 1 + m_AllowConstantClipSamplingOptimization: 1 + m_KeepAnimatorStateOnDisable: 0 + m_WriteDefaultValuesOnDisable: 0 --- !u!1 &863916994 GameObject: m_ObjectHideFlags: 0 @@ -183,6 +206,7 @@ GameObject: - component: {fileID: 863916995} - component: {fileID: 863916997} - component: {fileID: 863916996} + - component: {fileID: 863916999} m_Layer: 0 m_Name: Background Camera m_TagString: Untagged @@ -281,15 +305,129 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 863916994} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalRotation: {x: 0.00512295, y: 0.025614718, z: 0.0000000349246, w: 0.99965876} + m_LocalPosition: {x: 0, y: 0.86, z: 1.4} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 649026869} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1822444566 +--- !u!1183024399 &863916999 +LookAtConstraint: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 863916994} + m_Enabled: 1 + m_Weight: 1 + m_RotationAtRest: {x: 0, y: 0, z: 0} + m_RotationOffset: {x: 0, y: 0, z: 0} + m_Roll: 0 + m_WorldUpObject: {fileID: 0} + m_UseUpObject: 0 + m_IsContraintActive: 1 + m_IsLocked: 1 + m_Sources: + - sourceTransform: {fileID: 1171147136} + weight: 1 +--- !u!1001 &956942799 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 649026869} + m_Modifications: + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_LocalScale.x + value: 8.01 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_LocalScale.y + value: 8.01 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_LocalScale.z + value: 8.01 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_LocalPosition.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_LocalPosition.z + value: 3.87 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_LocalRotation.w + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_LocalRotation.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 180 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_ConstrainProportionsScale + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 919132149155446097, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + propertyPath: m_Name + value: model + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 6186cb09dfc45e34c9db45f24f945085, type: 3} +--- !u!4 &956942800 stripped +Transform: + m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 6186cb09dfc45e34c9db45f24f945085, + type: 3} + m_PrefabInstance: {fileID: 956942799} + m_PrefabAsset: {fileID: 0} +--- !u!1 &1171147135 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -297,53 +435,53 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 1822444567} - - component: {fileID: 1822444570} - - component: {fileID: 1822444569} - - component: {fileID: 1822444568} + - component: {fileID: 1171147136} + - component: {fileID: 1171147139} + - component: {fileID: 1171147138} + - component: {fileID: 1171147137} m_Layer: 0 - m_Name: Magic Cube + m_Name: Look At m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &1822444567 +--- !u!4 &1171147136 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1822444566} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 3.85} - m_LocalScale: {x: 1, y: 1, z: 1} + m_GameObject: {fileID: 1171147135} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.08, y: 0.844, z: 2.96} + m_LocalScale: {x: 0.1, y: 0.1, z: 0.1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 649026869} - m_RootOrder: 1 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!65 &1822444568 +--- !u!65 &1171147137 BoxCollider: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1822444566} + m_GameObject: {fileID: 1171147135} m_Material: {fileID: 0} m_IsTrigger: 0 m_Enabled: 1 serializedVersion: 2 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} ---- !u!23 &1822444569 +--- !u!23 &1171147138 MeshRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1822444566} - m_Enabled: 1 + m_GameObject: {fileID: 1171147135} + m_Enabled: 0 m_CastShadows: 1 m_ReceiveShadows: 1 m_DynamicOccludee: 1 @@ -378,11 +516,11 @@ MeshRenderer: m_SortingLayer: 0 m_SortingOrder: 0 m_AdditionalVertexStreams: {fileID: 0} ---- !u!33 &1822444570 +--- !u!33 &1171147139 MeshFilter: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1822444566} + m_GameObject: {fileID: 1171147135} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} diff --git a/Assets/Scenes/PlayScene.unity b/Assets/Scenes/PlayScene.unity index 85b1fc6db..421bf5f5d 100644 --- a/Assets/Scenes/PlayScene.unity +++ b/Assets/Scenes/PlayScene.unity @@ -547,7 +547,7 @@ RectTransform: - {fileID: 589499774} - {fileID: 326008585} m_Father: {fileID: 1476172820} - m_RootOrder: 3 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} @@ -638,6 +638,115 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &240896117 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 240896118} + - component: {fileID: 240896120} + - component: {fileID: 240896119} + - component: {fileID: 240896121} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &240896118 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 240896117} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1476172820} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: -0.00032043} + m_SizeDelta: {x: 1280, y: 720.08} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &240896119 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 240896117} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Texture: {fileID: 8400000, guid: 6f01deee09a9c5846a83d96667de20f1, type: 2} + m_UVRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 +--- !u!222 &240896120 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 240896117} + m_CullTransparentMesh: 1 +--- !u!328 &240896121 +VideoPlayer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 240896117} + m_Enabled: 0 + m_VideoClip: {fileID: 0} + m_TargetCameraAlpha: 1 + m_TargetCamera3DLayout: 0 + m_TargetCamera: {fileID: 0} + m_TargetTexture: {fileID: 8400000, guid: 6f01deee09a9c5846a83d96667de20f1, type: 2} + m_TimeReference: 0 + m_TargetMaterialRenderer: {fileID: 0} + m_TargetMaterialProperty: + m_RenderMode: 2 + m_AspectRatio: 5 + m_DataSource: 1 + m_PlaybackSpeed: 1 + m_AudioOutputMode: 0 + m_TargetAudioSources: + - {fileID: 0} + m_DirectAudioVolumes: + - 1 + m_Url: + m_EnabledAudioTracks: 01 + m_DirectAudioMutes: 00 + m_ControlledAudioTrackCount: 1 + m_PlayOnAwake: 0 + m_SkipOnDrop: 1 + m_Looping: 1 + m_WaitForFirstFrame: 1 + m_FrameReadyEventEnabled: 0 + m_VideoShaders: [] --- !u!1 &264140536 GameObject: m_ObjectHideFlags: 0 @@ -1056,7 +1165,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1476172820} - m_RootOrder: 5 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -1534,7 +1643,7 @@ RectTransform: m_Children: - {fileID: 1146384955} m_Father: {fileID: 1476172820} - m_RootOrder: 8 + m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -1610,7 +1719,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1476172820} - m_RootOrder: 1 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} @@ -2219,7 +2328,7 @@ PrefabInstance: - target: {fileID: 1682100933276730677, guid: 039fee0ec42345d4f88c0625255415d4, type: 3} propertyPath: m_RootOrder - value: 7 + value: 8 objectReference: {fileID: 0} - target: {fileID: 1682100933276730677, guid: 039fee0ec42345d4f88c0625255415d4, type: 3} @@ -2331,6 +2440,11 @@ PrefabInstance: propertyPath: m_Name value: ScoreDisplay objectReference: {fileID: 0} + - target: {fileID: 1682100933276730678, guid: 039fee0ec42345d4f88c0625255415d4, + type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 039fee0ec42345d4f88c0625255415d4, type: 3} --- !u!224 &703550372 stripped @@ -3542,6 +3656,7 @@ RectTransform: m_LocalScale: {x: 0, y: 0, z: 0} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 240896118} - {fileID: 2062919431} - {fileID: 484464890} - {fileID: 2146974096} @@ -3580,6 +3695,8 @@ MonoBehaviour: loadingText: {fileID: 1146384956} loadingContainer: {fileID: 469667487} pauseMenu: {fileID: 8545365} + background: {fileID: 240896119} + videoPlayer: {fileID: 240896121} --- !u!1 &1489966284 GameObject: m_ObjectHideFlags: 0 @@ -4466,7 +4583,7 @@ RectTransform: m_Children: - {fileID: 468187699} m_Father: {fileID: 1476172820} - m_RootOrder: 4 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} @@ -4569,7 +4686,7 @@ RectTransform: - {fileID: 296535527} - {fileID: 1684901693} m_Father: {fileID: 1476172820} - m_RootOrder: 6 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -4747,7 +4864,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1476172820} - m_RootOrder: 0 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -5456,7 +5573,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1476172820} - m_RootOrder: 2 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} diff --git a/Assets/Script/ImageHelper.cs b/Assets/Script/ImageHelper.cs new file mode 100644 index 000000000..c399fc668 --- /dev/null +++ b/Assets/Script/ImageHelper.cs @@ -0,0 +1,104 @@ +using System.IO; +using System.Linq; +using System.Reflection; +using UnityEngine; + +namespace TrombLoader.Helpers +{ + /// + /// Utility class for loading Texture2D and Sprite objects. + /// + public static class ImageHelper + { + /// + /// Load a texture, given an array of bytes. + /// + /// The bytes that make up the image. + /// A Texture2D, or null if the array is empty. + public static Texture2D LoadTextureRaw(byte[] bytes) + { + if (bytes.Count() > 0) + { + Texture2D Tex2D = new Texture2D(2, 2); + if (Tex2D.LoadImage(bytes)) + return Tex2D; + } + return null; + } + + /// + /// Load a texture, given a file path. + /// + /// Path to the file. + /// A Texture2D, or null if the file cannot be found. + public static Texture2D LoadTextureFromFile(string path) + { + if (File.Exists(path)) return LoadTextureRaw(File.ReadAllBytes(path)); + + return null; + } + + /// + /// Load a texture from an embedded resource, given the path to the resource. + /// + /// Path to the image, decimal-delimited starting from the root namespace. + /// A Texture2D + public static Texture2D LoadTextureFromResources(string resourcePath) + { + return LoadTextureRaw(GetResource(Assembly.GetCallingAssembly(), resourcePath)); + } + + /// + /// Load a Sprite, given an array of bytes. + /// + /// The bytes that make up the image. + /// The number of pixels per Unity unit. + /// A Sprite. + public static Sprite LoadSpriteRaw(byte[] image, float pixelsPerUnit = 100.0f) + { + return LoadSpriteFromTexture(LoadTextureRaw(image), pixelsPerUnit); + } + + /// + /// Load a Sprite, given a Texture2D. + /// + /// Texture2D to create the Sprite from. + /// The number of pixels per Unity unit. + /// A Sprite, or null if the Texture2D is null. + public static Sprite LoadSpriteFromTexture(Texture2D texture, float pixelsPerUnit = 100.0f) + { + if (texture) return Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), pixelsPerUnit); + return null; + } + + /// + /// Load a Sprite, given a file path. + /// + /// Path to the file. + /// The number of pixels per Unity unit. + /// A Sprite, or null if the file cannot be found. + public static Sprite LoadSpriteFromFile(string path, float pixelsPerUnit = 100.0f) + { + return LoadSpriteFromTexture(LoadTextureFromFile(path), pixelsPerUnit); + } + + /// + /// Load a texture from an embedded resource, given the path to the resource. + /// + /// Path to the image, decimal-delimited starting from the root namespace. + /// The number of pixels per Unity unit. + /// A Sprite. + public static Sprite LoadSpriteFromResources(string resourcePath, float pixelsPerUnit = 100.0f) + { + return LoadSpriteRaw(GetResource(Assembly.GetCallingAssembly(), resourcePath), pixelsPerUnit); + } + + private static byte[] GetResource(Assembly asm, string resourcePath) + { + Stream stream = asm.GetManifestResourceStream(resourcePath); + byte[] data = new byte[stream.Length]; + stream.Read(data, 0, (int)stream.Length); + return data; + } + } +} diff --git a/Assets/Script/ImageHelper.cs.meta b/Assets/Script/ImageHelper.cs.meta new file mode 100644 index 000000000..aed04adc5 --- /dev/null +++ b/Assets/Script/ImageHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dcb68c285571b324597ea4df754fd1ee +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Script/PlayMode/Play.cs b/Assets/Script/PlayMode/Play.cs index f04835f9e..4b5276b71 100644 --- a/Assets/Script/PlayMode/Play.cs +++ b/Assets/Script/PlayMode/Play.cs @@ -4,6 +4,7 @@ using System.IO; using MoonscraperChartEditor.Song; using MoonscraperChartEditor.Song.IO; +using TrombLoader.Helpers; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.InputSystem; @@ -161,16 +162,33 @@ private void StartSong() { //Load Background string backgroundPath = Path.Combine(song.Location, "bg.yarground"); + string mp4Path = Path.Combine(song.Location, "bg.mp4"); + string pngPath = Path.Combine(song.Location, "bg.png"); + //First check heck for a yarground if (File.Exists(backgroundPath)) { var bundle = AssetBundle.LoadFromFile(backgroundPath); var bg = bundle.LoadAsset("assets/_background.prefab"); - Instantiate(bg); + var bgInstance = Instantiate(bg); + bgInstance.GetComponent().bundle = bundle; Debug.Log("Loaded Custom Background!"); - OnSongEnd += (SongEntry song) => { bundle.Unload(true);}; + + } + //If not, check for a + else if (File.Exists(mp4Path)) { + GameUI.Instance.videoPlayer.url = mp4Path; + GameUI.Instance.videoPlayer.enabled = true; + GameUI.Instance.videoPlayer.Play(); } + + else if (File.Exists(pngPath)) { + var png = ImageHelper.LoadTextureFromFile(pngPath); + + GameUI.Instance.background.texture = png; + } + //No background file, we load a random video else { - Debug.LogWarning($"There is no background file in {backgroundPath}!"); + //TODO: Add custom videos folder, load here } SongStarted = true; diff --git a/Assets/Script/UI/GameUI.cs b/Assets/Script/UI/GameUI.cs index 469a931bb..d3881b58f 100644 --- a/Assets/Script/UI/GameUI.cs +++ b/Assets/Script/UI/GameUI.cs @@ -1,6 +1,7 @@ using TMPro; using UnityEngine; using UnityEngine.UI; +using UnityEngine.Video; using YARG.PlayMode; using YARG.Util; @@ -23,7 +24,8 @@ public class GameUI : MonoBehaviour { public GameObject loadingContainer; public GameObject pauseMenu; - + public RawImage background; + public VideoPlayer videoPlayer; public static GameUI Instance { get; private set; From 64fb0ff7bbc1c3f911baf95c767a4975e4338c96 Mon Sep 17 00:00:00 2001 From: NyxTheShield Date: Wed, 10 May 2023 23:22:12 -0400 Subject: [PATCH 5/5] FIxed wrong imports for build --- Assets/BackgroundManager.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Assets/BackgroundManager.cs b/Assets/BackgroundManager.cs index 941cc23ef..c8026b103 100644 --- a/Assets/BackgroundManager.cs +++ b/Assets/BackgroundManager.cs @@ -2,9 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.IO; -using UnityEditor.UI; using UnityEngine; -using UnityEngine.Video; using YARG.UI; #if UNITY_EDITOR