Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.3.8] - 2024-11-08

### Removed

* removing various material assets within entities (Test.mat and TestMaterial.mat).

### Fixed

* Disable "new empty subscene" menu item on default untitled scene.
* Fix invalid queries generated for `IJobEntity` with `[WithPresent(typeof(T))]` and `EnabledRef<T>` and/or `in T` in the same job.
  • Loading branch information
Unity Technologies committed Nov 8, 2024
1 parent 18e63ee commit 39f2f3b
Show file tree
Hide file tree
Showing 46 changed files with 339 additions and 348 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ uid: changelog

# Changelog

## [1.3.8] - 2024-11-08

### Removed

* removing various material assets within entities (Test.mat and TestMaterial.mat).

### Fixed

* Disable "new empty subscene" menu item on default untitled scene.
* Fix invalid queries generated for `IJobEntity` with `[WithPresent(typeof(T))]` and `EnabledRef<T>` and/or `in T` in the same job.


## [1.3.5] - 2024-10-04

### Changed
Expand All @@ -19,6 +31,7 @@ uid: changelog
* Exception thrown under certain circumstances when a system was destroyed could break various DOTS editor windows.



## [1.3.2] - 2024-09-06

### Added
Expand Down
21 changes: 20 additions & 1 deletion Unity.Entities.TestComponents/DependencyTestAuthoring.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using UnityEditor;
using UnityEngine;

namespace Unity.Entities.Tests
Expand All @@ -19,9 +20,27 @@ public override void Bake(DependencyTestAuthoring authoring)
DependsOn(authoring.GameObject);
// This test shouldn't require transform components
var entity = GetEntity(TransformUsageFlags.None);
Color color = default;
if (authoring.Material)
{
DependsOn(authoring.Material);
color = authoring.Material.color;
}
else
{
#if UNITY_EDITOR
var material = AssetDatabase.LoadAssetAtPath<Material>("Assets/TestMaterial.asset");
if (material != null)
{
DependsOn(material);
color = material.color;
}
#endif
}

