Skip to content

Commit

Permalink
0.9.0 with Entities 0.50 support
Browse files Browse the repository at this point in the history
  • Loading branch information
tbg10101 committed Mar 29, 2022
1 parent 1ce7286 commit 747abd6
Show file tree
Hide file tree
Showing 30 changed files with 250 additions and 362 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Material:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Test
m_Name: Scenery
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
m_ShaderKeywords: _SPECULAR_COLOR
m_LightmapFlags: 4
Expand Down Expand Up @@ -118,7 +118,7 @@ Material:
- _ReceiveShadows: 1
- _SampleGI: 0
- _Shininess: 0
- _Smoothness: 0.5
- _Smoothness: 0.2
- _SmoothnessSource: 0
- _SmoothnessTextureChannel: 0
- _SpecSource: 0
Expand All @@ -129,8 +129,8 @@ Material:
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor: {r: 0.57844627, g: 0.8301887, b: 0.5208259, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999978, g: 0.19999978, b: 0.19999978, a: 0.5}
- _SpecColor: {r: 0.19998756, g: 0.19998756, b: 0.19998756, a: 0.2}
m_BuildTextureStacks: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Test Material
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: 2000
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossinessSource: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Shininess: 0
- _Smoothness: 0.5
- _SmoothnessSource: 0
- _SmoothnessTextureChannel: 0
- _SpecSource: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.1999999, g: 0.1999999, b: 0.1999999, a: 0.5}
m_BuildTextureStacks: []
--- !u!114 &3226815170270220724
MonoBehaviour:
m_ObjectHideFlags: 11
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: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 4

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 10cd3273bb8895845abac9a0a36b2b68, type: 2}
- {fileID: 2100000, guid: d2cb46a9820e91f469458fc5bc541f37, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
Expand Down Expand Up @@ -94,3 +94,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 375e5906166d43e7adbd77db74139c2c, type: 3}
m_Name:
m_EditorClassIdentifier:
DestroyMe: 0
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ MonoBehaviour:
m_RequireOpaqueTexture: 0
m_OpaqueDownsampling: 1
m_SupportsTerrainHoles: 0
m_StoreActionsOptimization: 0
m_SupportsHDR: 0
m_MSAA: 1
m_RenderScale: 1
Expand All @@ -33,9 +34,6 @@ MonoBehaviour:
m_AdditionalLightsPerObjectLimit: 4
m_AdditionalLightShadowsSupported: 0
m_AdditionalLightsShadowmapResolution: 512
m_AdditionalLightsShadowResolutionTierLow: 128
m_AdditionalLightsShadowResolutionTierMedium: 256
m_AdditionalLightsShadowResolutionTierHigh: 512
m_ShadowDistance: 100
m_ShadowCascadeCount: 4
m_Cascade2Split: 0.25
Expand All @@ -51,11 +49,11 @@ MonoBehaviour:
m_UseAdaptivePerformance: 1
m_ColorGradingMode: 0
m_ColorGradingLutSize: 32
m_UseFastSRGBLinearConversion: 0
m_ShadowType: 1
m_LocalShadowsSupported: 0
m_LocalShadowsAtlasResolution: 256
m_MaxPixelLights: 0
m_ShadowAtlasResolution: 256
m_ShaderVariantLogLevel: 0
m_VolumeFrameworkUpdateMode: 0
m_ShadowCascades: 2
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,9 @@ MonoBehaviour:
_simulationResetSystems: []
_mainSimulationSystems:
- {fileID: 11400000, guid: b55916dcf0ef8ed4a9c0aa675f60e447, type: 2}
- {fileID: 11400000, guid: a2c5f951bc7bf904cb32976be936ea2d, type: 2}
_presentationPreUpdateSystems:
- {fileID: 11400000, guid: e8b4045ab457dba4f8c6c5031b4de4f7, type: 2}
- {fileID: 11400000, guid: a2c5f951bc7bf904cb32976be936ea2d, type: 2}
_presentationPostUpdateSystems: []
_endOfFrameSystems: []
EntitiesToGenerate: 2000
Expand Down Expand Up @@ -665,7 +665,7 @@ MonoBehaviour:
m_VolumeTrigger: {fileID: 0}
m_VolumeFrameworkUpdateModeOption: 2
m_RenderPostProcessing: 0
m_Antialiasing: 1
m_Antialiasing: 0
m_AntialiasingQuality: 2
m_StopNaN: 0
m_Dithering: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"GUID:852fdcd981c08e249a237d901a75e290",
"GUID:734d92eba21c94caba915361bd5ac177",
"GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:6f70aebd52e2e43498de74bdaa4389ef",
"GUID:e0cd26848372d4e5c891c569017e11f1"
"GUID:e0cd26848372d4e5c891c569017e11f1",
"GUID:2665a8d13d1b3f18800f46e256720795"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ namespace Software10101.DOTS.Example.Systems {
[CreateAssetMenu(menuName = "Systems/" + nameof(ApplyVelocitySystem))]
public class ApplyVelocitySystemReference : SystemTypeReference<ApplyVelocitySystem> { }

public class ApplyVelocitySystem : SystemBase {
// ReSharper disable once PartialTypeWithSinglePart // systems need to be partial after Entities 0.50
public partial class ApplyVelocitySystem : SystemBase {
protected override void OnUpdate() {
float dt = TimeUtil.FixedDeltaTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace Software10101.DOTS.Example.Systems {
[CreateAssetMenu(menuName = "Systems/" + nameof(PositionPresentationSystem))]
public class PositionPresentationSystemReference : SystemTypeReference<PositionPresentationSystem> { }

public class PositionPresentationSystem : SystemBase {
// ReSharper disable once PartialTypeWithSinglePart // systems need to be partial after Entities 0.50
public partial class PositionPresentationSystem : SystemBase {
protected override void OnUpdate() {
float presentationFraction = TimeUtil.PresentationTimeFraction; // this is done just once instead of once per instance

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ namespace Software10101.DOTS.Example.Systems {
[CreateAssetMenu(menuName = "Systems/" + nameof(ShuffleEntitiesExampleSystem))]
public class ShuffleEntitiesExampleReference : SystemTypeReference<ShuffleEntitiesExampleSystem> { }

public class ShuffleEntitiesExampleSystem : SystemBase {
// ReSharper disable once PartialTypeWithSinglePart // systems need to be partial after Entities 0.50
public partial class ShuffleEntitiesExampleSystem : SystemBase {
protected override void OnUpdate() {
// encapsulate the random
NativeSingleton<Random> random = new NativeSingleton<Random>(
new Random(Convert.ToUInt32(new System.Random().Next())),
Allocator.TempJob);
Random r = new Random(Convert.ToUInt32(new System.Random().Next()));

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// get entities with position
Expand All @@ -33,30 +31,26 @@ protected override void OnUpdate() {
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Job
.WithCode(() => {
Random r = random.GetValue();

// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modern_method
for (int i = entitiesWithPosition.Length - 1; i >= 1; i--) {
int j = r.NextInt(0, i + 1); // max is not inclusive
(entitiesWithPosition[i], entitiesWithPosition[j]) =
(entitiesWithPosition[j], entitiesWithPosition[i]);
}

random.SetValue(r);
})
.WithDisposeOnCompletion(random)
.Schedule();

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// do something with the shuffled list and dispose of it
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Job
.WithCode(() => {
int length = entitiesWithPosition.Length;

for (int i = 0; i < length; i++) {
Entity e = entitiesWithPosition[i];
if (entitiesWithPosition.IsEmpty) {
return;
}

int index = entitiesWithPosition[0].Index;
Debug.Log($"Initial shuffled entity index: {index}");
})
.WithDisposeOnCompletion(entitiesWithPosition)
.Schedule();
Expand Down
Loading

0 comments on commit 747abd6

Please sign in to comment.