Skip to content

Commit

Permalink
Add Scriptable Object Pattern and Project OverView.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonNordon4 committed Dec 10, 2024
1 parent f163848 commit 9cd1fdb
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ MonoBehaviour:
- rid: 2270719253998731264
type: {class: WebGLPlatformSettings, ns: UnityEditor.WebGL, asm: UnityEditor.WebGL.Extensions}
data:
m_Development: 1
m_ConnectProfiler: 1
m_Development: 0
m_ConnectProfiler: 0
m_BuildWithDeepProfilingSupport: 0
m_AllowDebugging: 0
m_WaitForManagedDebugger: 0
Expand Down
44 changes: 22 additions & 22 deletions Assets/Settings/UniversalRenderPipelineGlobalSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,24 @@ MonoBehaviour:
- rid: 6061690417623335090
- rid: 6061690417623335091
- rid: 6061690417623335092
- rid: 2270719338546200714
- rid: 2270719358191009872
- rid: 6061690417623335094
- rid: 6061690417623335095
- rid: 2270719338546200715
- rid: 2270719338546200716
- rid: 2270719358191009873
- rid: 2270719358191009874
- rid: 6061690417623335098
- rid: 2270719338546200717
- rid: 2270719358191009875
- rid: 6061690417623335100
- rid: 2270719338546200718
- rid: 2270719338546200719
- rid: 2270719338546200720
- rid: 2270719338546200721
- rid: 2270719358191009876
- rid: 2270719358191009877
- rid: 2270719358191009878
- rid: 2270719358191009879
- rid: 6061690417623335105
- rid: 6061690417623335106
- rid: 2270719338546200722
- rid: 2270719338546200723
- rid: 2270719358191009880
- rid: 2270719358191009881
- rid: 6061690417623335109
- rid: 2270719338546200724
- rid: 2270719358191009882
m_RuntimeSettings:
m_List:
- rid: 6061690417623335090
Expand Down Expand Up @@ -96,7 +96,7 @@ MonoBehaviour:
references:
version: 2
RefIds:
- rid: 2270719338546200714
- rid: 2270719358191009872
type: {class: Renderer2DResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
data:
m_Version: 0
Expand All @@ -111,22 +111,22 @@ MonoBehaviour:
m_DefaultLitMaterial: {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
m_DefaultUnlitMaterial: {fileID: 2100000, guid: 9dfc825aed78fcd4ba02077103263b40, type: 2}
m_DefaultMaskMaterial: {fileID: 2100000, guid: 15d0c3709176029428a0da2f8cecf0b5, type: 2}
- rid: 2270719338546200715
- rid: 2270719358191009873
type: {class: URPShaderStrippingSetting, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
data:
m_Version: 0
m_StripUnusedPostProcessingVariants: 1
m_StripUnusedVariants: 1
m_StripScreenCoordOverrideVariants: 1
- rid: 2270719338546200716
- rid: 2270719358191009874
type: {class: UniversalRenderPipelineEditorMaterials, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
data:
m_DefaultMaterial: {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_DefaultParticleMaterial: {fileID: 2100000, guid: e823cd5b5d27c0f4b8256e7c12ee3e6d, type: 2}
m_DefaultLineMaterial: {fileID: 2100000, guid: e823cd5b5d27c0f4b8256e7c12ee3e6d, type: 2}
m_DefaultTerrainMaterial: {fileID: 2100000, guid: 594ea882c5a793440b60ff72d896021e, type: 2}
m_DefaultDecalMaterial: {fileID: 2100000, guid: 31d0dcc6f2dd4e4408d18036a2c93862, type: 2}
- rid: 2270719338546200717
- rid: 2270719358191009875
type: {class: UniversalRenderPipelineEditorShaders, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
data:
m_AutodeskInteractive: {fileID: 4800000, guid: 0e9d5a909a1f7e84882a534d0d11e49f, type: 3}
Expand All @@ -138,7 +138,7 @@ MonoBehaviour:
m_DefaultSpeedTree7Shader: {fileID: 4800000, guid: 0f4122b9a743b744abe2fb6a0a88868b, type: 3}
m_DefaultSpeedTree8Shader: {fileID: -6465566751694194690, guid: 9920c1f1781549a46ba081a2a15a16ec, type: 3}
m_DefaultSpeedTree9Shader: {fileID: -6465566751694194690, guid: cbd3e1cc4ae141c42a30e33b4d666a61, type: 3}
- rid: 2270719338546200718
- rid: 2270719358191009876
type: {class: GPUResidentDrawerResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.GPUDriven.Runtime}
data:
m_Version: 0
Expand All @@ -151,13 +151,13 @@ MonoBehaviour:
m_OcclusionCullingDebugKernels: {fileID: 7200000, guid: b23e766bcf50ca4438ef186b174557df, type: 3}
m_DebugOcclusionTestPS: {fileID: 4800000, guid: d3f0849180c2d0944bc71060693df100, type: 3}
m_DebugOccluderPS: {fileID: 4800000, guid: b3c92426a88625841ab15ca6a7917248, type: 3}
- rid: 2270719338546200719
- rid: 2270719358191009877
type: {class: STP/RuntimeResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
data:
m_setupCS: {fileID: 7200000, guid: 33be2e9a5506b2843bdb2bdff9cad5e1, type: 3}
m_preTaaCS: {fileID: 7200000, guid: a679dba8ec4d9ce45884a270b0e22dda, type: 3}
m_taaCS: {fileID: 7200000, guid: 3923900e2b41b5e47bc25bfdcbcdc9e6, type: 3}
- rid: 2270719338546200720
- rid: 2270719358191009878
type: {class: ProbeVolumeDebugResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
data:
m_Version: 1
Expand All @@ -167,7 +167,7 @@ MonoBehaviour:
probeVolumeOffsetDebugShader: {fileID: 4800000, guid: db8bd7436dc2c5f4c92655307d198381, type: 3}
probeSamplingDebugMesh: {fileID: -3555484719484374845, guid: 20be25aac4e22ee49a7db76fb3df6de2, type: 3}
numbersDisplayTex: {fileID: 2800000, guid: 73fe53b428c5b3440b7e87ee830b608a, type: 3}
- rid: 2270719338546200721
- rid: 2270719358191009879
type: {class: ProbeVolumeBakingResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
data:
m_Version: 1
Expand All @@ -180,19 +180,19 @@ MonoBehaviour:
skyOcclusionRT: {fileID: -5126288278712620388, guid: 5a2a534753fbdb44e96c3c78b5a6999d, type: 3}
renderingLayerCS: {fileID: -6772857160820960102, guid: 94a070d33e408384bafc1dea4a565df9, type: 3}
renderingLayerRT: {fileID: -5126288278712620388, guid: 94a070d33e408384bafc1dea4a565df9, type: 3}
- rid: 2270719338546200722
- rid: 2270719358191009880
type: {class: ProbeVolumeGlobalSettings, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
data:
m_Version: 1
m_ProbeVolumeDisableStreamingAssets: 0
- rid: 2270719338546200723
- rid: 2270719358191009881
type: {class: ProbeVolumeRuntimeResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
data:
m_Version: 1
probeVolumeBlendStatesCS: {fileID: 7200000, guid: a3f7b8c99de28a94684cb1daebeccf5d, type: 3}
probeVolumeUploadDataCS: {fileID: 7200000, guid: 0951de5992461754fa73650732c4954c, type: 3}
probeVolumeUploadDataL2CS: {fileID: 7200000, guid: 6196f34ed825db14b81fb3eb0ea8d931, type: 3}
- rid: 2270719338546200724
- rid: 2270719358191009882
type: {class: IncludeAdditionalRPAssets, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
data:
m_version: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ public abstract class ScriptableBehaviour : ScriptableData
/// </summary>
public abstract void OnUpdate();

private void OnEnable()

protected override void OnEnable()
{
base.OnEnable();
EnablePlayerLoop();
#if UNITY_EDITOR
UnityEditor.EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
#endif
}

private void OnDisable()
protected override void OnDisable()
{
base.OnDisable();

#if UNITY_EDITOR
UnityEditor.EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
#endif
Expand All @@ -33,7 +34,6 @@ private void OnDisable()
DisablePlayerLoop();
}
}

#if UNITY_EDITOR
private void OnPlayModeStateChanged(UnityEditor.PlayModeStateChange stateChange)
{
Expand Down Expand Up @@ -83,11 +83,5 @@ private void DisablePlayerLoop()

_isActive = false;
}

public static void Initialize()
{

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@ public abstract class ScriptableData : ScriptableObject
{
protected bool IsPlayMode;

public void OnDestroy()
{
Debug.Log($"Destroyed {GetType()}");
}

/// <summary>
/// Method to define how data should reset.
/// Override this in derived classes.
/// </summary>
public abstract void ResetData();


protected virtual void OnEnable()
{
#if UNITY_EDITOR
Expand All @@ -28,6 +24,7 @@ protected virtual void OnEnable()

EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
#endif

}

protected virtual void OnDisable()
Expand All @@ -39,21 +36,17 @@ protected virtual void OnDisable()
#if UNITY_EDITOR
private void OnPlayModeStateChanged(PlayModeStateChange stateChange)
{

if (stateChange == PlayModeStateChange.EnteredPlayMode)
{
IsPlayMode = true;
}
else if (stateChange == PlayModeStateChange.ExitingEditMode)
{
// Avoid resetting data unnecessarily
Debug.Log("Exiting edit mode, skipping ResetData.");
}
else if (IsPlayMode && stateChange == PlayModeStateChange.ExitingPlayMode)
{
Debug.Log("ResetData called for: " + name);
ResetData();
IsPlayMode = false;
}

}
#endif

Expand Down
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
107 changes: 107 additions & 0 deletions Builds/ScriptableObjectPattern/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<!DOCTYPE html>
<html lang="en-us">

<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ScriptableObjectPattern</title>
<style>
html,
body {
background: #000;
width: 100%;
height: 100%;
overflow: visible;
padding: 0;
margin: 0;
}

div#gameContainer {
background: transparent !important;
position: absolute;
}

div#gameContainer canvas {
position: absolute;
}

div#gameContainer canvas[data-pixel-art="true"] {
position: absolute;
image-rendering: optimizeSpeed;
image-rendering: -webkit-crisp-edges;
image-rendering: -moz-crisp-edges;
image-rendering: -o-crisp-edges;
image-rendering: crisp-edges;
image-rendering: -webkit-optimize-contrast;
image-rendering: optimize-contrast;
image-rendering: pixelated;
-ms-interpolation-mode: nearest-neighbor;
}
</style>
</head>

<body>
<div id="gameContainer">
<canvas id="unity-canvas" data-pixel-art="false"></canvas>
<script src="Build/ScriptableObjectPattern.loader.js"></script>
<script>
var canvas = document.querySelector("#unity-canvas");
var config = {
dataUrl: "Build/ScriptableObjectPattern.data.unityweb",
frameworkUrl: "Build/ScriptableObjectPattern.framework.js.unityweb",
codeUrl: "Build/ScriptableObjectPattern.wasm.unityweb",
streamingAssetsUrl: "StreamingAssets",
companyName: "SimonNordon",
productName: "ScriptableObjectPattern",
productVersion: "1.0",
};
var scaleToFit = true;
function progressHandler(progress) {
var percent = progress * 100 + '%';
canvas.style.background = 'linear-gradient(to right, white, white ' + percent + ', transparent ' + percent + ', transparent) no-repeat center';
canvas.style.backgroundSize = '100% 1rem';
}
function onResize() {
var container = canvas.parentElement;
var w;
var h;

if (scaleToFit) {
w = window.innerWidth;
h = window.innerHeight;

var r = 600 / 960;

if (w * r > window.innerHeight) {
w = Math.min(w, Math.ceil(h / r));
}
h = Math.floor(w * r);
} else {
w = 960;
h = 600;
}

container.style.width = canvas.style.width = w + "px";
container.style.height = canvas.style.height = h + "px";
container.style.top = Math.floor((window.innerHeight - h) / 2) + "px";
container.style.left = Math.floor((window.innerWidth - w) / 2) + "px";
}
createUnityInstance(canvas, config, progressHandler).then(function (instance) {
canvas = instance.Module.canvas;
onResize();
});
window.addEventListener('resize', onResize);
onResize();

if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
// Mobile device style: fill the whole browser client area with the game canvas:
const meta = document.createElement('meta');
meta.name = 'viewport';
meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
document.getElementsByTagName('head')[0].appendChild(meta);
}
</script>
</div>
</body>

</html>
16 changes: 8 additions & 8 deletions ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ PlayerSettings:
m_SpriteBatchMaxVertexCount: 65535
m_SpriteBatchVertexThreshold: 300
m_MTRendering: 1
mipStripping: 0
mipStripping: 1
numberOfMipsStripped: 0
numberOfMipsStrippedPerMipmapLimitGroup: {}
m_StackTraceTypes: 010000000100000001000000010000000100000001000000
Expand Down Expand Up @@ -91,7 +91,7 @@ PlayerSettings:
submitAnalytics: 1
usePlayerLog: 1
dedicatedServerOptimizations: 1
bakeCollisionMeshes: 0
bakeCollisionMeshes: 1
forceSingleInstance: 0
useFlipModelSwapchain: 1
resizableWindow: 0
Expand Down Expand Up @@ -182,7 +182,7 @@ PlayerSettings:
CreateWallpaper: 0
androidSplitApplicationBinary: 0
keepLoadedShadersAlive: 0
StripUnusedMeshComponents: 0
StripUnusedMeshComponents: 1
strictShaderVariantMatching: 0
VertexChannelCompressionMask: 4054
iPhoneSdkVersion: 988
Expand Down Expand Up @@ -554,18 +554,18 @@ PlayerSettings:
webGLExceptionSupport: 1
webGLNameFilesAsHashes: 0
webGLShowDiagnostics: 0
webGLDataCaching: 0
webGLDataCaching: 1
webGLDebugSymbols: 0
webGLEmscriptenArgs:
webGLModulesDirectory:
webGLTemplate: Default
webGLTemplate: PROJECT:EnhancedTemplate
webGLAnalyzeBuildSize: 0
webGLUseEmbeddedResources: 0
webGLCompressionFormat: 2
webGLCompressionFormat: 0
webGLWasmArithmeticExceptions: 0
webGLLinkerTarget: 1
webGLThreadsSupport: 0
webGLDecompressionFallback: 0
webGLDecompressionFallback: 1
webGLInitialMemorySize: 32
webGLMaximumMemorySize: 2048
webGLMemoryGrowthMode: 2
Expand All @@ -588,7 +588,7 @@ PlayerSettings:
il2cppCodeGeneration: {}
il2cppStacktraceInformation: {}
managedStrippingLevel:
WebGL: 4
WebGL: 2
incrementalIl2cppBuild: {}
suppressCommonWarnings: 1
allowUnsafeCode: 0
Expand Down
Loading

0 comments on commit 9cd1fdb

Please sign in to comment.