AddComponent(entity, new ConversionDependencyData
{
MaterialColor = DependsOn(authoring.Material) != null ? authoring.Material.color : default,
MaterialColor = color,
HasMaterial = DependsOn(authoring.Material) != null,
TextureFilterMode = DependsOn(authoring.Texture) != null ? authoring.Texture.filterMode : default,
HasTexture = DependsOn(authoring.Texture) != null
Expand Down
138 changes: 134 additions & 4 deletions Unity.Entities.Tests/ForEachCodegen/JobEntityISystemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void SetUp()
TestEntity = m_Manager.CreateEntity(myArch);
m_Manager.SetComponentData(TestEntity, new EcsTestData { value = 3 });
m_Manager.SetComponentData(TestEntity, new EcsTestData2 { value0 = 4 });
m_Manager.SetComponentData(TestEntity, new EcsTestDataEnableable { value = 17 });
var buffer = m_Manager.GetBuffer<EcsIntElement>(TestEntity);
buffer.Add(new EcsIntElement { Value = 18 });
buffer.Add(new EcsIntElement { Value = 19 });
Expand Down Expand Up @@ -97,14 +98,29 @@ ref SystemState GetSystemStateRef()
public void WithDisabled() => GetTestSystemUnsafe().WithDisabled(ref GetSystemStateRef());

[Test]
public void EnableDisabled() => GetTestSystemUnsafe().EnableDisabled(ref GetSystemStateRef());
public void WithDisabled_RefRW() => GetTestSystemUnsafe().WithDisabled_RefRW(ref GetSystemStateRef());

[Test]
public void WithDisabled_EnabledRefRW() => GetTestSystemUnsafe().WithDisabled_EnabledRefRW(ref GetSystemStateRef());

[Test]
public void WithDisabled_RefRW_EnabledRefRW() => GetTestSystemUnsafe().WithDisabled_RefRW_EnabledRefRW(ref GetSystemStateRef());

[Test]
public void WithAbsent() => GetTestSystemUnsafe().WithAbsent(ref GetSystemStateRef());

[Test]
public void WithPresent() => GetTestSystemUnsafe().WithPresent(ref GetSystemStateRef());

[Test]
public void WithPresent_RefRW() => GetTestSystemUnsafe().WithPresent_RefRW(ref GetSystemStateRef());

[Test]
public void WithPresent_EnabledRefRW() => GetTestSystemUnsafe().WithPresent_EnabledRefRW(ref GetSystemStateRef());

[Test]
public void WithPresent_RefRW_EnabledRefRW() => GetTestSystemUnsafe().WithPresent_RefRW_EnabledRefRW(ref GetSystemStateRef());

[Test]
public void WithAny_DoesntExecute_OnEntityWithoutThatComponent() => GetTestSystemUnsafe().WithAny_DoesntExecute_OnEntityWithoutThatComponent(ref GetSystemStateRef());

Expand Down Expand Up @@ -239,11 +255,31 @@ partial struct WithDisabledJob : IJobEntity
}

[WithDisabled(typeof(EcsTestDataEnableable))]
partial struct EnableDisabledJob : IJobEntity
partial struct WithDisabled_RefRW_Job : IJobEntity
{
public int disabledValue;

void Execute(ref EcsTestData e1, RefRW<EcsTestDataEnableable> ref2) => e1.value = disabledValue + ref2.ValueRO.value;
}

[WithDisabled(typeof(EcsTestDataEnableable))]
partial struct WithDisabled_EnabledRefRW_Job : IJobEntity
{
void Execute(EnabledRefRW<EcsTestDataEnableable> e1) => e1.ValueRW = true;
}

[WithDisabled(typeof(EcsTestDataEnableable))]
partial struct WithDisabled_RefRW_EnabledRefRW_Job : IJobEntity
{
public int disabledValue;

void Execute(ref EcsTestData e1, EnabledRefRW<EcsTestDataEnableable> e2, RefRW<EcsTestDataEnableable> ref2)
{
e1.value = disabledValue + ref2.ValueRO.value;
e2.ValueRW = true;
}
}

[WithAbsent(typeof(EcsTestData3))]
partial struct WithAbsentJob : IJobEntity
{
Expand All @@ -260,6 +296,38 @@ partial struct WithPresentJob : IJobEntity
void Execute(ref EcsTestData e1) => e1.value = presentValue;
}

[WithPresent(typeof(EcsTestDataEnableable))]
partial struct WithPresent_RefRW_Job : IJobEntity
{
public int presentValue;

void Execute(ref EcsTestData e1, RefRW<EcsTestDataEnableable> ref2) => e1.value = presentValue + ref2.ValueRO.value;
}

[WithPresent(typeof(EcsTestDataEnableable))]
partial struct WithPresent_EnabledRefRW_Job : IJobEntity
{
public int presentValue;

void Execute(ref EcsTestData e1, EnabledRefRW<EcsTestDataEnableable> eref2)
{
e1.value = presentValue;
eref2.ValueRW = !eref2.ValueRO;
}
}

[WithPresent(typeof(EcsTestDataEnableable))]
partial struct WithPresent_RefRW_EnabledRefRW_Job : IJobEntity
{
public int presentValue;

void Execute(ref EcsTestData e1, RefRW<EcsTestDataEnableable> ref2, EnabledRefRW<EcsTestDataEnableable> eref2)
{
e1.value = presentValue + ref2.ValueRO.value;
eref2.ValueRW = !eref2.ValueRO;
}
}

[WithAny(typeof(EcsTestData3))]
partial struct WithAny_DoesntExecute_OnEntityWithoutThatComponentJob : IJobEntity
{
Expand Down Expand Up @@ -395,14 +463,32 @@ public void WithDisabled(ref SystemState state)
Assert.AreEqual(1, state.EntityManager.GetComponentData<EcsTestData>(JobEntityISystemTests.TestEntity).value);
}

public void EnableDisabled(ref SystemState state)
public void WithDisabled_RefRW(ref SystemState state)
{
new WithDisabled_RefRW_Job{ disabledValue = 1 }.Schedule();
state.Dependency.Complete();
Assert.AreEqual(1+17, state.EntityManager.GetComponentData<EcsTestData>(JobEntityISystemTests.TestEntity).value);
}

public void WithDisabled_EnabledRefRW(ref SystemState state)
{
Assert.AreEqual(1, SystemAPI.QueryBuilder().WithDisabled<EcsTestDataEnableable>().Build().CalculateEntityCount());
Assert.AreEqual(0, SystemAPI.QueryBuilder().WithAll<EcsTestDataEnableable>().Build().CalculateEntityCount());
new WithDisabled_EnabledRefRW_Job{}.Schedule();
state.Dependency.Complete();
Assert.AreEqual(0, SystemAPI.QueryBuilder().WithDisabled<EcsTestDataEnableable>().Build().CalculateEntityCount());
Assert.AreEqual(1, SystemAPI.QueryBuilder().WithAll<EcsTestDataEnableable>().Build().CalculateEntityCount());
}

public void WithDisabled_RefRW_EnabledRefRW(ref SystemState state)
{
Assert.AreEqual(1, SystemAPI.QueryBuilder().WithDisabled<EcsTestDataEnableable>().Build().CalculateEntityCount());
Assert.AreEqual(0, SystemAPI.QueryBuilder().WithAll<EcsTestDataEnableable>().Build().CalculateEntityCount());
new EnableDisabledJob{}.Schedule();
new WithDisabled_RefRW_EnabledRefRW_Job{ disabledValue = 1 }.Schedule();
state.Dependency.Complete();
Assert.AreEqual(0, SystemAPI.QueryBuilder().WithDisabled<EcsTestDataEnableable>().Build().CalculateEntityCount());
Assert.AreEqual(1, SystemAPI.QueryBuilder().WithAll<EcsTestDataEnableable>().Build().CalculateEntityCount());
Assert.AreEqual(1+17, state.EntityManager.GetComponentData<EcsTestData>(JobEntityISystemTests.TestEntity).value);
}

public void WithAbsent(ref SystemState state)
Expand All @@ -426,6 +512,50 @@ public void WithPresent(ref SystemState state)
Assert.AreEqual(2, state.EntityManager.GetComponentData<EcsTestData>(JobEntityISystemTests.TestEntity).value);
}

public void WithPresent_RefRW(ref SystemState state)
{
// Test with the present component disabled
state.EntityManager.SetComponentEnabled<EcsTestDataEnableable>(JobEntityISystemTests.TestEntity, false);
new WithPresent_RefRW_Job{ presentValue= 1}.Schedule();
state.Dependency.Complete();
Assert.AreEqual(1+17, state.EntityManager.GetComponentData<EcsTestData>(JobEntityISystemTests.TestEntity).value);
// test again with the present component enabled
state.EntityManager.SetComponentEnabled<EcsTestDataEnableable>(JobEntityISystemTests.TestEntity, true);
new WithPresent_RefRW_Job{ presentValue= 2}.Schedule();
state.Dependency.Complete();
Assert.AreEqual(2+17, state.EntityManager.GetComponentData<EcsTestData>(JobEntityISystemTests.TestEntity).value);
}

public void WithPresent_EnabledRefRW(ref SystemState state)
{
// Test with the present component disabled
state.EntityManager.SetComponentEnabled<EcsTestDataEnableable>(JobEntityISystemTests.TestEntity, false);
new WithPresent_EnabledRefRW_Job{ presentValue= 1}.Schedule();
state.Dependency.Complete();
Assert.AreEqual(1, state.EntityManager.GetComponentData<EcsTestData>(JobEntityISystemTests.TestEntity).value);
Assert.IsTrue(state.EntityManager.IsComponentEnabled<EcsTestDataEnableable>(JobEntityISystemTests.TestEntity));
// test again with the present component enabled
new WithPresent_EnabledRefRW_Job{ presentValue= 2}.Schedule();
state.Dependency.Complete();
Assert.AreEqual(2, state.EntityManager.GetComponentData<EcsTestData>(JobEntityISystemTests.TestEntity).value);
Assert.IsFalse(state.EntityManager.IsComponentEnabled<EcsTestDataEnableable>(JobEntityISystemTests.TestEntity));
}

public void WithPresent_RefRW_EnabledRefRW(ref SystemState state)
{
// Test with the present component disabled
state.EntityManager.SetComponentEnabled<EcsTestDataEnableable>(JobEntityISystemTests.TestEntity, false);
new WithPresent_RefRW_EnabledRefRW_Job{ presentValue= 1}.Schedule();
state.Dependency.Complete();
Assert.AreEqual(1+17, state.EntityManager.GetComponentData<EcsTestData>(JobEntityISystemTests.TestEntity).value);
Assert.IsTrue(state.EntityManager.IsComponentEnabled<EcsTestDataEnableable>(JobEntityISystemTests.TestEntity));
// test again with the present component enabled
new WithPresent_RefRW_EnabledRefRW_Job{ presentValue= 2}.Schedule();
state.Dependency.Complete();
Assert.AreEqual(2+17, state.EntityManager.GetComponentData<EcsTestData>(JobEntityISystemTests.TestEntity).value);
Assert.IsFalse(state.EntityManager.IsComponentEnabled<EcsTestDataEnableable>(JobEntityISystemTests.TestEntity));
}

public void WithAny_DoesntExecute_OnEntityWithoutThatComponent(ref SystemState state)
{
new WithAny_DoesntExecute_OnEntityWithoutThatComponentJob { one = 1 }.Schedule();
Expand Down
Binary file modified Unity.Entities/SourceGenerators/AspectGenerator.dll
Binary file not shown.
Binary file modified Unity.Entities/SourceGenerators/AspectGenerator.pdb
Binary file not shown.
Binary file modified Unity.Entities/SourceGenerators/Common.dll
Binary file not shown.
Binary file modified Unity.Entities/SourceGenerators/Common.pdb
Binary file not shown.
Binary file modified Unity.Entities/SourceGenerators/JobEntityGenerator.dll
Binary file not shown.
Binary file modified Unity.Entities/SourceGenerators/JobEntityGenerator.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ public void FillFromAttributes(SyntaxList<AttributeListSyntax> attributeLists, S
case SimpleNameSyntax { Identifier.ValueText: "WithPresent" }:
if (attribute.ArgumentList != null)
foreach (var argument in attribute.ArgumentList.Arguments)
AddQueryInstanceFromAttribute(QueryPresentTypes, argument, QueryType.Present, semanticModel, removeFromQueryAllIfFound: false);
AddQueryInstanceFromAttribute(QueryPresentTypes, argument, QueryType.Present, semanticModel, removeFromQueryAllIfFound: true);
break;
case SimpleNameSyntax { Identifier.ValueText: "WithAbsent" }:
if (attribute.ArgumentList != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public void Reset()
public EntityQueryBuilder WithDisabled<T>() => this;
public EntityQueryBuilder WithDisabledRW<T>() => this;
public EntityQueryBuilder WithAbsent<T>() => this;
public EntityQueryBuilder WithPresent<T>() => this;
public EntityQueryBuilder WithPresentRW<T>() => this;
public EntityQueryBuilder WithAspect<T>() => this;
public EntityQueryBuilder WithOptions(EntityQueryOptions options) => this;
public EntityQueryBuilder AddAdditionalQuery() => this;
Expand Down Expand Up @@ -81,6 +83,14 @@ public sealed class WithDisabledAttribute : Attribute
{
public WithDisabledAttribute(params Type[] types){}
}
public sealed class WithAbsentAttribute : Attribute
{
public WithAbsentAttribute(params Type[] types){}
}
public sealed class WithPresentAttribute : Attribute
{
public WithPresentAttribute(params Type[] types){}
}
public sealed class WithChangeFilterAttribute : Attribute
{
public WithChangeFilterAttribute(params Type[] types){}
Expand Down Expand Up @@ -476,6 +486,7 @@ public struct SystemAPIQueryBuilder
public SystemAPIQueryBuilder WithNone<T1>() => default;
public SystemAPIQueryBuilder WithDisabled<T1>() => default;
public SystemAPIQueryBuilder WithAbsent<T1>() => default;
public SystemAPIQueryBuilder WithPresent<T1>() => default;
public SystemAPIQueryBuilder WithOptions(EntityQueryOptions options) => default;
public EntityQuery Build() => default;
}
Expand Down
Binary file modified Unity.Entities/SourceGenerators/SystemGenerator.Common.dll
Binary file not shown.
Binary file modified Unity.Entities/SourceGenerators/SystemGenerator.Common.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Unity.Entities/SourceGenerators/SystemGenerator.LambdaJobs.dll
Binary file not shown.
Binary file modified Unity.Entities/SourceGenerators/SystemGenerator.LambdaJobs.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Unity.Entities/SourceGenerators/SystemGenerator.SystemAPI.dll
Binary file not shown.
Binary file modified Unity.Entities/SourceGenerators/SystemGenerator.SystemAPI.pdb
Binary file not shown.
Binary file modified Unity.Entities/SourceGenerators/SystemGenerator.dll
Binary file not shown.
Binary file modified Unity.Entities/SourceGenerators/SystemGenerator.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Unity.Entities/SourceGenerators/Unity.Entities.Analyzer.dll
Binary file not shown.
Binary file modified Unity.Entities/SourceGenerators/Unity.Entities.Analyzer.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
Expand Down Expand Up @@ -98,13 +97,14 @@ LightmapSettings:
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
m_LightingSettings: {fileID: 4890085278179872738, guid: 00a1e3be8d77248bfb0ebd4477a42b82,
type: 2}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
serializedVersion: 3
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
Expand All @@ -117,7 +117,9 @@ NavMeshSettings:
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
buildHeightMesh: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
Expand Down Expand Up @@ -152,19 +154,25 @@ MonoBehaviour:
m_EditorClassIdentifier:
GameObject: {fileID: 0}
Asset: {fileID: 0}
Material: {fileID: 2100000, guid: f40229054a993f149aea8b2f9012f687, type: 2}
Texture: {fileID: 0}
Material: {fileID: 0}
Texture: {fileID: 2800000, guid: d52bd2787bc5f5d408f93a562e50feed, type: 2}
--- !u!4 &572202328
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 572202326}
serializedVersion: 2
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: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 572202328}
Loading

0 comments on commit 39f2f3b

Please sign in to comment.